C++ API - GRBColumn#

class 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. Create an empty column.

Returns:

An empty 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(const double *coeffs, const GRBConstr *constrs, int count)#

Add a list of terms into a column.

Parameters:
  • coeffs – Coefficients for new terms.

  • constrs – Constraints for new terms.

  • count – Number of terms to add to the column.

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.

void remove(int i)#

Remove the term stored at index i of the column.

Parameters:

i – The index of the term to be removed.

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).

unsigned int size()#

Retrieve the number of terms in the column.

Returns:

Number of terms in the column.