File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,31 @@ def test_reopt_many_variables_sparse_objective(self):
7373 self .assertAlmostEqual (m .getVal (vars [50 ]), 0.0 )
7474 self .assertAlmostEqual (m .getVal (vars [99 ]), 0.0 )
7575
76+ def test_freeReoptSolve_requires_reoptimization_enabled (self ):
77+ """freeReoptSolve must raise ValueError instead of crashing when
78+ reoptimization was not enabled (see issue #624)."""
79+ m = Model ()
80+ m .hideOutput ()
81+ self .assertFalse (m .isReoptEnabled ())
82+
83+ x = m .addVar (name = "x" , vtype = "I" , ub = 10 )
84+ m .addCons (x >= 3 )
85+ m .setObjective (x )
86+ m .optimize ()
87+
88+ with self .assertRaises (ValueError ):
89+ m .freeReoptSolve ()
90+
91+ m2 = Model ()
92+ m2 .enableReoptimization ()
93+ self .assertTrue (m2 .isReoptEnabled ())
94+ m2 .hideOutput ()
95+ y = m2 .addVar (name = "y" , vtype = "I" , ub = 10 )
96+ m2 .addCons (y >= 3 )
97+ m2 .setObjective (y )
98+ m2 .optimize ()
99+ m2 .freeReoptSolve ()
100+
76101 def test_reopt_zero_objective (self ):
77102 """Test reoptimization with zero objective (no variables, all coefficients zero)."""
78103 m = Model ()
You can’t perform that action at this time.
0 commit comments