8000 update doc for slack models. · lambe/NLP.py@316a8ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 316a8ac

Browse files
syarradpo
authored andcommitted
update doc for slack models.
1 parent fc5b586 commit 316a8ac

File tree

2 files changed

+29
-86
lines changed

2 files changed

+29
-86
lines changed

doc/source/modeling.rst

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -127,67 +127,6 @@ The :mod:`snlp` Module
127127

128128
.. automodule:: snlp
129129

130-
131-
`SlackFramework` is a general framework for converting the :ref:`general
132-
nonlinear optimization problem <nlp>` to a form using slack variables.
133-
134-
The transformed problem is in the variables `x`, `s` and `t` and its
135-
constraints have the form
136-
137-
.. math::
138-
139-
c_i(x) - a_i = 0, & \qquad i = 1, \ldots, m, \\
140-
g_j(x) - g_j^L - s_j^L = 0, & \qquad j = 1, \ldots, p,
141-
\qquad \text{for which} \quad g_j^L > -\infty, \\
142-
s_j^L \geq 0, & \qquad j = 1, \ldots, p,
143-
\qquad \text{for which} \quad g_j^L > -\infty, \\
144-
g_j^U - g_j(x) - s_j^U = 0, & \qquad j = 1, \ldots, p,
145-
\qquad \text{for which} \quad g_j^U < +\infty, \\
146-
s_j^U \geq 0, & \qquad j = 1, \ldots, p,
147-
\qquad \text{for which} \quad g_j^U < +\infty, \\
148-
x_k - x_k^L - t_k^L = 0, & \qquad k = 1, \ldots, n,
149-
\qquad \text{for which} \quad x_k^L > -\infty, \\
150-
t_k^L \geq 0, & \qquad k = 1, \ldots, n,
151-
\qquad \text{for which} \quad x_k^L > -\infty, \\
152-
x_k^U - x_k - t_k^U = 0, & \qquad k = 1, \ldots, n,
153-
\qquad \text{for which} \quad x_k^U < +\infty, \\
154-
t_k^U \geq 0, & \qquad k = 1, \ldots, n,
155-
\qquad \text{for which} \quad x_k^U < +\infty.
156-
157-
In the latter problem, the only inequality constraints are bounds on
158-
the slack variables. The other constraints are (typically) nonlinear
159-
equalities.
160-
161-
The order of variables in the transformed problem is as follows:
162-
163-
[ x | sL | sU | tL | tU ]
164-
165-
where:
166-
167-
- sL = [ sLL | sLR ], sLL being the slack variables corresponding to
168-
general constraints with a lower bound only, and sLR being the slack
169-
variables corresponding to the 'lower' side of range constraints.
170-
171-
- sU = [ sUU | sUR ], sUU being the slack variables corresponding to
172-
general constraints with an upper bound only, and sUR being the slack
173-
variables corresponding to the 'upper' side of range constraints.
174-
175-
- tL = [ tLL | tLR ], tLL being the slack variables corresponding to
176-
variables with a lower bound only, and tLR being the slack variables
177-
corresponding to the 'lower' side of two-sided bounds.
178-
179-
- tU = [ tUU | tUR ], tUU being the slack variables corresponding to
180-
variables with an upper bound only, and tLR being the slack variables
181-
corresponding to the 'upper' side of two-sided bounds.
182-
183-
This framework initializes the slack variables sL, sU, tL, and tU to
184-
zero by default.
185-
186-
Note that the slack framework does not update all members of AmplModel,
187-
such as the index set of constraints with an upper bound, etc., but
188-
rather performs the evaluations of the constraints for the updated
189-
model implicitly.
190-
191130
.. autoclass:: SlackModel
192131
:show-inheritance:
193132
:members:

nlp/model/snlp.py

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1+
# -*- coding: utf-8 -*-
12
"""A slack framework for NLP.py."""
23

34

45
import numpy as np
56
from nlp.model.nlpmodel import NLPModel
6-
from pysparse.sparse.pysparseMatrix import PysparseMatrix as sp
77

88
__docformat__ = 'restructuredtext'
99

1010

1111
class SlackModel(NLPModel):
12-
"""
13-
General framework for converting a nonlinear optimization problem to a
12+
u"""General framework for converting a nonlinear optimization problem to a
1413
form using slack variables.
1514
16-
Original problem:
17-
cL <= c(x)
18-
c(x) <= cU
19-
cRL <= c(x) <= cRU
20-
c(x) = cE
21-
l <= x <= u
15+
Original problem::
16+
17+
cᴸ ≤ c(x)
18+
c(x) ≤ cᵁ
19+
cᴿᴸ ≤ c(x) ≤ cᴿᵁ
20+
c(x) = cᴱ
21+
l ≤ x ≤ u
22+
23+
is transformed to::
2224
23-
is transformed to:
25+
c(x) - sᴸ = 0
26+
c(x) - sᵁ = 0
27+
c(x) - sᴿ = 0
28+
c(x) - cᴱ = 0
2429
25-
c(x) - sL = 0
26-
c(x) - sU = 0
27-
c(x) - sR = 0
28-
c(x) - cE = 0
29-
cL <= sL
30-
sU <= cU
31-
cRL <= sR <= cRU
32-
l <= x <= u
30+
cᴸ ≤ sᴸ
31+
sᵁ ≤ cᵁ
32+
cᴿᴸ ≤ sᴿ ≤ cᴿᵁ
33+
l ≤ x ≤ u
3334
3435
In the latter problem, the only inequality constraints are bounds on the
3536
slack and original variables. The other constraints are (typically)
@@ -39,13 +40,13 @@ class SlackModel(NLPModel):
3940
4041
1. x, the original problem variables.
4142
42-
2. sL, the slack variables corresponding to general constraints with
43+
2. sᴸ, the slack variables corresponding to general constraints with
4344
a lower bound only.
4445
45-
3. sU, the slack variables corresponding to general constraints with
46+
3. sᵁ, the slack variables corresponding to general constraints with
4647
an upper bound only.
4748
48-
4. sR, the slack variables corresponding to general constraints with
49+
4. sᴿ, the slack variables corresponding to general constraints with
4950
a lower bound and an upper bound.
5051
5152
This framework initializes the slack variables sL and sU to
@@ -55,13 +56,16 @@ class SlackModel(NLPModel):
5556
such as the index set of constraints with an upper bound, etc., but
5657
rather performs the evaluations of the constraints for the updated
5758
model implicitly.
58-
59-
:parameters:
60-
:model: Original model to be transformed into a slack form.
61-
6259
"""
6360

6461
def __init__(self, model, **kwargs):
62+
"""Initialize a slack form of an :class:`NLPModel`.
63+
64+
:parameters:
65+
66+
:model: Original model to be transformed into a slack form.
67+
68+
"""
6569
self.model = model
6670

6771
# Save number of variables and constraints prior to transformation

0 commit comments

Comments
 (0)
0