File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed
Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -579,17 +579,16 @@ function VectorAffineFunction{T}(f::VectorOfVariables) where {T}
579579end
580580
581581function VectorAffineFunction (
582- elements :: AbstractVector{ScalarAffineFunction{T}} ,
582+ rows :: AbstractVector{ScalarAffineFunction{T}}
583583) where {T}
584- terms = Vector {VectorAffineTerm{T}} ()
585- constants = Vector {T} ()
586- for (idx, saf) in enumerate (elements)
587- push! (constants, saf. constant)
588- for term in saf. terms
589- push! (terms, VectorAffineTerm (idx, term))
584+ ret = VectorAffineFunction {T} (VectorAffineTerm{T}[], T[])
585+ for (row, f) in enumerate (rows)
586+ push! (ret. constants, f. constant)
587+ for term in f. terms
588+ push! (ret. terms, VectorAffineTerm (row, term))
590589 end
591590 end
592- return VectorAffineFunction {T} (terms, constants)
591+ return ret
593592end
594593
595594"""
Original file line number Diff line number Diff line change @@ -131,10 +131,16 @@ end
131131
132132function test_vectoraffinefunction_creation ()
133133 x = MOI. VariableIndex (1 )
134- f = MOI. VectorAffineFunction ([1.0 * x, 2.0 * x])
135- @test f. constants == [0.0 , 0.0 ]
136- @test f. terms[1 ]. scalar_term. coefficient == 1.0
137- @test f. terms[2 ]. scalar_term. coefficient == 2.0
134+ f = MOI. VectorAffineFunction ([1.0 * x + 2.0 , 3.0 * x + 4.0 ])
135+ g = MOI. VectorAffineFunction (
136+ MOI. VectorAffineTerm{Float64}[
137+ MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , x)),
138+ MOI. VectorAffineTerm (2 , MOI. ScalarAffineTerm (3.0 , x)),
139+ ],
140+ [2.0 , 4.0 ],
141+ )
142+ @test f ≈ g
143+ return
138144end
139145
140146function test_isapprox_VectorOfVariables ()
You can’t perform that action at this time.
0 commit comments