Try our new documentation site (beta).
GRBfeasrelax
int | GRBfeasrelax ( | GRBmodel | *model, |
int | relaxobjtype, | ||
int | minrelax, | ||
double | *lbpen, | ||
double | *ubpen, | ||
double | *rhspen, | ||
double | *feasobjP ) |
Modifies the input model to create a feasibility relaxation. Note that you need to call GRBoptimize 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 routine 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, a violation of 2.0 on constraint i
would contribute 2*rhspen[i]
to the feasibility relaxation
objective for relaxobjtype=0
, it would contribute
2*2*rhspen[i]
for relaxobjtype=1
, and
it would contribute rhspen[i]
for relaxobjtype=2
.
The minrelax
argument is a boolean that controls the type of
feasibility relaxation that is created. If minrelax=0
, optimizing
the returned model gives a solution that minimizes the cost of the
violation. If minrelax=1
, 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 GRBfeasrelax
must solve an optimization problem to
find the minimum possible relaxation for minrelax=1
, which can
be quite expensive.
In all cases, you can specify a penalty of GRB_INFINITY
to
indicate that a specific bound or linear constraint may not be violated.
Note that this is a destructive routine: it modifies the model passed to it. If you don't want to modify your original model, use GRBcopymodel to create a copy before calling this routine.
Return value:
A non-zero return value indicates that a problem occurred while computing the feasibility relaxation. Refer to the Error Code table for a list of possible return values. Details on the error can be obtained by calling GRBgeterrormsg.
Arguments:
model: The original (infeasible) model. The model is modified by this routine.
relaxobjtype: The cost function used when finding the minimum cost relaxation.
minrelax: The type of feasibility relaxation to perform.
lbpen: The penalty associated with violating a lower bound. Can be NULL, in which case no lower bound violations are allowed.
ubpen: The penalty associated with violating an upper bound. Can be NULL, in which case no upper bound violations are allowed.
rhspen: The penalty associated with violating a linear constraint. Can be NULL, in which case no constraint violations are allowed.
feasobjP: When minrelax=1, this returns the objective value for the minimum cost relaxation.
Example usage:
double penalties[]; error = GRBfeasrelax(model, 0, 0, NULL, NULL, penalties, NULL); error = GRBoptimize(model);