|
1 | 1 | const modificationtests = Dict{String, Function}()
|
2 | 2 |
|
3 | 3 | """
|
4 |
| - solve_modify_variable_bound(model::MOI.ModelLike, config::TestConfig) |
| 4 | + solve_set_singlevariable_lessthan(model::MOI.ModelLike, config::TestConfig) |
5 | 5 |
|
6 | 6 | Test set modification SingleVariable-in-LessThan constraint. If
|
7 | 7 | `config.solve=true` confirm that it solves correctly, and if
|
8 | 8 | `config.duals=true`, check that the duals are computed correctly.
|
9 | 9 | """
|
10 |
| -function solve_modify_variable_bound(model::MOI.ModelLike, config::TestConfig) |
| 10 | +function solve_set_singlevariable_lessthan(model::MOI.ModelLike, config::TestConfig) |
11 | 11 | MOI.empty!(model)
|
12 | 12 | MOIU.loadfromstring!(model,"""
|
13 | 13 | variables: x
|
@@ -36,16 +36,16 @@ function solve_modify_variable_bound(model::MOI.ModelLike, config::TestConfig)
|
36 | 36 | )
|
37 | 37 | end
|
38 | 38 | end
|
39 |
| -modificationtests["solve_modify_variable_bound"] = solve_modify_variable_bound |
| 39 | +modificationtests["solve_set_singlevariable_lessthan"] = solve_set_singlevariable_lessthan |
40 | 40 |
|
41 | 41 | """
|
42 |
| - solve_modify_rhs(model::MOI.ModelLike, config::TestConfig) |
| 42 | + solve_set_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig) |
43 | 43 |
|
44 | 44 | Test modifying set of ScalarAffineFunction-in-LessThan constraint. If
|
45 | 45 | `config.solve=true` confirm that it solves correctly, and if
|
46 | 46 | `config.duals=true`, check that the duals are computed correctly.
|
47 | 47 | """
|
48 |
| -function solve_modify_rhs(model::MOI.ModelLike, config::TestConfig) |
| 48 | +function solve_set_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig) |
49 | 49 | MOI.empty!(model)
|
50 | 50 | MOIU.loadfromstring!(model,"""
|
51 | 51 | variables: x
|
@@ -77,6 +77,83 @@ function solve_modify_rhs(model::MOI.ModelLike, config::TestConfig)
|
77 | 77 | )
|
78 | 78 | end
|
79 | 79 | end
|
80 |
| -modificationtests["solve_modify_rhs"] = solve_modify_rhs |
| 80 | +modificationtests["solve_set_scalaraffine_lessthan"] = solve_set_scalaraffine_lessthan |
| 81 | + |
| 82 | +""" |
| 83 | + solve_coef_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig) |
| 84 | +
|
| 85 | +Test modifying set of ScalarAffineFunction-in-LessThan constraint. If |
| 86 | +`config.solve=true` confirm that it solves correctly, and if |
| 87 | +`config.duals=true`, check that the duals are computed correctly. |
| 88 | +""" |
| 89 | +function solve_coef_scalaraffine_lessthan(model::MOI.ModelLike, config::TestConfig) |
| 90 | + MOI.empty!(model) |
| 91 | + MOIU.loadfromstring!(model,""" |
| 92 | + variables: x |
| 93 | + maxobjective: 1.0x |
| 94 | + """) |
| 95 | + x = MOI.get(model, MOI.VariableIndex, "x") |
| 96 | + c = MOI.addconstraint!(model, |
| 97 | + MOI.ScalarAffineFunction([MOI.ScalarAffineTerm(1.0, x)], 0.0), |
| 98 | + MOI.LessThan(1.0) |
| 99 | + ) |
| 100 | + if config.solve |
| 101 | + test_model_solution(model, config; |
| 102 | + objective_value = 1.0, |
| 103 | + variable_primal = [(x, 1.0)], |
| 104 | + constraint_primal = [(c, 1.0)], |
| 105 | + constraint_dual = [(c, -1.0)] |
| 106 | + ) |
| 107 | + end |
| 108 | + @test MOI.canmodify(model, typeof(c), MOI.ScalarCoefficientChange{Float64}) |
| 109 | + MOI.modify!(model, c, MOI.ScalarCoefficientChange(x, 2.0)) |
| 110 | + if config.solve |
| 111 | + test_model_solution(model, config; |
| 112 | + objective_value = 0.5, |
| 113 | + variable_primal = [(x, 0.5)], |
| 114 | + constraint_primal = [(c, 1.0)], |
| 115 | + constraint_dual = [(c, -0.5)] |
| 116 | + ) |
| 117 | + end |
| 118 | +end |
| 119 | +modificationtests["solve_coef_scalaraffine_lessthan"] = solve_coef_scalaraffine_lessthan |
| 120 | + |
| 121 | +""" |
| 122 | + solve_coef_scalar_objective(model::MOI.ModelLike, config::TestConfig) |
| 123 | +
|
| 124 | +Test modifying set of ScalarAffineFunction-in-LessThan constraint. If |
| 125 | +`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_coef_scalar_objective(model::MOI.ModelLike, config::TestConfig) |
| 129 | + MOI.empty!(model) |
| 130 | + MOIU.loadfromstring!(model,""" |
| 131 | + variables: x |
| 132 | + maxobjective: 1.0x + 2.0 |
| 133 | + c1: 1.0x <= 1.0 |
| 134 | + """) |
| 135 | + x = MOI.get(model, MOI.VariableIndex, "x") |
| 136 | + if config.solve |
| 137 | + test_model_solution(model, config; |
| 138 | + objective_value = 3.0, |
| 139 | + variable_primal = [(x, 1.0)] |
| 140 | + ) |
| 141 | + end |
| 142 | + @test MOI.canmodify(model, |
| 143 | + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), |
| 144 | + MOI.ScalarConstantChange{Float64} |
| 145 | + ) |
| 146 | + MOI.modify!(model, |
| 147 | + MOI.ObjectiveFunction{MOI.ScalarAffineFunction{Float64}}(), |
| 148 | + MOI.ScalarConstantChange(3.0) |
| 149 | + ) |
| 150 | + if config.solve |
| 151 | + test_model_solution(model, config; |
| 152 | + objective_value = 4.0, |
| 153 | + variable_primal = [(x, 1.0)] |
| 154 | + ) |
| 155 | + end |
| 156 | +end |
| 157 | +modificationtests["solve_coef_scalar_objective"] = solve_coef_scalar_objective |
81 | 158 |
|
82 | 159 | @moitestset modification
|
0 commit comments