File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 33
44import pytest
55
6+ import mip
67from mip import (
78 CBC ,
89 Column ,
@@ -1315,3 +1316,31 @@ def test_remove(solver):
13151316
13161317 m .remove (constr )
13171318 m .remove (x )
1319+
1320+ @pytest .mark .parametrize ("solver" , SOLVERS )
1321+ def test_add_equation (solver ):
1322+ m = Model (solver_name = solver )
1323+ x = m .add_var ("x" )
1324+ constr = m .add_constr (x == 23.5 )
1325+
1326+ status = m .optimize ()
1327+ assert status == OptimizationStatus .OPTIMAL
1328+
1329+ assert x .x == pytest .approx (23.5 )
1330+
1331+ @pytest .mark .parametrize ("solver" , SOLVERS )
1332+ def test_change_objective_sense (solver ):
1333+ m = Model (solver_name = solver )
1334+ x = m .add_var ("x" , lb = 10.0 , ub = 20.0 )
1335+
1336+ # first maximize
1337+ m .objective = mip .maximize (x )
1338+ status = m .optimize ()
1339+ assert status == OptimizationStatus .OPTIMAL
1340+ assert x .x == pytest .approx (20.0 )
1341+
1342+ # then minimize
1343+ m .objective = mip .minimize (x )
1344+ status = m .optimize ()
1345+ assert status == OptimizationStatus .OPTIMAL
1346+ assert x .x == pytest .approx (10.0 )
You can’t perform that action at this time.
0 commit comments