File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""This example reads a MIP (in .lp or .mps), solves its linear programming
22relaxation and then tests the impact of adding different types of cutting
3- planes. In the end, the it informs which cut generator produced the best bound
4- improvement."""
3+ planes. In the end, it informs which cut generator produced the best bound
4+ improvement.
5+ """
56
67from textwrap import shorten
7- import sys
88from mip import Model , CutType , OptimizationStatus
99import mip
1010
11- lp_path = ""
12-
1311# using test data
1412lp_path = mip .__file__ .replace ("mip/__init__.py" , "test/data/1443_0-9.lp" ).replace (
1513 "mip\\ __init__.py" , "test\\ data\\ 1443_0-9.lp"
1614)
1715
1816m = Model ()
19- if m .solver_name .upper () in [ "GRB" , "GUROBI" ] :
20- print ("This feature is currently not supported in Gurobi ." )
17+ if m .solver_name .upper () != mip . CBC :
18+ print ("This feature is currently supported only in CBC ." )
2119else :
2220 m .read (lp_path )
2321
5553 best_cut = ct
5654
5755 print (
58- "Linear programming relaxation bound now: %g, improvement of %.2f "
59- % ( m2 .objective_value , perc_impr )
56+ f "Linear programming relaxation bound now: "
57+ f" { m2 .objective_value :.2f } , improvement of { perc_impr :.2f } "
6058 )
6159 else :
6260 continue
Original file line number Diff line number Diff line change @@ -448,6 +448,12 @@ def optimize(
448448
449449 check (self ._lib .Highs_run (self ._model ))
450450
451+ # check whether unsupported callbacks were set
452+ if self .model .lazy_constrs_generator :
453+ raise NotImplementedError ("HiGHS doesn't support lazy constraints at the moment" )
454+ if self .model .cuts_generator :
455+ raise NotImplementedError ("HiGHS doesn't support cuts generator at the moment" )
456+
451457 # store solution values for later access
452458 opt_status = self .get_status ()
453459 if opt_status in (
Original file line number Diff line number Diff line change 1+ import time
2+
13import numpy as np
4+
25from mip import Model , OptimizationStatus
36from mip .ndarray import LinExprTensor
4- import time
5-
67from util import skip_on
78
89
10+ @skip_on (NotImplementedError )
911def test_numpy ():
1012 model = Model ()
11- N = 1000
13+ N = 100
1214
1315 start = time .time ()
1416 x = model .add_var_tensor (shape = (N , N ), name = "x" )
You can’t perform that action at this time.
0 commit comments