Java 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 method.

GRBColumn GRBColumn()#

Column constructor that creates an empty column.

Return value:

An empty column object.

GRBColumn GRBColumn(GRBColumn col)#

Column constructor that copies an existing column.

Arguments:

col – Existing column object.

Return value:

A copy of the input column object.

void addTerm(double coeff, GRBConstr constr)#

Add a single term into a column.

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

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

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

Arguments:

i – Index for coefficient of interest.

Return value:

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.

Arguments:

i – Index for term of interest.

Return value:

Constraint for the term at index i in the column.

void remove(int i)#

Remove the term stored at index i of the column.

Arguments:

i – The index of the term to be removed.

boolean remove(GRBConstr constr)#

Remove the term associated with constraint constr from the column.

Arguments:

constr – The constraint whose term should be removed.

Return value:

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

int size()#

Retrieve the number of terms in the column.

Return value:

Number of terms in the column.