Slack Variables
Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The slack variable is defined by setting a lower bound of zero (>=0).
|
Inequality Constraint Form |
x > b |
|
Equality Constraint Form with Slack Variable |
x = b + slack |
In APMonitor, slack variables can be defined by starting a variable name with slk. When the model is parsed at run-time, any variable beginning with slk is automatically assigned a lower value of zero. Alternatively, inequality constraints will be automatically converted to equality constraints with a slack variable.
Example Problem
! Example model with slack variable
! Solve slack variable problem
! Minimize total_cost
! Subject to supply < b
Model
Parameters
b = 5
End Parameters
Variables
supply
total_cost
End Variables
Equations
supply < b
total_cost = (supply-2)^2
Minimize total_cost
End Equations
End Model
|
![]() |











QR Code