Adding variables to the model
The next step in our example is to add variables to the model.
# Create variables x = m.addVar(vtype=GRB.BINARY, name="x") y = m.addVar(vtype=GRB.BINARY, name="y") z = m.addVar(vtype=GRB.BINARY, name="z")
Variables are added through the
addVar() method on a model
addVars() if you wish to add more than one at a time).
A variable is always associated with a particular model.
Python allows you to pass arguments by position or by name. We've
passed them by name here. Each variable gets a type (binary), and
a name. We use the default values for the other arguments.
Please refer to the online help (
in the Gurobi Shell) for further details on