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

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

double Get(GRB.DoubleAttr attr)#

Query the value of a double-valued attribute.

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

int Get(GRB.IntAttr attr)#

Query the value of an int-valued attribute.

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

string Get(GRB.StringAttr attr)#

Query the value of a string-valued attribute.

Parameters:

attr – The attribute being queried.

Returns:

The current value of the requested attribute.

int Index#

This property 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.

Returns:

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

bool SameAs(GRBConstr constr2)#

Check whether two constraint objects refer to the same constraint.

Parameters:

constr2 – The other constraint.

Returns:

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

void Set(GRB.CharAttr attr, char newvalue)#

Set the value of a char-valued attribute.

Parameters:
  • attr – The attribute being modified.

  • newvalue – The desired new value of the attribute.

void Set(GRB.DoubleAttr attr, double newvalue)#

Set the value of a double-valued attribute.

Parameters:
  • attr – The attribute being modified.

  • newvalue – The desired new value of the attribute.

void Set(GRB.IntAttr attr, int newvalue)#

Set the value of an int-valued attribute.

Parameters:
  • attr – The attribute being modified.

  • newvalue – The desired new value of the attribute.

void Set(GRB.StringAttr attr, string newvalue)#

Set the value of a string-valued attribute.

Parameters:
  • attr – The attribute being modified.

  • newvalue – The desired new value of the attribute.