# GRBModel.FeasRelax()

Filter Content By
Version
Languages

### GRBModel.FeasRelax()

Modifies the GRBModel object to create a feasibility relaxation. Note that you need to call Optimize on the result to compute the actual relaxed solution.

The feasibility relaxation is a model that, when solved, minimizes the amount by which the solution violates the bounds and linear constraints of the original model. This method provides a number of options for specifying the relaxation.

If you specify relaxobjtype=0, the objective of the feasibility relaxation is to minimize the sum of the weighted magnitudes of the bound and constraint violations. The lbpen, ubpen, and rhspen arguments specify the cost per unit violation in the lower bounds, upper bounds, and linear constraints, respectively.

If you specify relaxobjtype=1, the objective of the feasibility relaxation is to minimize the weighted sum of the squares of the bound and constraint violations. The lbpen, ubpen, and rhspen arguments specify the coefficients on the squares of the lower bound, upper bound, and linear constraint violations, respectively.

If you specify relaxobjtype=2, the objective of the feasibility relaxation is to minimize the weighted count of bound and constraint violations. The lbpen, ubpen, and rhspen arguments specify the cost of violating a lower bound, upper bound, and linear constraint, respectively.

To give an example, if a constraint with rhspen value p is violated by 2.0, it would contribute 2*p to the feasibility relaxation objective for relaxobjtype=0, it would contribute 2*2*p for relaxobjtype=1, it would contribute p for relaxobjtype=2.

The minrelax argument is a boolean that controls the type of feasibility relaxation that is created. If minrelax=false, optimizing the returned model gives a solution that minimizes the cost of the violation. If minrelax=true, optimizing the returned model finds a solution that minimizes the original objective, but only from among those solutions that minimize the cost of the violation. Note that FeasRelax must solve an optimization problem to find the minimum possible relaxation when minrelax=true, which can be quite expensive.

There are two signatures for this method. The more complex one takes a list of variables and constraints, as well as penalties associated with relaxing the corresponding lower bounds, upper bounds, and constraints. If a variable or constraint is not included in one of these lists, the associated bounds or constraints may not be violated. The simpler signature takes a pair of boolean arguments, vrelax and crelax, that indicate whether variable bounds and/or constraints can be violated. If vrelax/crelax is true, then every bound/constraint is allowed to be violated, respectively, and the associated cost is 1.0.

Note that this is a destructive method: it modifies the model on which it is invoked. If you don't want to modify your original model, use the GRBModel constructor to create a copy before invoking this method.

 double FeasRelax ( int relaxobjtype, boolean minrelax, GRBVar[] vars, double[] lbpen, double[] ubpen, GRBConstr[] constrs, double[] rhspen )
Create a feasibility relaxation model.

Arguments:

relaxobjtype: The cost function used when finding the minimum cost relaxation.

minrelax: The type of feasibility relaxation to perform.

vars: Variables whose bounds are allowed to be violated.

lbpen: Penalty for violating a variable lower bound. One entry for each variable in argument vars.

ubpen: Penalty for violating a variable upper bound. One entry for each variable in argument vars.

constrs: Linear constraints that are allowed to be violated.

rhspen: Penalty for violating a linear constraint. One entry for each constraint in argument constrs.

Arguments:

Return value:

Zero if minrelax is false. If minrelax is true, the return value is the objective value for the relaxation performed. If the value is less than 0, it indicates that the method failed to create the feasibility relaxation.

 double FeasRelax ( int relaxobjtype, boolean minrelax, boolean vrelax, boolean crelax )
Simplified method for creating a feasibility relaxation model.

Arguments:

relaxobjtype: The cost function used when finding the minimum cost relaxation.

minrelax: The type of feasibility relaxation to perform.

vrelax: Indicates whether variable bounds can be relaxed (with a cost of 1.0 for any violations.

crelax: Indicates whether linear constraints can be relaxed (with a cost of 1.0 for any violations.

Return value:

Zero if minrelax is false. If minrelax is true, the return value is the objective value for the relaxation performed. If the value is less than 0, it indicates that the method failed to create the feasibility relaxation.