Try our new documentation site (beta).
Model.addVar()
addVar ( lb=0.0, ub=GRB.INFINITY, obj=0.0, vtype=GRB.CONTINUOUS, name="", column=None )
Add a decision variable to a model.
Arguments:
lb (optional): Lower bound for new variable.
ub (optional): Upper bound for new variable.
obj (optional): Objective coefficient for new variable.
vtype (optional): Variable type for new variable (GRB.CONTINUOUS, GRB.BINARY, GRB.INTEGER, GRB.SEMICONT, or GRB.SEMIINT).
name (optional): Name for new variable. Note that name will be stored as an ASCII string. Thus, a name like 'AB' will produce an error, because '' can not be represented as an ASCII character. Note also that names that contain spaces are strongly discouraged, because they can't be written to LP format files.
column (optional): Column object that indicates the set of constraints in which the new variable participates, and the associated coefficients.
Return value:
New variable object.
Example usage:
x = model.addVar() # all default arguments y = model.addVar(vtype=GRB.INTEGER, obj=1.0, name="y") # arguments by name z = model.addVar(0.0, 1.0, 1.0, GRB.BINARY, "z") # arguments by position