@@ -14,40 +14,24 @@ function MOIU.allocate_constraint(m::SOItoMOIBridge, f::SAF, s::SupportedSets)
1414 _allocate_constraint (m:: SOItoMOIBridge , f, s)
1515end
1616
17- output_index (:: MOI.ScalarAffineTerm ) = 1
18- output_index (t:: MOI.VectorAffineTerm ) = t. output_index
19- scalar_term (t:: MOI.ScalarAffineTerm ) = t
20- scalar_term (t:: MOI.VectorAffineTerm ) = t. scalar_term
21-
22- _getconstant (m:: SOItoMOIBridge , s:: MOI.AbstractScalarSet ) = MOIU. getconstant (s)
23- _getconstant (m:: SOItoMOIBridge{T} , s:: MOI.AbstractSet ) where T = zero (T)
24-
25- function loadcoefficients! (m:: SOItoMOIBridge , cs:: UnitRange , f:: SAF , s)
17+ function loadcoefficients! (m:: SOItoMOIBridge , cs:: UnitRange ,
18+ f:: MOI.ScalarAffineFunction , s)
2619 f = MOIU. canonical (f) # sum terms with same variables and same outputindex
27- if ! isempty (cs)
28- rhs = _getconstant (m, s) .- MOI. _constant (f)
29- for t in f. terms
30- st = scalar_term (t)
31- if ! iszero (st. coefficient)
32- c = cs[output_index (t)]
33- for (blk, i, j, coef, shift) in varmap (m, st. variable_index)
34- if ! iszero (blk)
35- @assert ! iszero (coef)
36- setconstraintcoefficient! (m. sdoptimizer, st. coefficient* coef, c, blk, i, j)
37- end
38- if isa (rhs, Vector)
39- rhs[output_index (t)] -= st. coefficient * shift
40- else
41- rhs -= st. coefficient * shift
42- end
20+ @assert length (cs) == 1
21+ c = first (cs)
22+ rhs = MOIU. getconstant (s) - MOI. _constant (f)
23+ for t in f. terms
24+ if ! iszero (t. coefficient)
25+ for (blk, i, j, coef, shift) in varmap (m, t. variable_index)
26+ if ! iszero (blk)
27+ @assert ! iszero (coef)
28+ setconstraintcoefficient! (m. sdoptimizer, t. coefficient* coef, c, blk, i, j)
4329 end
30+ rhs -= t. coefficient * shift
4431 end
4532 end
46- for j in 1 : MOI. output_dimension (f)
47- c = cs[j]
48- setconstraintconstant! (m. sdoptimizer, rhs[j], c)
49- end
5033 end
34+ setconstraintconstant! (m. sdoptimizer, rhs, c)
5135end
5236
5337function MOIU. load_constraint (m:: SOItoMOIBridge , ci:: CI , f:: SAF , s:: SupportedSets )
0 commit comments