Constraint Transformation
OPTIMake supports softening, deactivation, and hardening operations on constraints to meet different requirements:
- Constraint softening specifies constraints as soft constraints at modeling time, to reduce memory usage and computation time
- Constraint deactivation and hardening dynamically adjust constraint validity and soft/hard properties at solve time
Constraint Softening
OPTIMake has built-in support for constraint softening, which can reduce memory usage and computation time through this interface.
Constraint softening can be divided into softening of equality constraints and softening of inequality constraints. OPTIMake provides constraint softening support in the following interfaces:
variable(variable upper and lower bounds, inequality constraint)inequality(inequality constraint)equality(equality constraint)start_equality(equality constraint)end_equality(equality constraint)
The supported softening penalty types are:
'quadratic''l1'
The problem definition sections above introduced how to use these interfaces to soften constraints. We use the following general problem formulation to introduce the constraint softening problem setup in OPTIMake. Note that in the following, represents slack variables rather than parameters.
Equality Constraint Softening
When the softening penalty type is 'quadratic', the softened problem is defined as follows ( is the penalty weight, is the slack variable for constraint softening):
When the softening penalty type is 'l1', the softened problem is defined as follows ( is the penalty weight, are the slack variables for constraint softening):
Inequality Constraint Softening
When the softening penalty type is 'quadratic', the softened problem is defined as follows ( is the penalty weight, is the slack variable for constraint softening):
When the softening penalty type is 'l1', the softened problem is defined as follows ( is the penalty weight, is the slack variable for constraint softening):
Constraint Deactivation
When certain constraints are defined during modeling but you want to deactivate them at solve time so they do not affect the solution, OPTIMake supports the following types of constraint deactivation:
- Hard upper/lower bounds on variables: By setting the lower bound to -inf or the upper bound to inf
- Soft upper/lower bounds on variables: By setting the penalty weight to 0.0
- Hard inequality constraint : By setting the initial guess value to inf through parameters (always greater than 0)
- Soft inequality constraint : By setting the penalty weight to 0.0, or by setting the initial guess value to inf through parameters (always greater than 0)
For example, for the following inequality constraint:
# -bd <= x + y <= bd
xy_bd = prob.parameter('xy_bd', stage_dependent=False)
ineq = general_inequality(
expr = [x + y, x + y],
sign = ['>=', '<='],
bound = [-xy_bd, xy_bd])
prob.inequality(ineq)
When you want to deactivate this inequality constraint, you can set the parameter before solving as follows:
// HUGE_VAL is infinity in C
// In C++, you can use std::numeric_limits<double>::infinity()
prob.param[PARAM_XY_BD] = HUGE_VAL;
OPTIMake currently does not support deactivation of equality constraints and second-order cone constraints.
Soft Constraint Hardening
When constraints are specified as soft constraints during modeling but you want to harden them at solve time to make them hard constraints, OPTIMake supports the following types of soft constraint hardening:
- Soft upper/lower bounds on variables: By setting the penalty weight to inf, the soft bound will be combined with the hard bound to form a new hard bound (i.e., the stricter of the two is used)
- Soft inequality constraint : By setting the penalty weight to inf
- Soft equality constraint : By setting the penalty weight to inf