Skip to content

Commit cf67e12

Browse files
committed
use GUROBI_HOME environment variable when available
Former-commit-id: d8eef3f [formerly 0bdf9fb] Former-commit-id: 0e40596
1 parent d9382e5 commit cf67e12

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

mip/cbc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def var_get_lb(self, var: "Var") -> float:
681681
return float(lb[var.idx])
682682

683683
def var_get_ub(self, var: "Var") -> float:
684-
ub = cbclib.Cbc_getColLower(self._model)
684+
ub = cbclib.Cbc_getColUpper(self._model)
685685
if ub == ffi.NULL:
686686
raise Exception('Error while getting upper bound of variables')
687687
return float(ub[var.idx])

mip/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from enum import Enum
44

5-
VERSION = '1.3.4'
5+
VERSION = '1.3.6'
66

77
# epsilon number (practical zero)
88
EPS = 10e-6

mip/gurobi.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
from sys import maxsize
33
from typing import List, Tuple
44
from os.path import isfile
5+
import os.path
6+
from glob import glob
7+
from os import environ
58
from cffi import FFI
69
from mip.model import Model, Solver, Column, Var, LinExpr, Constr, \
710
VConstrList, VVarList
@@ -13,18 +16,27 @@
1316
found = False
1417
lib_path = None
1518

16-
for major_ver in reversed(range(6, 10)):
17-
for minor_ver in reversed(range(0, 11)):
18-
lib_path = find_library('gurobi{}{}'.format(major_ver,
19-
minor_ver))
19+
if 'GUROBI_HOME' in environ:
20+
libfile = glob(os.path.join(os.environ['GUROBI_HOME'],
21+
'lib/libgurobi*[0-9].so'))
22+
if libfile:
23+
lib_path = libfile[0]
24+
25+
if lib_path is None:
26+
for major_ver in reversed(range(6, 10)):
27+
for minor_ver in reversed(range(0, 11)):
28+
lib_path = find_library('gurobi{}{}'.format(major_ver,
29+
minor_ver))
30+
if lib_path is not None:
31+
break
2032
if lib_path is not None:
2133
break
22-
if lib_path is not None:
23-
break
2434

2535
if lib_path is None:
2636
raise Exception("""Gurobi not found. Plase check if the
27-
Gurobi dynamic loadable library if reachable
37+
Gurobi dynamic loadable library is reachable or define
38+
the environment variable GUROBI_HOME indicating the gurobi
39+
installation path.
2840
""")
2941
ffi = FFI()
3042

0 commit comments

Comments
 (0)