File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 1
1
"""This example reads a MIP (in .lp or .mps), solves its linear programming
2
2
relaxation 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
+ """
5
6
6
7
from textwrap import shorten
7
- import sys
8
8
from mip import Model , CutType , OptimizationStatus
9
9
import mip
10
10
11
- lp_path = ""
12
-
13
11
# using test data
14
12
lp_path = mip .__file__ .replace ("mip/__init__.py" , "test/data/1443_0-9.lp" ).replace (
15
13
"mip\\ __init__.py" , "test\\ data\\ 1443_0-9.lp"
16
14
)
17
15
18
16
m = 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 ." )
21
19
else :
22
20
m .read (lp_path )
23
21
55
53
best_cut = ct
56
54
57
55
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 } "
60
58
)
61
59
else :
62
60
continue
Original file line number Diff line number Diff line change @@ -448,6 +448,12 @@ def optimize(
448
448
449
449
check (self ._lib .Highs_run (self ._model ))
450
450
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
+
451
457
# store solution values for later access
452
458
opt_status = self .get_status ()
453
459
if opt_status in (
Original file line number Diff line number Diff line change
1
+ import time
2
+
1
3
import numpy as np
4
+
2
5
from mip import Model , OptimizationStatus
3
6
from mip .ndarray import LinExprTensor
4
- import time
5
-
6
7
from util import skip_on
7
8
8
9
10
+ @skip_on (NotImplementedError )
9
11
def test_numpy ():
10
12
model = Model ()
11
- N = 1000
13
+ N = 100
12
14
13
15
start = time .time ()
14
16
x = model .add_var_tensor (shape = (N , N ), name = "x" )
You can’t perform that action at this time.
0 commit comments