|
203 | 203 | MOI.set(mockoptimizer, MOI.ConstraintDual(), JuMP.optimizer_index(c), -12.0) |
204 | 204 | end |
205 | 205 | end |
| 206 | + for v in all_variables(tb.model) |
| 207 | + MOI.set(mockoptimizer, MOI.VariablePrimal(1), JuMP.optimizer_index(v), 1.0) |
| 208 | + end |
206 | 209 | # MOI.set(mockoptimizer, MOI.ConstraintDual(), JuMP.optimizer_index(creft), 7.0) |
207 | 210 | MOI.set(mockoptimizer, MOI.VariablePrimal(1), JuMP.optimizer_index(gt), 1.0) |
208 | 211 | MOI.set(mockoptimizer, MOI.VariablePrimal(1), JuMP.optimizer_index(inft[1]), 2.0) |
|
270 | 273 | @test isa(optimizer_index(inf, label = InternalLabel), Vector{MOI.VariableIndex}) |
271 | 274 | @test isa(optimizer_index(rv), Vector{MOI.VariableIndex}) |
272 | 275 | end |
| 276 | + # test warmstart_backend_start_values |
| 277 | + @testset "warmstart_backend_start_values" begin |
| 278 | + @test warmstart_backend_start_values(m) isa Nothing |
| 279 | + @test start_value(gt) == 1 |
| 280 | + end |
273 | 281 | # test dual |
274 | 282 | @testset "JuMP.dual" begin |
275 | 283 | @test_throws ErrorException dual(g) |
@@ -436,12 +444,21 @@ end |
436 | 444 | @test shadow_price(c4) == [-2, -3] |
437 | 445 | @test_throws ErrorException InfiniteOpt.map_shadow_price(c1, TestBackend()) |
438 | 446 | end |
| 447 | + # test warmstart_backend_start_values |
| 448 | + @testset "warmstart_backend_start_values" begin |
| 449 | + @test warmstart_backend_start_values(m) isa Nothing |
| 450 | + @test start_value(c1t) == 1 |
| 451 | + @test dual_start_value(c1t) == -1 |
| 452 | + @test_throws ErrorException warmstart_backend_start_values(TestBackend()) |
| 453 | + end |
439 | 454 | # test model not up to date |
440 | 455 | set_objective_sense(m, MOI.MAX_SENSE) |
441 | 456 | @testset "Not up-to-date" begin |
442 | 457 | @test_throws ErrorException dual(c1) |
443 | 458 | @test_throws ErrorException shadow_price(c1) |
444 | 459 | @test_throws ErrorException optimizer_index(c1) |
| 460 | + str = "No previous solution values found to warmstart the backend." |
| 461 | + @test_logs (:warn, str) warmstart_backend_start_values(m) |
445 | 462 | end |
446 | 463 | end |
447 | 464 |
|
|
0 commit comments