@@ -118,6 +118,50 @@ function solve_coef_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConf
118
118
end
119
119
modificationtests[" solve_coef_scalaraffine_lessthan" ] = solve_coef_scalaraffine_lessthan
120
120
121
+ """
122
+ solve_func_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig)
123
+
124
+ Test setting the function in a ScalarAffineFunction-in-LessThan
125
+ constraint. If `config.solve=true` confirm that it solves correctly, and if
126
+ `config.duals=true`, check that the duals are computed correctly.
127
+ """
128
+ function solve_func_scalaraffine_lessthan (model:: MOI.ModelLike , config:: TestConfig )
129
+ MOI. empty! (model)
130
+ MOIU. loadfromstring! (model,"""
131
+ variables: x
132
+ maxobjective: 1.0x
133
+ """ )
134
+ x = MOI. get (model, MOI. VariableIndex, " x" )
135
+ c = MOI. addconstraint! (model,
136
+ MOI. ScalarAffineFunction ([MOI. ScalarAffineTerm (1.0 , x)], 0.0 ),
137
+ MOI. LessThan (1.0 )
138
+ )
139
+ if config. solve
140
+ test_model_solution (model, config;
141
+ objective_value = 1.0 ,
142
+ variable_primal = [(x, 1.0 )],
143
+ constraint_primal = [(c, 1.0 )],
144
+ constraint_dual = [(c, - 1.0 )]
145
+ )
146
+ end
147
+ @test MOI. canset (model, MOI. ConstraintFunction (), typeof (c))
148
+ MOI. set! (model, MOI. ConstraintFunction (), c,
149
+ MOI. ScalarAffineFunction ([MOI. ScalarAffineTerm (2.0 , x)], 0.0 )
150
+ )
151
+ @test MOI. canget (model, MOI. ConstraintFunction (), typeof (c))
152
+ foo = MOI. get (model, MOI. ConstraintFunction (), c)
153
+ @test_broken foo == MOI. ScalarAffineFunction ([MOI. ScalarAffineTerm (2.0 , x)], 0.0 )
154
+ if config. solve
155
+ test_model_solution (model, config;
156
+ objective_value = 0.5 ,
157
+ variable_primal = [(x, 0.5 )],
158
+ # constraint_primal = [(c, 1.0)],
159
+ constraint_dual = [(c, - 0.5 )]
160
+ )
161
+ end
162
+ end
163
+ modificationtests[" solve_func_scalaraffine_lessthan" ] = solve_func_scalaraffine_lessthan
164
+
121
165
"""
122
166
solve_const_vectoraffine_nonpos(model::MOI.ModelLike, config::TestConfig)
123
167
0 commit comments