GRBModel::feasRelax()


GRBModel::feasRelax()

Modifies theGRBModelobject to create a feasibility relaxation. Note that you need to calloptimizeon 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 specifyrelaxobjtype=0的目的feasibility relaxation is to minimize the sum of the weighted magnitudes of the bound and constraint violations. Thelbpen,ubpen, andrhspenarguments specify the cost per unit violation in the lower bounds, upper bounds, and linear constraints, respectively.

If you specifyrelaxobjtype=1的目的feasibility relaxation is to minimize the weighted sum of the squares of the bound and constraint violations. Thelbpen,ubpen, andrhspenarguments specify the coefficients on the squares of the lower bound, upper bound, and linear constraint violations, respectively.

If you specifyrelaxobjtype=2的目的feasibility relaxation is to minimize the weighted count of bound and constraint violations. Thelbpen,ubpen, andrhspenarguments specify the cost of violating a lower bound, upper bound, and linear constraint, respectively.

To give an example, if a constraint withrhspenvaluepis violated by 2.0, it would contribute2*pto the feasibility relaxation objective forrelaxobjtype=0, it would contribute2*2*pforrelaxobjtype=1, and it would contributepforrelaxobjtype=2.

Theminrelaxargument is a boolean that controls the type of feasibility relaxation that is created. Ifminrelax=false, optimizing the returned model gives a solution that minimizes the cost of the violation. Ifminrelax=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 thatfeasRelaxmust solve an optimization problem to find the minimum possible relaxation whenminrelax=true,这将是相当昂贵的。

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,vrelaxandcrelax, that indicate whether variable bounds and/or constraints can be violated. Ifvrelax/crelaxistrue, 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 theGRBModel constructorto create a copy before invoking this method.

double feasRelax( int relaxobjtype,
bool minrelax,
int vlen,
const GRBVar* vars,
const double* lbpen,
const double* ubpen,
int clen,
const GRBConstr* constrs,
const 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.

    vlen: The length of the list of variables whose bounds are allowed to be violated.

    vars: Variables whose bounds are allowed to be violated.

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

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

    clen: The length of the list of linear constraints that are allowed to be violated.

    constrs: Linear constraints that are allowed to be violated.

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

    Return value:

    Zero ifminrelaxis false. Ifminrelaxis 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,
bool minrelax,
bool vrelax,
bool 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 ifminrelaxis false. Ifminrelaxis 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.