Concepts
Features
Reference
Gurobi column object. A column consists of a list of coefficient,constraint pairs. Columns are used to represent the set of constraintsin which a variable participates, and the associated coefficients. Theyare temporary objects that typically have short lifespans.
You generally build columns using theColumn constructor.Terms can be added to an existing column usingaddTerms.Terms can also be removed from a column usingremove.
Individual terms in a column can be queried using thegetConstr, andgetCoeff methods. You can query thenumber of terms in the column using thesize method.
Column constructor.
coeffs – (optional) Lists the coefficients associated with themembers ofconstrs.
constrs – (optional) Constraint or constraints that participate inexpression. Ifconstrs is a list, thencoeffs must contain alist of the same length. Ifconstrs is a single constraint, thencoeffs must be a scalar.
An expression object.
constrs=model.getConstrs()c=Column()c.addTerms(3.0,constrs[0])model.addVar(vtype=GRB.BINARY,obj=1.0,column=c)model.addVar(vtype=GRB.INTEGER,column=Column(3.0,constrs[0]))model.addVar(obj=3.0,column=Column([1.0,2.0],constrs[1:3]))
Add new terms into a column.
coeffs – Coefficients for added constraints; either a list ofcoefficients or a single coefficient. The two arguments must have thesame size.
constrs – Constraints to add to column; either a list ofconstraints or a single constraint. The two arguments must have the samesize.
col.addTerms(1.0,x)col.addTerms([2.0,3.0],[y,z])
Remove all terms from a column.
col.clear()
Copy a column.
Copy of input column.
col0=Column(1.0,c0)col1=col0.copy()
Retrieve the coefficient from a single term in the column.
Coefficient for the term at indexi in the column.
col=Column([1.0,2.0],[c0,c1])print(col.getCoeff(1))
Retrieve the constraint object from a single term in the column.
Constraint for the term at indexi in the column.
col=Column([1.0,2.0],[c0,c1])print(col.getConstr(1))
Remove a term from a column.
item – Ifitem is an integer, then the term stored at indexitem of the column is removed. Ifitem is a Constr, then allterms that involveitem are removed.
col=Column([1.0,2.0],[c0,c1])col.remove(c0)
Retrieve the number of terms in the column.
Number of terms in the column.
print(Column([1.0,2.0],[c0,c1]).size())
Help and Feedback