## Main.SlackVariables History

Deleted lines 4-5:
!! Slack Variables
Changed lines 29-30 from:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Click to Solve a Slack Variable Optimization Problem]]
to:
{\begin{align}\min \quad & cost_{total}\\\mathrm{subject\;to} \quad & supply<b\\& cost_{total}=(supply-2)^2\end{align}}

'''Gekko (Python) Solution'''

(:source lang=python:)
# Solve slack variable problem
#  Minimize  total_cost
#  Subject to supply < b
from gekko import GEKKO

b = 5
m = GEKKO(remote=False)
supply = m.Var()
total_cost = m.Var()

m.Equation(supply<b)
m.Equation(total_cost==(supply-2)**2)
m.Minimize(total_cost)

m.solve()

print(supply.value[0])
print(total_cost.value[0])
(:sourceend:)

'''APMonitor Solution'''

Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Click to Solve Slack Variable Optimization Problem Online]]

Changed lines 62-72 from:
!!! Inequality Constraints in APM

In APMonitor Modeling Language, inequality constraints are automatically translated into equality constraints with slack variables. Slack
variables can also 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.

!!! Logical Conditions in Optimization

Slack variables are also useful for optimization problems with non-smooth or discontinuous functions. The following tutorial demonstrates the use of slack variables in reformulating the ABS() function, IF statements, and others.

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/NPUNixLGlh0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
to:
----

!!! Inequality Constraints

In [[https://gekko.readthedocs.io/en/latest/|Gekko Optimization Suite]] and the [[https://apmonitor.com/wiki/|APMonitor Modeling Language]], inequality constraints are automatically translated into equality constraints with slack
variables. In APMonitor, slack variables can also 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 are automatically converted to equality constraints with a slack variable.
April 14, 2017, at 08:26 PM by 10.5.113.121 -
Deleted lines 36-37:
----
Changed lines 39-47 from:
In APMonitor Modeling Language, inequality constraints are automatically translated into equality constraints with slack variables. Slack variables can also 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.
to:
In APMonitor Modeling Language, inequality constraints are automatically translated into equality constraints with slack variables. Slack variables can also 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.

!!! Logical Conditions in Optimization

Slack variables are also useful for optimization problems with non-smooth or discontinuous functions. The following tutorial demonstrates the use of slack variables in reformulating the ABS() function, IF statements, and others.

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/NPUNixLGlh0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
June 18, 2013, at 06:04 AM by 69.169.131.173 -
Changed line 21 from:
(:html:)<br><br><br>(:htmlend:)
to:
----
June 18, 2013, at 06:04 AM by 69.169.131.173 -
Added lines 21-22:
(:html:)<br><br><br>(:htmlend:)
Deleted line 23:
<br><br>
June 18, 2013, at 06:03 AM by 69.169.131.173 -
Changed line 22 from:
<br>
to:
<br><br>
June 18, 2013, at 06:03 AM by 69.169.131.173 -
Added line 22:
<br>
June 18, 2013, at 06:02 AM by 69.169.131.173 -
Changed line 9 from:
(:table border=1 width=80% align=left bgcolor=#FFFFFF cellspacing=0:)
to:
(:table border=1 width=100% align=left bgcolor=#FFFFFF cellspacing=0:)
Deleted lines 20-21:
(:html:)<br><br><br><br><br>(:htmlend:)
Changed lines 31-55 from:
(:table border=1 width=100% align=left bgcolor=#EEEEEE cellspacing=0:)
(:cellnr:)
! 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
(:cellnr:)
to:
Attach:slack_problem.png
Deleted line 33:
(:tableend:)
June 18, 2013, at 05:58 AM by 69.169.131.173 -
Changed lines 27-28 from:
!! Example Problem
to:
----

!
!! Example Problem
Changed lines 61-63 from:
!! Inequality Constraints in APM
to:
----

!
!! Inequality Constraints in APM
June 18, 2013, at 05:58 AM by 69.169.131.173 -
Changed line 31 from:
(:table border=1 width=50% align=left bgcolor=#EEEEEE cellspacing=0:)
to:
(:table border=1 width=100% align=left bgcolor=#EEEEEE cellspacing=0:)
Deleted lines 57-58:

(:html:)<br>(:htmlend:)
June 18, 2013, at 05:57 AM by 69.169.131.173 -
Added lines 58-59:

(:html:)<br>(:htmlend:)
June 18, 2013, at 05:56 AM by 69.169.131.173 -
Changed lines 27-28 from:
!!! Example Problem
to:
!! Example Problem
Changed line 59 from:
----
to:
!! Inequality Constraints in APM
June 18, 2013, at 05:55 AM by 69.169.131.173 -
Added lines 58-59:

----
June 18, 2013, at 05:54 AM by 69.169.131.173 -
Deleted lines 22-23:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Click to Solve a Slack Variable Optimization Problem]]
Deleted lines 26-27:
In APMonitor, inequality constraints are automatically translated into equality constraints with slack variables. Slack variables can also 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.
Added lines 29-30:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Click to Solve a Slack Variable Optimization Problem]]
Changed lines 57-59 from:
(:tableend:)
to:
(:tableend:)

In APMonitor Modeling Language, inequality constraints are automatically translated into equality constraints with slack variables. Slack variables can also 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.
June 18, 2013, at 05:52 AM by 69.169.131.173 -
Changed lines 7-8 from:
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).
to:
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).
Changed line 18 from:
slack >= 0
to:
slack > 0
June 16, 2013, at 11:34 PM by 69.169.188.188 -
Changed lines 25-26 from:
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.
to:
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/jh6BK0BqqIs?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

In APMonitor, inequality constraints are automatically translated into equality constraints with slack variables. Slack variables can also
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.
Changed line 59 from:
(:tableend:)
to:
(:tableend:)
March 16, 2012, at 09:27 PM by 69.169.136.170 -
Changed line 23 from:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Solve Slack Variable Optimization Problems]]
to:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Click to Solve a Slack Variable Optimization Problem]]
March 16, 2012, at 09:26 PM by 69.169.136.170 -
Added lines 1-4:
(:title Slack Variable Tutorial:)
(:keywords slack variables, inequality, slacks, lower bound, transform:)
(:description Slack variables are used to transform an inequality expression into an equality expression:)

