Try our new documentation site (beta).


GRBModel.AddGenConstrIndicator()

Add a new general constraint of type GRB.GENCONSTR_INDICATOR to a model.

An INDICATOR constraint <span>$</span>z = f \rightarrow a^Tx \leq b<span>$</span> states that if the binary indicator variable <span>$</span>z<span>$</span> is equal to <span>$</span>f<span>$</span>, where <span>$</span>f \in \{0,1\}<span>$</span>, then the linear constraint <span>$</span>a^Tx \leq b<span>$</span> should hold. On the other hand, if <span>$</span>z = 1-f<span>$</span>, the linear constraint may be violated. The sense of the linear constraint can also be specified to be <span>$</span>=<span>$</span> or <span>$</span>\geq<span>$</span>.

Note that the indicator variable <span>$</span>z<span>$</span> of a constraint will be forced to be binary, independent of how it was created.

Multiple signatures are available.

GRBGenConstr AddGenConstrIndicator ( GRBVar binvar,
    int binval,
    GRBLinExpr expr,
    char sense,
    double rhs,
    string name )

Arguments:

binvar: The binary indicator variable.

binval: The value for the binary indicator variable that would force the linear constraint to be satisfied (<span>$</span>0<span>$</span> or <span>$</span>1<span>$</span>).

expr: Left-hand side expression for the linear constraint triggered by the indicator.

sense: Sense for the linear constraint. Options are GRB.LESS_EQUAL, GRB.EQUAL, or GRB.GREATER_EQUAL.

rhs: Right-hand side value for the linear constraint.

name: Name for the new general constraint.

Return value:

New general constraint.

GRBGenConstr AddGenConstrIndicator ( GRBVar binvar,
    int binval,
    GRBTempConstr constr,
    string name )

Arguments:

binvar: The binary indicator variable.

binval: The value for the binary indicator variable that would force the linear constraint to be satisfied (<span>$</span>0<span>$</span> or <span>$</span>1<span>$</span>).

constr: Temporary constraint object defining the linear constraint that is triggered by the indicator. The temporary constraint object is created using an overloaded comparison operator. See GRBTempConstr for more information.

name: Name for the new general constraint.

Return value:

New general constraint.


Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search

Gurobi Optimization