|
30 | 30 | exception = ErrorException( |
31 | 31 | "Cannot query $(attr) from caching optimizer because no optimizer" * |
32 | 32 | " is attached.") |
33 | | - @test_throws Exception MOI.get(model, MOI.SolverName()) |
| 33 | + @test_throws exception MOI.get(model, attr) |
| 34 | + attr = MOI.Silent() |
| 35 | + exception = ErrorException( |
| 36 | + "Cannot query $(attr) from caching optimizer because no optimizer" * |
| 37 | + " is attached.") |
| 38 | + @test_throws exception MOI.get(model, attr) |
34 | 39 |
|
35 | 40 | attr = MOI.ResultCount() |
36 | 41 | exception = ErrorException( |
37 | 42 | "Cannot query $(attr) from caching optimizer because no optimizer" * |
38 | 43 | " is attached.") |
39 | | - @test_throws Exception MOI.get(model, MOI.ResultCount()) |
| 44 | + @test_throws exception MOI.get(model, attr) |
40 | 45 | end |
41 | 46 | end |
42 | 47 |
|
| 48 | +@testset "Copyable solver attributes" begin |
| 49 | + cache = MOIU.UniversalFallback(ModelForCachingOptimizer{Float64}()) |
| 50 | + cached = MOIU.CachingOptimizer(cache, MOIU.MANUAL) |
| 51 | + MOI.set(cached, MOI.Silent(), true) |
| 52 | + mock = MOIU.MockOptimizer(MOIU.UniversalFallback(ModelForMock{Float64}())) |
| 53 | + MOIU.reset_optimizer(cached, mock) |
| 54 | + @test MOI.get(mock, MOI.Silent()) |
| 55 | + @test MOI.get(cached, MOI.Silent()) |
| 56 | + MOI.set(cached, MOI.Silent(), false) |
| 57 | + @test !MOI.get(mock, MOI.Silent()) |
| 58 | + @test !MOI.get(cached, MOI.Silent()) |
| 59 | + mock = MOIU.MockOptimizer(MOIU.UniversalFallback(ModelForMock{Float64}())) |
| 60 | + MOIU.reset_optimizer(cached, mock) |
| 61 | + @test !MOI.get(mock, MOI.Silent()) |
| 62 | + @test !MOI.get(cached, MOI.Silent()) |
| 63 | + MOI.set(cached, MOI.Silent(), true) |
| 64 | + @test MOI.get(mock, MOI.Silent()) |
| 65 | + @test MOI.get(cached, MOI.Silent()) |
| 66 | + mock = MOIU.MockOptimizer(MOIU.UniversalFallback(ModelForMock{Float64}())) |
| 67 | + MOIU.reset_optimizer(cached, mock) |
| 68 | + @test MOI.get(mock, MOI.Silent()) |
| 69 | + @test MOI.get(cached, MOI.Silent()) |
| 70 | +end |
| 71 | + |
43 | 72 | @testset "CachingOptimizer MANUAL mode" begin |
44 | 73 | m = MOIU.CachingOptimizer(ModelForCachingOptimizer{Float64}(), MOIU.MANUAL) |
45 | 74 | @test MOIU.state(m) == MOIU.NO_OPTIMIZER |
|
0 commit comments