Model.feasRelaxS()


Model.feasRelaxS()

feasRelaxS( relaxobjtype, minrelax, vrelax, crelax )

Modifies theModelobject to create a feasibility relaxation. Note that you need to calloptimizeon the result to compute the actual relaxed solution. Note also that this is a simplified version of this method - usefeasRelaxfor more control over the relaxation performed.

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, the objective of the feasibility relaxation is to minimize the sum of the magnitudes of the bound and constraint violations.

If you specifyrelaxobjtype=1, the objective of the feasibility relaxation is to minimize the sum of the squares of the bound and constraint violations.

If you specifyrelaxobjtype=2, the objective of the feasibility relaxation is to minimize the total number of bound and constraint violations.

To give an example, if a constraint is violated by 2.0, it would contribute2.0to the feasibility relaxation objective forrelaxobjtype=0, it would contribute2.0*2.0forrelaxobjtype=1, and it would contribute1.0forrelaxobjtype=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 thatfeasRelaxSmust solve an optimization problem to find the minimum possible relaxation whenminrelax=True,这将是相当昂贵的。

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, usecopyto create a copy before invoking this method.

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.

crelax: Indicates whether constraints can be relaxed.

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.

Example usage:

if model.status == GRB.INFEASIBLE: model.feasRelaxS(1, False, False, True) model.optimize()