Deleted line 55:
January 14, 2012, at 11:30 PM by 69.169.188.228 -
Changed lines 19-20 from:
to:
Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Solve Slack Variable Optimization Problems]]
Deleted lines 21-26:

!!! Solve Slack Variable Problems Online

%blue%A%red%P%black%Monitor has an online interface for solving optimization problems.  The optimization problem shown below as '''Example Problem''' can be solved through the web-interface at the following link:

Attach:table50.jpg [[https://apmonitor.com/online/view_pass.php?f=slack.apm | Slack Variable Solution Online]]
January 14, 2012, at 11:26 PM by 69.169.188.228 -
Changed line 13 from:
x = b + slack
to:
x = b + slack (:html:)<br>(:htmlend:)
January 14, 2012, at 11:24 PM by 69.169.188.228 -
Changed line 13 from:
x = b + slack,
to:
x = b + slack
January 14, 2012, at 11:23 PM by 69.169.188.228 -
Changed line 13 from:
x = b + slack
to:
x = b + slack,
January 14, 2012, at 11:23 PM by 69.169.188.228 -
Changed line 5 from:
(:table border=2 width=50% align=left bgcolor=#FFFFFF cellspacing=0:)
to:
(:table border=1 width=80% align=left bgcolor=#FFFFFF cellspacing=0:)
January 14, 2012, at 11:20 PM by 69.169.188.228 -
Changed line 20 from:
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.
to:
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.
January 14, 2012, at 11:20 PM by 69.169.188.228 -
Changed line 20 from:
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.
to:
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.
January 14, 2012, at 11:19 PM by 69.169.188.228 -
Changed line 17 from:
(:html:)<br><br><br><br><br><br>(:htmlend:)
to:
(:html:)<br><br><br><br><br>(:htmlend:)
January 14, 2012, at 11:19 PM by 69.169.188.228 -
Changed line 17 from:
(:html:)<br><br><br><br>(:htmlend:)
to:
(:html:)<br><br><br><br><br><br>(:htmlend:)
January 14, 2012, at 11:18 PM by 69.169.188.228 -
Changed line 17 from:
(:html:)<br>(:htmlend:)
to:
(:html:)<br><br><br><br>(:htmlend:)
January 14, 2012, at 11:18 PM by 69.169.188.228 -
Changed line 5 from:
(:table border=1 width=50% align=left bgcolor=#FFFFFF cellspacing=0:)
to:
(:table border=2 width=50% align=left bgcolor=#FFFFFF cellspacing=0:)
January 14, 2012, at 11:18 PM by 69.169.188.228 -
Changed line 5 from:
(:table border=1 width=50% align=left bgcolor=#EEEEEE cellspacing=0:)
to:
(:table border=1 width=50% align=left bgcolor=#FFFFFF cellspacing=0:)
Added lines 16-18:

(:html:)<br>(:htmlend:)

January 14, 2012, at 11:16 PM by 69.169.188.228 -
Changed lines 5-7 from:
Slack variables are defined by starting a variable name with ''''slk''''.  Thus, valid slack variable names would include names such as ''slk_1'', ''slkr'', ''slkvar[1]''.  When the model is parsed at run-time, any variable beginning with ''slk'' is automatically assigned a lower value of zero.

Equation inequalities are automatically tranformed to equality expressions for solvers that do not support them
.
to:
(:table border=1 width=50% align=left bgcolor=#EEEEEE cellspacing=0:)
(:cellnr:)
Inequality Constraint Form
(:cell:)
x > b
(:cellnr:)
Equality Constraint Form with Slack Variable
(:cell:)
x = b + slack
slack >= 0
(:tableend:)

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.