Error when assigning binary variable type ('GRB' is not defined)
AnsweredHi,
I'm encountering what I think is a very simple error but haven't figured out how to fix it. When assigning binary variable type to my model in Python, I keep getting the error that 'GRB' is not defined:
xij = m.addMVar(nx, vtype=GRB.BINARY)
returns
name 'GRB' is not defined
What am I missing? I updated to the latest Gurobi version and checked it is correctly installed.
Thanks!
1
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Nicolas,
This is probably a problem with the import of the Gurobi Python module. In our examples we do the following:
import gurobipy as gp
from gurobipy import GRBIf these lines are present before you actually want to use something from our Python module (so normally, you would add them in the beginning of your file), your code should work fine. Please also see our mip1.py example.
Best,
Sonja
1
Post is closed for comments.
Comments
2 comments