@@ -49,6 +49,33 @@ function test_knapsack()
4949 return
5050end
5151
52+ function test_caching_optimizer_knapsack ()
53+ model = MOI. instantiate (
54+ () -> MOA. Optimizer (HiGHS. Optimizer);
55+ with_cache_type = Float64,
56+ )
57+ P = Float64[1 0 0 0 ; 0 1 0 0 ; 0 0 0 1 ; 0 0 1 0 ]
58+ MOI. set (model, MOA. Algorithm (), MOA. Lexicographic ())
59+ @test MOI. supports (model, MOA. LexicographicAllPermutations ())
60+ @test MOI. supports (model, MOA. ObjectiveRelativeTolerance (1 ))
61+ MOI. set (model, MOA. LexicographicAllPermutations (), false )
62+ MOI. set (model, MOA. ObjectiveRelativeTolerance (1 ), 0.1 )
63+ MOI. set (model, MOI. Silent (), true )
64+ x = MOI. add_variables (model, 4 )
65+ MOI. add_constraint .(model, x, MOI. GreaterThan (0.0 ))
66+ MOI. add_constraint .(model, x, MOI. LessThan (1.0 ))
67+ MOI. set (model, MOI. ObjectiveSense (), MOI. MAX_SENSE)
68+ f = MOI. Utilities. operate (vcat, Float64, P * x... )
69+ f. constants[4 ] = 1_000.0
70+ MOI. set (model, MOI. ObjectiveFunction {typeof(f)} (), f)
71+ MOI. add_constraint (model, sum (1.0 * x[i] for i in 1 : 4 ), MOI. LessThan (2.0 ))
72+ MOI. optimize! (model)
73+ @test MOI. get (model, MOI. ResultCount ()) == 1
74+ x_sol = MOI. get (model, MOI. VariablePrimal (), x)
75+ @test ≈ (x_sol, [0.9 , 1 , 0 , 0.1 ]; atol = 1e-3 )
76+ return
77+ end
78+
5279function test_knapsack_default ()
5380 P = Float64[1 0 0 0 ; 0 1 0 0 ; 0 0 0 1 ]
5481 model = MOA. Optimizer (HiGHS. Optimizer)
0 commit comments