python-mip icon indicating copy to clipboard operation
python-mip copied to clipboard

Setup gurobi cloud could not be loaded

Open PMLP-novo opened this issue 2 years ago • 1 comments

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

PMLP-novo avatar Nov 29 '21 13:11 PMLP-novo

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.

DavidWalz avatar Aug 18 '22 08:08 DavidWalz