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 by starting with an empty column (using theGRBColumn constructor), and then adding terms. Terms canbe added individually, usingAddTerm,or in groups, usingAddTerms. Termscan 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 property.
Column constructor that creates an empty column.
An empty column object.
// Create empty column objectGRBColumncol=newGRBColumn();
' Create empty column objectDimcolAsGRBColumn=NewGRBColumn()
Column constructor that copies an existing column.
A copy of the input column object.
// Copy an existing columnGRBColumncol=newGRBColumn(col2);
' Copy an existing columnDimcolAsGRBColumn=NewGRBColumn(col2)
Add a single term into a column.
coeff – Coefficient for new term.
constr – Constraint for new term.
// Add a pair (2.0, constr1) to column objectcol.AddTerm(2.0,constr1);
' Add a pair (2.0, constr1) to column objectcol.AddTerm(2.0,constr1)
Add a list of terms into a column. Note that the lengths of the twoargument arrays must be equal.
coeffs – Coefficients for added constraints.
constrs – Constraints to add to column.
// Add 3 trivial linear constraints to modelGRBConstr[]constrs=model.AddConstrs(3);// Constraint coefficients for variable xdouble[]coeffs={1.0,2.0,3.0};// Create and fill GRBColumn objectGRBColumncol=newGRBColumn();col.AddTerms(coeffs,constrs);
' Add 3 trivial linear constraints to modelDimconstrsAsGRBConstr()=model.AddConstrs(3)' Constraint coefficients for variable xDimcoeffsAsDouble()=NewDouble(){1.0,2.0,3.0}' Create and fill GRBColumn objectDimcolAsGRBColumn=NewGRBColumn()col.AddTerms(coeffs,constrs)
Add new terms into a column. This signature allows you to use arrays tohold the coefficients and constraints that describe the terms in anarray without being forced to add an term for each member in the array.Thestart andlen arguments allow you to specify which terms toadd.
coeffs – Coefficients for added constraints.
constrs – Constraints to add to column.
start – The first term in the list to add.
len – The number of terms to add.
// Add 3 trivial linear constraints to modelGRBConstr[]constrs=model.AddConstrs(3);// Constraint coefficients for variable xdouble[]coeffs={1.0,2.0,3.0};// Create and fill GRBColumn object, but use only first 2 pairsGRBColumncol=newGRBColumn();col.AddTerms(coeffs,constrs,0,2);
' Add 3 trivial linear constraints to modelDimconstrsAsGRBConstr()=model.AddConstrs(3)' Constraint coefficients for variable xDimcoeffsAsDouble()=NewDouble(){1.0,2.0,3.0}' Create and fill GRBColumn object, but use only first 2 pairsDimcolAsGRBColumn=NewGRBColumn()col.AddTerms(coeffs,constrs,0,2)
Remove all terms from a column.
col.Clear();
col.Clear()
Retrieve the coefficient from a single term in the column.
Coefficient for the term at indexi in the column.
// Get the coefficient of first coefficient constraint pairdoublecoeff=col.GetCoeff(0);
' Get the coefficient of first coefficient constraint pairDimcoeffAsDouble=col.GetCoeff(0)
Retrieve the constraint object from a single term in the column.
Constraint for the term at indexi in the column.
// Get the constraint of first coefficient constraint pairGRBConstrconstr=col.GetConstr(0);
' Get the constraint of first coefficient constraint pairDimconstrAsGRBConstr=col.GetConstr(0)
Remove the term stored at indexi of the column.
i – The index of the term to be removed.
The constraint whose term was removed from the column. Returnsnull if the specified index is out of range.
// Remove first coefficient constraint paircol.Remove(0);
' Remove first coefficient constraint paircol.Remove(0)
Remove the term associated with constraintconstr from the column.
constr – The constraint whose term should be removed.
Returnstrue if the constraint appeared in the column (andwas removed).
// Remove pair associated with constr1boolremoved=col.Remove(constr1);
' Remove pair associated with constr1DimremovedAsBoolean=col.Remove(constr1)
(Property) The number of terms in the column.
ints=col.Size;
DimsAsInteger=col.Size
Help and Feedback