@@ -1015,3 +1015,44 @@ function test_modification_incorrect_VariableIndex(
10151015 )
10161016 return
10171017end
1018+
1019+ function test_modification_objective_scalarquadraticcoefficientchange (
1020+ model:: MOI.ModelLike ,
1021+ config:: Config{T} ,
1022+ ) where {T}
1023+ attr = MOI. ObjectiveFunction {MOI.ScalarQuadraticFunction{T}} ()
1024+ @requires MOI. supports (model, attr)
1025+ @requires _supports (config, MOI. modify)
1026+ @requires _supports (config, MOI. ScalarQuadraticCoefficientChange)
1027+ x = MOI. add_variable (model)
1028+ MOI. set (model, attr, T (1 ) * x * x + T (2 ) * x + T (3 ))
1029+ @test MOI. get (model, attr) ≈ T (1 ) * x * x + T (2 ) * x + T (3 )
1030+ MOI. modify (model, attr, MOI. ScalarQuadraticCoefficientChange (x, x, T (4 )))
1031+ @test MOI. get (model, attr) ≈ T (2 ) * x * x + T (2 ) * x + T (3 )
1032+ y = MOI. add_variable (model)
1033+ MOI. set (model, attr, T (1 ) * x * x + T (2 ) * x * y)
1034+ @test MOI. get (model, attr) ≈ T (1 ) * x * x + T (2 ) * x * y
1035+ MOI. modify (model, attr, MOI. ScalarQuadraticCoefficientChange (x, y, T (4 )))
1036+ @test MOI. get (model, attr) ≈ T (1 ) * x * x + T (4 ) * x * y
1037+ return
1038+ end
1039+
1040+ function test_modification_constraint_scalarquadraticcoefficientchange (
1041+ model:: MOI.ModelLike ,
1042+ config:: Config{T} ,
1043+ ) where {T}
1044+ F, S = MOI. ScalarQuadraticFunction{T}, MOI. LessThan{T}
1045+ @requires MOI. supports_constraint (model, F, S)
1046+ @requires _supports (config, MOI. modify)
1047+ @requires _supports (config, MOI. ScalarQuadraticCoefficientChange)
1048+ x = MOI. add_variable (model)
1049+ y = MOI. add_variable (model)
1050+ f = T (1 ) * x * x + T (1 ) * x * x - T (1 ) * x * y + T (2 ) * y * y - T (1 ) * x * y
1051+ c = MOI. add_constraint (model, f, MOI. LessThan (T (1 )))
1052+ @test MOI. get (model, MOI. ConstraintFunction (), c) ≈ f
1053+ g = T (1 ) * x * x + T (- 3 ) * x * y + T (2 ) * y * y
1054+ MOI. modify (model, c, MOI. ScalarQuadraticCoefficientChange (x, x, T (2 )))
1055+ MOI. modify (model, c, MOI. ScalarQuadraticCoefficientChange (x, y, - T (3 )))
1056+ @test MOI. get (model, MOI. ConstraintFunction (), c) ≈ g
1057+ return
1058+ end
0 commit comments