Java API - GRBConstr#

GRBConstr#

Gurobi constraint object. Constraints are always associated with a particular model. You create a constraint object by adding a constraint to a model (using GRBModel.addConstr), rather than by using a GRBConstr constructor.

The methods on constraint objects are used to get and set constraint attributes. For example, constraint right-hand sides can be queried by calling get (GRB.DoubleAttr.RHS). Note, however, that it is generally more efficient to query attributes for a set of constraints at once. This is done using the attribute query method on the GRBModel object (GRBModel.get).

char get(GRB.CharAttr attr)#

Query the value of a char-valued attribute.

Arguments:

attr – The attribute being queried.

Return value:

The current value of the requested attribute.

double get(GRB.DoubleAttr attr)#

Query the value of a double-valued attribute.

Arguments:

attr – The attribute being queried.

Return value:

The current value of the requested attribute.

int get(GRB.IntAttr attr)#

Query the value of an int-valued attribute.

Arguments:

attr – The attribute being queried.

Return value:

The current value of the requested attribute.

String get(GRB.StringAttr attr)#

Query the value of a string-valued attribute.

Arguments:

attr – The attribute being queried.

Return value:

The current value of the requested attribute.

int index()#

This method returns the current index, or order, of the constraint in the underlying constraint matrix.

Note that the index of a constraint may change after subsequent model modifications.

Return value:

-2: removed, -1: not in model, otherwise: index of the constraint in the model

boolean sameAs(GRBConstr otherConstr)#

Check whether two constraint objects refer to the same constraint.

Arguments:

otherConstr – The other constraint.

Return value:

Boolean result indicates whether the two constraint objects refer to the same model constraint.

void set(GRB.CharAttr attr, char newval)#

Set the value of a char-valued attribute.

Arguments:
  • attr – The attribute being modified.

  • newval – The desired new value of the attribute.

void set(GRB.DoubleAttr attr, double newval)#

Set the value of a double-valued attribute.

Arguments:
  • attr – The attribute being modified.

  • newval – The desired new value of the attribute.

void set(GRB.IntAttr attr, int newval)#

Set the value of an int-valued attribute.

Arguments:
  • attr – The attribute being modified.

  • newval – The desired new value of the attribute.

void set(GRB.StringAttr attr, String newval)#

Set the value of a string-valued attribute.

Arguments:
  • attr – The attribute being modified.

  • newval – The desired new value of the attribute.