@@ -82,8 +82,8 @@ modificationtests["solve_set_scalaraffine_lessthan"] = solve_set_scalaraffine_le
82
82
"""
83
83
solve_coef_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig)
84
84
85
- Test modifying set of ScalarAffineFunction-in-LessThan constraint. If
86
- `config.solve=true` confirm that it solves correctly, and if
85
+ Test modifying a variable coefficient in a ScalarAffineFunction-in-LessThan
86
+ constraint. If `config.solve=true` confirm that it solves correctly, and if
87
87
`config.duals=true`, check that the duals are computed correctly.
88
88
"""
89
89
function solve_coef_scalaraffine_lessthan (model:: MOI.ModelLike , config:: TestConfig )
@@ -119,13 +119,55 @@ end
119
119
modificationtests[" solve_coef_scalaraffine_lessthan" ] = solve_coef_scalaraffine_lessthan
120
120
121
121
"""
122
- solve_coef_scalar_objective (model::MOI.ModelLike, config::TestConfig)
122
+ solve_const_vectoraffine_nonpos (model::MOI.ModelLike, config::TestConfig)
123
123
124
- Test modifying set of ScalarAffineFunction-in-LessThan constraint. If
125
- `config.solve=true` confirm that it solves correctly, and if
124
+ Test modifying the constant term in a VectorAffineFunction-in-Nonpositives
125
+ constraint. If `config.solve=true` confirm that it solves correctly, and if
126
126
`config.duals=true`, check that the duals are computed correctly.
127
127
"""
128
- function solve_coef_scalar_objective (model:: MOI.ModelLike , config:: TestConfig )
128
+ function solve_const_vectoraffine_nonpos (model:: MOI.ModelLike , config:: TestConfig )
129
+ MOI. empty! (model)
130
+ MOIU. loadfromstring! (model,"""
131
+ variables: x, y
132
+ maxobjective: 1.0x + 2.0y
133
+ """ )
134
+ x = MOI. get (model, MOI. VariableIndex, " x" )
135
+ y = MOI. get (model, MOI. VariableIndex, " y" )
136
+ c = MOI. addconstraint! (model,
137
+ MOI. VectorAffineFunction ([
138
+ MOI. VectorAffineTerm (1 , MOI. ScalarAffineTerm (1.0 , x)),
139
+ MOI. VectorAffineTerm (2 , MOI. ScalarAffineTerm (2.0 , y))
140
+ ],
141
+ [0.0 , 0.0 ]
142
+ ),
143
+ MOI. Nonpositives (2 )
144
+ )
145
+ if config. solve
146
+ test_model_solution (model, config;
147
+ objective_value = 0.0 ,
148
+ variable_primal = [(x, 0.0 ), (y, 0.0 )],
149
+ constraint_primal = [(c, [0.0 , 0.0 ])]
150
+ )
151
+ end
152
+ @test MOI. canmodify (model, typeof (c), MOI. VectorConstantChange{Float64})
153
+ MOI. modify! (model, c, MOI. VectorConstantChange ([- 1.0 , - 1.5 ]))
154
+ if config. solve
155
+ test_model_solution (model, config;
156
+ objective_value = 2.5 ,
157
+ variable_primal = [(x, 1.0 ), (y, 0.75 )],
158
+ constraint_primal = [(c, [0.0 , 0.0 ])]
159
+ )
160
+ end
161
+ end
162
+ modificationtests[" solve_const_vectoraffine_nonpos" ] = solve_const_vectoraffine_nonpos
163
+
164
+ """
165
+ solve_const_scalar_objective(model::MOI.ModelLike, config::TestConfig)
166
+
167
+ Test the constant of a scalaraffine objective. If `config.solve=true` confirm
168
+ that it solves correctly.
169
+ """
170
+ function solve_const_scalar_objective (model:: MOI.ModelLike , config:: TestConfig )
129
171
MOI. empty! (model)
130
172
MOIU. loadfromstring! (model,"""
131
173
variables: x
@@ -154,6 +196,43 @@ function solve_coef_scalar_objective(model::MOI.ModelLike, config::TestConfig)
154
196
)
155
197
end
156
198
end
199
+ modificationtests[" solve_const_scalar_objective" ] = solve_const_scalar_objective
200
+
201
+ """
202
+ solve_coef_scalar_objective(model::MOI.ModelLike, config::TestConfig)
203
+
204
+ Test modifying a variable coefficient in a scalaraffine objective. If
205
+ `config.solve=true` confirm that it solves correctly.
206
+ """
207
+ function solve_coef_scalar_objective (model:: MOI.ModelLike , config:: TestConfig )
208
+ MOI. empty! (model)
209
+ MOIU. loadfromstring! (model,"""
210
+ variables: x
211
+ maxobjective: 1.0x
212
+ c1: 1.0x <= 1.0
213
+ """ )
214
+ x = MOI. get (model, MOI. VariableIndex, " x" )
215
+ if config. solve
216
+ test_model_solution (model, config;
217
+ objective_value = 1.0 ,
218
+ variable_primal = [(x, 1.0 )]
219
+ )
220
+ end
221
+ @test MOI. canmodify (model,
222
+ MOI. ObjectiveFunction {MOI.ScalarAffineFunction{Float64}} (),
223
+ MOI. ScalarCoefficientChange{Float64}
224
+ )
225
+ MOI. modify! (model,
226
+ MOI. ObjectiveFunction {MOI.ScalarAffineFunction{Float64}} (),
227
+ MOI. ScalarCoefficientChange (x, 3.0 )
228
+ )
229
+ if config. solve
230
+ test_model_solution (model, config;
231
+ objective_value = 3.0 ,
232
+ variable_primal = [(x, 1.0 )]
233
+ )
234
+ end
235
+ end
157
236
modificationtests[" solve_coef_scalar_objective" ] = solve_coef_scalar_objective
158
237
159
238
@moitestset modification
0 commit comments