L02 Simplex PDF
L02 Simplex PDF
Aleksei Tepljakov 2 / 35
Solutions to a Linear Programming Problem
z = CX → max(min) z = CX → max(min)
AX 6 B or AX = B
X > 0 X > 0
(standard form) (canonical form)
Aleksei Tepljakov 3 / 35
Solutions to a Linear Programming Problem
z = CX → max(min) z = CX → max(min)
AX 6 B or AX = B
X > 0 X > 0
(standard form) (canonical form)
Aleksei Tepljakov 3 / 35
Solutions to a Linear Programming Problem
z = CX → max(min) z = CX → max(min)
AX 6 B or AX = B
X > 0 X > 0
(standard form) (canonical form)
Aleksei Tepljakov 3 / 35
Simplex Method: Introductory Example
Aleksei Tepljakov 4 / 35
Simplex Method: Initial Steps
Aleksei Tepljakov 5 / 35
Simplex Method: Initial Steps
Aleksei Tepljakov 5 / 35
Simplex Method: Initial Steps
Aleksei Tepljakov 5 / 35
Simplex Method: Initial Steps (continued)
Aleksei Tepljakov 6 / 35
Simplex Method: Initial Steps (continued)
Aleksei Tepljakov 6 / 35
Simplex Method: Initial Steps (continued)
Aleksei Tepljakov 6 / 35
Simplex Method: Initial Steps (continued)
For the given problem we introduce slack variables s1 and s2 , such that
s1 , s2 > 0, and
Aleksei Tepljakov 7 / 35
Simplex Method: Initial Steps (continued)
For the given problem we introduce slack variables s1 and s2 , such that
s1 , s2 > 0, and
z − 3x1 − 4x2 = 0
2x1 + 4x2 + s1 = 120
2x1 + 2x2 + s2 = 80.
Aleksei Tepljakov 7 / 35
Simplex Method: Initial Steps (continued)
For the given problem we introduce slack variables s1 and s2 , such that
s1 , s2 > 0, and
z − 3x1 − 4x2 = 0
2x1 + 4x2 + s1 = 120
2x1 + 2x2 + s2 = 80.
Aleksei Tepljakov 7 / 35
Simplex Method: Initial Simplex Table
x1 x2 s1 s2 z b variables
2 4 1 0 0 120 s1
2 2 0 1 0 80 s2
−3 −4 0 0 1 0 z
Aleksei Tepljakov 8 / 35
Simplex Method: Pivoting
Pivoting: To pivot a matrix about a given element, called the pivot element, is
to apply row operations, so that the pivot element is replaced by 1 and all
other entries in the same column (called pivot column) become 0.
Aleksei Tepljakov 9 / 35
Simplex Method: Pivoting
Pivoting: To pivot a matrix about a given element, called the pivot element, is
to apply row operations, so that the pivot element is replaced by 1 and all
other entries in the same column (called pivot column) become 0.
Pivot element: The pivot element for the Simplex method is found using the
following rules:
Aleksei Tepljakov 9 / 35
Simplex Method: Pivoting
Pivoting: To pivot a matrix about a given element, called the pivot element, is
to apply row operations, so that the pivot element is replaced by 1 and all
other entries in the same column (called pivot column) become 0.
Pivot element: The pivot element for the Simplex method is found using the
following rules:
• The pivot column is selected by locating the most negative entry in the
objective row. If all the entries in this column are negative, the problem is
unbounded and there is no solution.
Aleksei Tepljakov 9 / 35
Simplex Method: Pivoting
Pivoting: To pivot a matrix about a given element, called the pivot element, is
to apply row operations, so that the pivot element is replaced by 1 and all
other entries in the same column (called pivot column) become 0.
Pivot element: The pivot element for the Simplex method is found using the
following rules:
• The pivot column is selected by locating the most negative entry in the
objective row. If all the entries in this column are negative, the problem is
unbounded and there is no solution.
• Divide each entry in the last column by the corresponding entry from the
same row in the pivot column. Ignore the rows in which the pivot column
entry is less than or equal to 0. The row in which the smallest positive
ratio is obtained is the pivot row.
The pivot element is the entry at the intersection of the pivot row and the
pivot column.
Aleksei Tepljakov 9 / 35
Simplex Method: Locating the Pivot
Element
x1 x2 s1 s2 z b variables ratio
2 4 1 0 0 120 s1
2 2 0 1 0 80 s2
−3 −4 0 0 1 0 z
Aleksei Tepljakov 10 / 35
Simplex Method: Locating the Pivot
Element
x1 x2 s1 s2 z b variables ratio
2 4 1 0 0 120 s1
2 2 0 1 0 80 s2
−3 −4 0 0 1 0 z
Aleksei Tepljakov 10 / 35
Simplex Method: Locating the Pivot
Element
x1 x2 s1 s2 z b variables ratio
2 4 1 0 0 120 s1 120/4 = 30
2 2 0 1 0 80 s2 80/2 = 40
−3 −4 0 0 1 0 z
Aleksei Tepljakov 10 / 35
Simplex Method: Locating the Pivot
Element
x1 x2 s1 s2 z b variables ratio
2 4 1 0 0 120 s1 120/4 = 30
2 2 0 1 0 80 s2 80/2 = 40
−3 −4 0 0 1 0 z
Aleksei Tepljakov 10 / 35
Simplex Method: Row Operations and New
Table
We now divide R1 (the first row) by 4 and then apply the operations
R2 = R2 − 2R1 and R3 = R3 + 4R1 . The new table becomes
x1 x2 s1 s2 z b variables ratio
1 1
2
1 4
0 0 30 x2
1 0 − 12 1 0 20 s2
−1 0 1 0 1 120 z
Aleksei Tepljakov 11 / 35
Simplex Method: Row Operations and New
Table
We now divide R1 (the first row) by 4 and then apply the operations
R2 = R2 − 2R1 and R3 = R3 + 4R1 . The new table becomes
x1 x2 s1 s2 z b variables ratio
1 1
2
1 4
0 0 30 x2
1 0 − 12 1 0 20 s2
−1 0 1 0 1 120 z
• The most negative entry in the objective row is −4, hence the 1st column is
the pivot column.
Aleksei Tepljakov 11 / 35
Simplex Method: Row Operations and New
Table
We now divide R1 (the first row) by 4 and then apply the operations
R2 = R2 − 2R1 and R3 = R3 + 4R1 . The new table becomes
x1 x2 s1 s2 z b variables ratio
1 1
2
1 4
0 0 30 x2 60
1 0 − 12 1 0 20 s2 20
−1 0 1 0 1 120 z
• The most negative entry in the objective row is −4, hence the 1st column is
the pivot column.
• Compute the ratios by dividing each entry in the 6th column by the
corresponding entry in the 1st column.
Aleksei Tepljakov 11 / 35
Simplex Method: Row Operations and New
Table
We now divide R1 (the first row) by 4 and then apply the operations
R2 = R2 − 2R1 and R3 = R3 + 4R1 . The new table becomes
x1 x2 s1 s2 z b variables ratio
1 1
2
1 4
0 0 30 x2 60
1 0 − 21 1 0 20 s2 20
−1 0 1 0 1 120 z
• The most negative entry in the objective row is −4, hence the 1st column is
the pivot column.
• Compute the ratios by dividing each entry in the 6th column by the
corresponding entry in the 1st column.
• The smallest ratio is 20, so the element a21 = 1 is the pivot element.
Aleksei Tepljakov 11 / 35
Simplex Method: Row Operations and Final
Table
We apply the operations R1 = R1 − 12 R2 and R3 = R3 + R2 . The
new table becomes
x1 x2 s1 s2 z b variables
1
0 1 2 − 12 0 20 x2
1 0 − 21 1 0 20 x1
1
0 0 2 1 1 140 z
Aleksei Tepljakov 12 / 35
Simplex Method: Row Operations and Final
Table
We apply the operations R1 = R1 − 12 R2 and R3 = R3 + R2 . The
new table becomes
x1 x2 s1 s2 z b variables
1
0 1 2 − 12 0 20 x2
1 0 − 21 1 0 20 x1
1
0 0 2 1 1 140 z
Aleksei Tepljakov 12 / 35
Simplex Method: Definitions and Theorems
Aleksei Tepljakov 13 / 35
Simplex Method: Definitions and Theorems
Aleksei Tepljakov 13 / 35
Simplex Method: Definitions and Theorems
Aleksei Tepljakov 13 / 35
Simplex Method: Solving Minimum Linear
Programming Problems
Note that in general a minimum problem can be changed to a maximum
problem by realizing that in order to minimize z we must maximize −z. That
is, we multiply the objective by −1 and solve the resulting maximum problem
using the Simplex method.
Aleksei Tepljakov 14 / 35
Simplex Method: Solving Minimum Linear
Programming Problems
Note that in general a minimum problem can be changed to a maximum
problem by realizing that in order to minimize z we must maximize −z. That
is, we multiply the objective by −1 and solve the resulting maximum problem
using the Simplex method.
Consider the following linear programming problem:
Aleksei Tepljakov 14 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
3x1 − x2 + 2x3 + s1 = 7
−2x1 + 4x2 + s2 = 12
−4x1 + 3x2 + 8x3 + s3 = 10
x1 > 0, x2 > 0, x3 > 0
s1 > 0, s2 > 0, s3 > 0
Aleksei Tepljakov 15 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
3 −1 2 1 0 0 0 7 s1
−2 4 0 0 1 0 0 12 s2
−4 3 8 0 0 1 0 10 s3
1 −3 2 0 0 0 1 0 z
Aleksei Tepljakov 16 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
3 −1 2 1 0 0 0 7 s1
−2 4 0 0 1 0 0 12 s2 12/4 = 3
10
−4 3 8 0 0 1 0 10 s3 3
1 −3 2 0 0 0 1 0 z
Aleksei Tepljakov 16 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
3 −1 2 1 0 0 0 7 s1
−2 4 0 0 1 0 0 12 s2 12/4 = 3
10
−4 3 8 0 0 1 0 10 s3 3
1 −3 2 0 0 0 1 0 z
Aleksei Tepljakov 16 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
5 1
2 0 2 1 4 0 0 10 s1
− 12 1 0 0 1
4 0 0 3 x2
− 52 0 8 0 − 34 1 0 1 s3
− 12 0 2 0 3
4 0 1 9 z
Aleksei Tepljakov 17 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
5 1
2 0 2 1 4 0 0 10 s1 4
− 12 1 0 0 1
4 0 0 3 x2 ignore
− 52 0 8 0 − 34 1 0 1 s3 ignore
− 12 0 2 0 3
4 0 1 9 z
Aleksei Tepljakov 17 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables ratio
5 1
2 0 2 1 4 0 0 10 s1 4
− 12 1 0 0 1
4 0 0 3 x2 ignore
− 52 0 8 0 − 34 1 0 1 s3 ignore
− 12 0 2 0 3
4 0 1 9 z
Aleksei Tepljakov 17 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables
4 2 1
1 0 5 5 10 0 0 4 x1
2 1 3
0 1 5 5 10 0 0 5 x2
0 0 10 1 − 12 1 0 11 s3
12 1 4
0 0 5 5 5 0 1 11 z
Aleksei Tepljakov 18 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables
4 2 1
1 0 5 5 10 0 0 4 x1
2 1 3
0 1 5 5 10 0 0 5 x2
0 0 10 1 − 12 1 0 11 s3
12 1 4
0 0 5 5 5 0 1 11 z
Aleksei Tepljakov 18 / 35
Simplex Method: Solving Minimum Linear
Programming Problems (continued)
x1 x2 x3 s1 s2 s3 z′ b variables
4 2 1
1 0 5 5 10 0 0 4 x1
2 1 3
0 1 5 5 10 0 0 5 x2
0 0 10 1 − 12 1 0 11 s3
12 1 4
0 0 5 5 5 0 1 11 z
In the above table we see that there are no negative entries in the
objective row. Hence, the optimal solution is found. Therefore,
′
zmax = 11 for x1 = 4, x2 = 5, x3 = 0, s1 = 0, s2 = 0, s3 = 11. Hence,
the solution of the original problem is zmin (4, 5, 0) = −11.
Aleksei Tepljakov 18 / 35
Simplex Method: Exercise
Aleksei Tepljakov 19 / 35
Simplex Method: Summary
1. Add slack variables to change the constraints into equations and write all
variables to the left of the equal sign and constants to the right.
2. Write the objective function with all nonzero terms to the left of the equal
sign and zero to the right. The variable to be maximized must be positive.
3. Set up the initial simplex table by creating an augmented matrix from the
equations, placing the equation for the objective function last.
4. Determine a pivot element and use matrix row operations to convert the
column containing the pivot element into a unit column.
5. If negative elements still exist in the objective row, repeat Step 4. If all
elements in the objective row are positive, terminate the process.
6. When the final matrix has been obtained, determine the final basic
solution. This will give the maximum value for the objective function and
the values of the variables where this maximum occurs.
Aleksei Tepljakov 20 / 35
Simplex Method: Special Cases
Aleksei Tepljakov 21 / 35
Simplex Method: Special Cases
Aleksei Tepljakov 21 / 35
Simplex Method: Special Cases
Aleksei Tepljakov 21 / 35
Nelder-Mead Simplex Method
min F (x), x ∈ Rn .
x
Aleksei Tepljakov 22 / 35
Nelder-Mead Simplex Method: Summary
Aleksei Tepljakov 23 / 35
Nelder-Mead Simplex Method: Summary
(continued)
3 Expand. If Fr < F1 , calculate the expansion point
xe = x̄ + χ(xr − x̄), and evaluate Fe = F (xe ). If Fe < Fr , set
xn+1 = xe and terminate the iteration. Otherwise, set xn+1 = xr
and terminate the iteration.
4 Contract. If Fr > Fn , perform a contraction between x̄ and the
better of xn+1 and xr :
Aleksei Tepljakov 24 / 35
Nelder-Mead Simplex Method: Summary
(continued)
xi = x1 + σ(xi − x1 ), i = 2, . . . , n + 1,
Aleksei Tepljakov 25 / 35
Nelder-Mead Simplex Method: Examples
• Rosenbrock function
fR (x1 , x2 ) = (1 − x1 )2 + 100(x2 − x21 )2 .
Aleksei Tepljakov 26 / 35
Nelder-Mead Simplex Method: Examples
• Rosenbrock function
fR (x1 , x2 ) = (1 − x1 )2 + 100(x2 − x21 )2 .
• Himmelblau’s function
fH (x1 , x2 ) = (x21 + x2 − 11)2 + (x1 + x22 − 7)2 .
◦ f (3, 2) = 0,
◦ f (−2.805118, 3.131312) = 0,
◦ f (−3.779310, −3.283186) = 0,
◦ f (3.584428, −1.848126) = 0.
Aleksei Tepljakov 26 / 35
General Nonlinear Optimization Problem
where f , cne
i and c ni are scalar-valued functions of the variables x,
j
xL
k and x U are lower and upper scalar bounds, respectively, and
k
I ,E , and K are sets of indices.
Aleksei Tepljakov 27 / 35
Problems with Bounds and Constraints for
Unconstrained Optimization Algorithms
Aleksei Tepljakov 28 / 35
Problems with Bounds and Constraints for
Unconstrained Optimization Algorithms
Aleksei Tepljakov 28 / 35
Problems with Bounds and Constraints for
Unconstrained Optimization Algorithms
Aleksei Tepljakov 28 / 35
Problems with Bounds and Constraints:
Coordinate Transformation
• Let x denote the vector of search variables of size N × 1. For bound
constraints, a coordinate transformation may be applied to each
individual search variable. Let xL
i and x U
i denote the lower bound and
upper bound on the ith search parameter, respectively, and denote by
z the new search variable vector. Let ϕ : R → R denote a coordinate
transformation function, such that x = ϕ(z) and z = ϕ−1 (x).
Aleksei Tepljakov 29 / 35
Problems with Bounds and Constraints:
Coordinate Transformation
• Let x denote the vector of search variables of size N × 1. For bound
constraints, a coordinate transformation may be applied to each
individual search variable. Let xL
i and x U
i denote the lower bound and
upper bound on the ith search parameter, respectively, and denote by
z the new search variable vector. Let ϕ : R → R denote a coordinate
transformation function, such that x = ϕ(z) and z = ϕ−1 (x).
• For problems with lower bounds we have
xi = xL 2
i + zi ,
Aleksei Tepljakov 29 / 35
Problems with Bounds and Constraints:
Coordinate Transformation (continued)
xi = xU 2
i − zi ,
Aleksei Tepljakov 30 / 35
Problems with Bounds and Constraints:
Coordinate Transformation (continued)
L sin(zi ) +1
xi = xL
i + (xU
i − xi ) ,
2
from which it follows that xL U
i 6 xi 6 xi , since the values of the
function f (zi ) = (sin(zi ) + 1)/2 are always inside of the interval
[0, 1] and xi is therefore bounded by f (zi ) = 0 ⇒ xi = xL i ,
f (zi ) = 1 ⇒ xi = xU i . Initial estimates zi,0 are obtained from
original initial estimates xLi 6 x i,0 6 x U as
i
−2xi,0 + xL
i + xU
i
zi,0 = ℜ arcsin ,
xLi − x U
i
Aleksei Tepljakov 31 / 35
Problems with Bounds and Constraints:
Penalty Functions
To introduce constraints, a modification of the cost function
κ(·) = κ∗ ,
where κ∗ denotes the cost for the original optimization problem, is necessary.
Let us define a function fnz : R → R+ such that
(
x, x > 0
fnz (x) :=
0, x 6 0.
Aleksei Tepljakov 32 / 35
Problems with Bounds and Constraints:
Penalizing Nonlinear Equality Constraints
where
Nne M
X X ne
cne
Σ (·) = fnz (|cne
i,k (·)|),
i=1 k=1
Aleksei Tepljakov 33 / 35
Problems with Bounds and Constraints:
Penalizing Nonlinear Inequality Constraints
For general nonlinear inequality constraints of the form cni (·) 6 0, where
cni : Rq×r → RNni ×Mni , we define the following penalty function
κni : RNni ×Mni → R as
where
Nni M
X X ni
cni
Σ (·) = fnz (cni
i,k (·)).
i=1 k=1
Thus, taking both equality and inequality constraints into account, the
new cost function is
κ(·) = κ∗ + |κne {z
+ κni} .
Penalizing terms
Aleksei Tepljakov 34 / 35
Questions?
Aleksei Tepljakov 35 / 35