@@ -196,6 +196,51 @@ function solve_func_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConf
196196end
197197modificationtests[" solve_func_scalaraffine_lessthan" ] = solve_func_scalaraffine_lessthan
198198
199+ """
200+ solve_func_vectoraffine_nonneg(model::MOI.ModelLike, config::TestConfig)
201+
202+ Test setting the function in a VectorAffineFunction-in-Nonnegatives
203+ constraint. If `config.solve=true` confirm that it solves correctly, and if
204+ `config.duals=true`, check that the duals are computed correctly.
205+ """
206+ function solve_func_vectoraffine_nonneg (model:: MOI.ModelLike , config:: TestConfig )
207+ MOI. empty! (model)
208+ MOIU. loadfromstring! (model,"""
209+ variables: x, y
210+ minobjective: 1.0x + 2.0y
211+ c: [1.0x, 2.0y] in Nonnegatives(2)
212+ """ )
213+ x = MOI. get (model, MOI. VariableIndex, " x" )
214+ y = MOI. get (model, MOI. VariableIndex, " y" )
215+ c = MOI. get (model, MOI. ConstraintIndex, " c" )
216+ test_model_solution (model, config;
217+ objective_value = 0.0 ,
218+ variable_primal = [(x, 0.0 ), (y, 0.0 )],
219+ constraint_primal = [(c, [0.0 , 0.0 ])]
220+ )
221+ MOI. set (model, MOI. ConstraintFunction (), c,
222+ MOI. VectorAffineFunction ([
223+ MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , x)),
224+ MOI. VectorAffineTerm (2 , MOI. ScalarAffineTerm (2.0 , y))
225+ ],
226+ [- 1.0 , - 1.5 ]
227+ )
228+ )
229+ foo = MOI. get (model, MOI. ConstraintFunction (), c)
230+ @test foo ≈ MOI. VectorAffineFunction ([
231+ MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , x)),
232+ MOI. VectorAffineTerm (2 , MOI. ScalarAffineTerm (2.0 , y))
233+ ],
234+ [- 1.0 , - 1.5 ]
235+ )
236+ test_model_solution (model, config;
237+ objective_value = 2.5 ,
238+ variable_primal = [(x, 1.0 ), (y, 0.75 )],
239+ constraint_primal = [(c, [0.0 , 0.0 ])]
240+ )
241+ end
242+ modificationtests[" solve_func_vectoraffine_nonneg" ] = solve_func_vectoraffine_nonneg
243+
199244"""
200245 solve_const_vectoraffine_nonpos(model::MOI.ModelLike, config::TestConfig)
201246
0 commit comments