@@ -753,6 +753,105 @@ function test_jump_dual_delete_constraint()
753753 return
754754end
755755
756+ function test_jump_dual_delete_constraint_2 ()
757+ model = Model (() -> POI. Optimizer (GLPK. Optimizer ()))
758+ @variable (model, α in MOI. Parameter (1.0 ))
759+ @variable (model, β in MOI. Parameter (0.0 ))
760+ @variable (model, x)
761+ list = []
762+ cref = @constraint (model, x >= 1 * 1 )
763+ push! (list, cref)
764+ cref = @constraint (model, x >= 9 * α)
765+ push! (list, cref)
766+ cref = @constraint (model, x >= 8 * α + β^ 2 )
767+ push! (list, cref)
768+ cref = @constraint (model, x >= 7 * 1 )
769+ push! (list, cref)
770+ cref = @constraint (model, x >= 6 * α)
771+ push! (list, cref)
772+ cref = @constraint (model, x >= 5 * α + β^ 2 )
773+ push! (list, cref)
774+ cref = @constraint (model, x >= 4 * 1 )
775+ push! (list, cref)
776+ cref = @constraint (model, x >= 3 * α)
777+ push! (list, cref)
778+ cref = @constraint (model, x >= 2 * α + β^ 2 )
779+ push! (list, cref)
780+ @objective (model, Min, x)
781+ cref1 = popfirst! (list)
782+ for i in 9 : - 1 : 2
783+ JuMP. optimize! (model)
784+ @test JuMP. value (x) == 1.0 * i
785+ @test JuMP. dual (cref1) == 0.0
786+ for con in list[2 : end ]
787+ @test JuMP. dual (con) == 0.0
788+ end
789+ @test JuMP. dual (list[1 ]) == 1.0
790+ if i in [7 , 4 ]
791+ @test MOI. get (model, POI. ParameterDual (), α) == 0.0
792+ else
793+ @test MOI. get (model, POI. ParameterDual (), α) == 1.0 * i
794+ end
795+ con = popfirst! (list)
796+ JuMP. delete (model, con)
797+ end
798+ return
799+ end
800+
801+ function test_jump_dual_delete_constraint_3 ()
802+ cached = MOI. Utilities. CachingOptimizer (
803+ MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ()),
804+ SCS. Optimizer (),
805+ )
806+ optimizer = POI. Optimizer (cached)
807+ model = direct_model (optimizer)
808+ set_silent (model)
809+ list = []
810+ @variable (model, α in MOI. Parameter (1.0 ))
811+ @variable (model, β in MOI. Parameter (0.0 ))
812+ @variable (model, x)
813+ cref = @constraint (model, [x - 1 * 1 ] in MOI. Nonnegatives (1 ))
814+ push! (list, cref)
815+ cref = @constraint (model, [x - 9 * α] in MOI. Nonnegatives (1 ))
816+ push! (list, cref)
817+ # cref = @constraint(model, [x - 8 * α + β^2] in MOI.Nonnegatives(1))
818+ cref = @constraint (model, [x - 8 * α + β] in MOI. Nonnegatives (1 ))
819+ push! (list, cref)
820+ cref = @constraint (model, [x - 7 * 1 ] in MOI. Nonnegatives (1 ))
821+ push! (list, cref)
822+ cref = @constraint (model, [x - 6 * α] in MOI. Nonnegatives (1 ))
823+ push! (list, cref)
824+ # cref = @constraint(model, [x - 5 * α + β^2] in MOI.Nonnegatives(1))
825+ cref = @constraint (model, [x - 5 * α + β] in MOI. Nonnegatives (1 ))
826+ push! (list, cref)
827+ cref = @constraint (model, [x - 4 * 1 ] in MOI. Nonnegatives (1 ))
828+ push! (list, cref)
829+ cref = @constraint (model, [x - 3 * α] in MOI. Nonnegatives (1 ))
830+ push! (list, cref)
831+ # cref = @constraint(model, [x - 2 * α + β^2] in MOI.Nonnegatives(1))
832+ cref = @constraint (model, [x - 2 * α + β] in MOI. Nonnegatives (1 ))
833+ push! (list, cref)
834+ @objective (model, Min, 1.0 * x)
835+ cref1 = popfirst! (list)
836+ for i in 9 : - 1 : 2
837+ JuMP. optimize! (model)
838+ @test JuMP. value (x) ≈ 1.0 * i atol = 1e-5
839+ @test JuMP. dual (cref1)[] ≈ 0.0 atol = 1e-5
840+ for con in list[2 : end ]
841+ @test JuMP. dual (con)[] ≈ 0.0 atol = 1e-5
842+ end
843+ @test JuMP. dual (list[1 ])[] ≈ 1.0 atol = 1e-5
844+ if i in [7 , 4 ]
845+ @test MOI. get (model, POI. ParameterDual (), α) ≈ 0.0 atol = 1e-5
846+ else
847+ @test MOI. get (model, POI. ParameterDual (), α) ≈ 1.0 * i atol = 1e-5
848+ end
849+ con = popfirst! (list)
850+ JuMP. delete (model, con)
851+ end
852+ return
853+ end
854+
756855function test_jump_nlp ()
757856 model = Model (() -> ParametricOptInterface. Optimizer (Ipopt. Optimizer ()))
758857 @variable (model, x)
0 commit comments