@@ -353,4 +353,41 @@ function delete_variable_with_single_variable_obj(model::MOI.ModelLike,
353353end
354354modificationtests[" delete_variable_with_single_variable_obj" ] = delete_variable_with_single_variable_obj
355355
356+ """
357+ delete_variables_in_a_batch(model::MOI.ModelLike, config::TestConfig)
358+
359+ Test deleting many variables in a batch (i.e. using the delete method which
360+ takes a vector of variable references). If `config.solve=true` confirm that it
361+ solves correctly.
362+ """
363+ function delete_variables_in_a_batch (model:: MOI.ModelLike ,
364+ config:: TestConfig )
365+ MOI. empty! (model)
366+ @test MOI. is_empty (model)
367+ MOIU. loadfromstring! (model,"""
368+ variables: x, y, z
369+ minobjective: 1.0 * x + 2.0 * y + 3.0 * z
370+ c1: x >= 1.0
371+ c2: y >= 1.0
372+ c3: z >= 1.0
373+ """ )
374+ x, y, z = MOI. get (model, MOI. ListOfVariableIndices ())
375+ @test MOI. is_valid (model, x)
376+ @test MOI. is_valid (model, y)
377+ @test MOI. is_valid (model, z)
378+ if config. solve
379+ MOI. optimize! (model)
380+ @test MOI. get (model, MOI. ObjectiveValue ()) == 6.0
381+ end
382+ MOI. delete (model, [x, z])
383+ @test ! MOI. is_valid (model, x)
384+ @test MOI. is_valid (model, y)
385+ @test ! MOI. is_valid (model, z)
386+ if config. solve
387+ MOI. optimize! (model)
388+ @test MOI. get (model, MOI. ObjectiveValue ()) == 2.0
389+ end
390+ end
391+ modificationtests[" delete_variables_in_a_batch" ] = delete_variables_in_a_batch
392+
356393@moitestset modification
0 commit comments