Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Utilities/matrix_of_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ function MOI.add_constraint(
),
)
end
if !Utilities.is_canonical(func)
func = Utilities.canonical(func)
end
return _add_constraint(model, i, IdentityMap(), func, set)
end

Expand Down
10 changes: 10 additions & 0 deletions test/Utilities/matrix_of_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,16 @@ function test_dual_power_cone()
return
end

function test_duplicate()
model = _new_ScalarSets()
x = MOI.add_variable(model)
c = MOI.add_constraint(model, 1.0x + 2.0x, MOI.EqualTo(-1.0))
MOI.Utilities.final_touch(model, nothing)
@test MOI.get(model, MOI.ConstraintFunction(), c) ≈ 3.0x
@test MOI.get(model, MOI.ConstraintSet(), c) == MOI.EqualTo(-1.0)
return
end

end

TestMatrixOfConstraints.runtests()