@@ -758,37 +758,99 @@ function test_jump_dual_delete_constraint_2()
758758 import ParametricOptInterface as POI
759759 model = Model (() -> POI. Optimizer (GLPK. Optimizer ()))
760760 @variable (model, α in MOI. Parameter (1.0 ))
761+ @variable (model, β in MOI. Parameter (0.0 ))
761762 @variable (model, x)
762763 list = []
763764 cref = @constraint (model, x >= 1 * 1 )
764765 push! (list, cref)
765766 cref = @constraint (model, x >= 9 * α)
766767 push! (list, cref)
767- cref = @constraint (model, x >= 8 * α^ 2 )
768+ cref = @constraint (model, x >= 8 * α + β ^ 2 )
768769 push! (list, cref)
769770 cref = @constraint (model, x >= 7 * 1 )
770771 push! (list, cref)
771772 cref = @constraint (model, x >= 6 * α)
772773 push! (list, cref)
773- cref = @constraint (model, x >= 5 * α^ 2 )
774+ cref = @constraint (model, x >= 5 * α + β ^ 2 )
774775 push! (list, cref)
775776 cref = @constraint (model, x >= 4 * 1 )
776777 push! (list, cref)
777778 cref = @constraint (model, x >= 3 * α)
778779 push! (list, cref)
779- cref = @constraint (model, x >= 2 * α^ 2 )
780+ cref = @constraint (model, x >= 2 * α + β ^ 2 )
780781 push! (list, cref)
781782 @objective (model, Min, x)
782783 cref1 = popfirst! (list)
783- for i in 9 : 2
784+ for i in 9 : - 1 : 2
784785 JuMP. optimize! (model)
785786 @test JuMP. value (x) == 1.0 * i
786787 @test JuMP. dual (cref1) == 0.0
787788 for con in list[2 : end ]
788789 @test JuMP. dual (con) == 0.0
789790 end
790791 @test JuMP. dual (list[1 ]) == 1.0
791- @test MOI. get (model, POI. ParameterDual (), α) == 1.0 * i
792+ if i in [7 , 4 ]
793+ @test MOI. get (model, POI. ParameterDual (), α) == 0.0
794+ else
795+ @test MOI. get (model, POI. ParameterDual (), α) == 1.0 * i
796+ end
797+ con = popfirst! (list)
798+ JuMP. delete (model, con)
799+ end
800+ return
801+ end
802+
803+ function test_jump_dual_delete_constraint_3 ()
804+ using Test, JuMP, SCS
805+ import ParametricOptInterface as POI
806+ import MathOptInterface as MOI
807+ cached = MOI. Utilities. CachingOptimizer (
808+ MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ()),
809+ SCS. Optimizer (),
810+ )
811+ optimizer = POI. Optimizer (cached)
812+ model = direct_model (optimizer)
813+ set_silent (model)
814+ list = []
815+ @variable (model, α in MOI. Parameter (1.0 ))
816+ @variable (model, β in MOI. Parameter (0.0 ))
817+ @variable (model, x)
818+ cref = @constraint (model, [x - 1 * 1 ] in MOI. Nonnegatives (1 ))
819+ push! (list, cref)
820+ cref = @constraint (model, [x - 9 * α] in MOI. Nonnegatives (1 ))
821+ push! (list, cref)
822+ # cref = @constraint(model, [x - 8 * α + β^2] in MOI.Nonnegatives(1))
823+ cref = @constraint (model, [x - 8 * α + β] in MOI. Nonnegatives (1 ))
824+ push! (list, cref)
825+ cref = @constraint (model, [x - 7 * 1 ] in MOI. Nonnegatives (1 ))
826+ push! (list, cref)
827+ cref = @constraint (model, [x - 6 * α] in MOI. Nonnegatives (1 ))
828+ push! (list, cref)
829+ # cref = @constraint(model, [x - 5 * α + β^2] in MOI.Nonnegatives(1))
830+ cref = @constraint (model, [x - 5 * α + β] in MOI. Nonnegatives (1 ))
831+ push! (list, cref)
832+ cref = @constraint (model, [x - 4 * 1 ] in MOI. Nonnegatives (1 ))
833+ push! (list, cref)
834+ cref = @constraint (model, [x - 3 * α] in MOI. Nonnegatives (1 ))
835+ push! (list, cref)
836+ # cref = @constraint(model, [x - 2 * α + β^2] in MOI.Nonnegatives(1))
837+ cref = @constraint (model, [x - 2 * α + β] in MOI. Nonnegatives (1 ))
838+ push! (list, cref)
839+ @objective (model, Min, 1.0 * x)
840+ cref1 = popfirst! (list)
841+ for i in 9 : - 1 : 2
842+ JuMP. optimize! (model)
843+ @test JuMP. value (x) ≈ 1.0 * i atol = 1e-5
844+ @test JuMP. dual (cref1)[] ≈ 0.0 atol = 1e-5
845+ for con in list[2 : end ]
846+ @test JuMP. dual (con)[] ≈ 0.0 atol = 1e-5
847+ end
848+ @test JuMP. dual (list[1 ])[] ≈ 1.0 atol = 1e-5
849+ if i in [7 , 4 ]
850+ @test MOI. get (model, POI. ParameterDual (), α) ≈ 0.0 atol = 1e-5
851+ else
852+ @test MOI. get (model, POI. ParameterDual (), α) ≈ 1.0 * i atol = 1e-5
853+ end
792854 con = popfirst! (list)
793855 JuMP. delete (model, con)
794856 end
0 commit comments