python-mip
python-mip copied to clipboard
Setup gurobi cloud could not be loaded
Describe the bug A clear and concise description of what the bug is.
To Reproduce I'm trying to run with gurobi cloud and I have been following the linux install guide for it here: https://www.gurobi.com/documentation/9.1/quickstart_linux/software_installation_guid.html
I have run a hello world with gurobipy:
from gurobipy import *
model = Model("hello")
x = model.addVar(obj=3000, vtype="C", name="x")
y = model.addVar(obj=4000, vtype="C", name="y")
model.update()
L1 = LinExpr([5,6],[x,y])
model.addConstr(L1,">",10)
L2 = LinExpr([7,5],[x,y])
model.addConstr(L2,">",5)
model.ModelSense = 1 # minimize
model.optimize()
But when I run with python mip it does not work. I have specified my license file and gurobi home correctly
from mip import Model, xsum, maximize, BINARY, GRB
p = [10, 13, 18, 31, 7, 15]
w = [11, 15, 20, 35, 10, 33]
c, I = 47, range(len(w))
m = Model("knapsack", solver_name=GRB)
x = [m.add_var(var_type=BINARY) for i in I]
m.objective = maximize(xsum(p[i] * x[i] for i in I))
m += xsum(w[i] * x[i] for i in I) <= c
m.optimize()
selected = [i for i in I if x[i].x >= 0.99]
print("selected items: {}".format(selected))
I get: "Gurobi environment could not be loaded, check your license."
Expected behavior I expect the gurobi cloud to work after specifing the license file
Desktop (please complete the following information):
- Linux ubuntu docker
- 3.6.8
- Python-MIP version: 1.13
I hope you can help be
I cannot reproduce.
The gurobipy example you tried first can also run without license, so make that you see gurobi connecting to the cloud.
Instead of https://www.gurobi.com/documentation/9.1/quickstart_linux/software_installation_guid.html you can also simply pip-install gurobipy.