.NET API - GRBColumn#

GRBColumn#

Gurobi column object. A column consists of a list of coefficient, constraint pairs. Columns are used to represent the set of constraints in which a variable participates, and the associated coefficients. They are temporary objects that typically have short lifespans.

You generally build columns by starting with an empty column (using the GRBColumn constructor), and then adding terms. Terms can be added individually, using AddTerm, or in groups, using AddTerms. Terms can also be removed from a column, using Remove.

Individual terms in a column can be queried using the GetConstr, and GetCoeff methods. You can query the number of terms in the column using the Size property.

GRBColumn GRBColumn()#

Column constructor that creates an empty column.

Returns:

An empty column object.

GRBColumn GRBColumn(GRBColumn orig)#

Column constructor that copies an existing column.

Returns:

A copy of the input column object.

void AddTerm(double coeff, GRBConstr constr)#

Add a single term into a column.

Parameters:
  • coeff – Coefficient for new term.

  • constr – Constraint for new term.

void AddTerms(double[] coeffs, GRBConstr[] constrs)#

Add a list of terms into a column. Note that the lengths of the two argument arrays must be equal.

Parameters:
  • coeffs – Coefficients for added constraints.

  • constrs – Constraints to add to column.

void AddTerms(double[] coeffs, GRBConstr[] constrs, int start, int len)#

Add new terms into a column. This signature allows you to use arrays to hold the coefficients and constraints that describe the terms in an array without being forced to add an term for each member in the array. The start and len arguments allow you to specify which terms to add.

Parameters:
  • 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.

void Clear()#

Remove all terms from a column.

double GetCoeff(int i)#

Retrieve the coefficient from a single term in the column.

Returns:

Coefficient for the term at index i in the column.

GRBConstr GetConstr(int i)#

Retrieve the constraint object from a single term in the column.

Returns:

Constraint for the term at index i in the column.

GRBConstr Remove(int i)#

Remove the term stored at index i of the column.

Parameters:

i – The index of the term to be removed.

Returns:

The constraint whose term was removed from the column. Returns null if the specified index is out of range.

boolean Remove(GRBConstr constr)#

Remove the term associated with constraint constr from the column.

Parameters:

constr – The constraint whose term should be removed.

Returns:

Returns true if the constraint appeared in the column (and was removed).

int Size#

(Property) The number of terms in the column.