Skip to content

Commit ec29a5c

Browse files
committed
fix conflict
2 parents 232c5a6 + 19e4a9e commit ec29a5c

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/functions.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -579,17 +579,16 @@ function VectorAffineFunction{T}(f::VectorOfVariables) where {T}
579579
end
580580

581581
function 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
593592
end
594593

595594
"""

test/functions.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,16 @@ end
131131

132132
function 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
138144
end
139145

140146
function test_isapprox_VectorOfVariables()

0 commit comments

Comments
 (0)