Chapter 3
Chapter 3
Chapter 3
Primal method for solving a linear program
1 Problem position
The primal problem of semi-definite programming in standard form is written
min(C; Xi )
(LPP) AX = b
X ∈ Sn+
1
S Delenda
Chapter 3
Primal method for solving a linear program
{x ∈ Rn ; Ax ≤ b; x ≥ 0}
is called the feasible region of (LP). A point x in the feasible region is called
a feasible solution. An LP is said to be feasible if the feasible region is not
empty, and infeasible otherwise.
Example In the above example, the feasible region is the triangle whose
vertices are (0,0), (0,1) and (1,0). Consider the linear program:
max x1 + x2
s:t: x1 + x2 ≤ −1
x1 ; x2 ≥ 0
The constraints are requesting that x1 , x2 are non-negative, but also below
the line x1 + x2 = −1 figure (1), this LP is thus infeasible.
2
S Delenda
Chapter 3
Primal method for solving a linear program
3
S Delenda
Chapter 3
Primal method for solving a linear program
δZ = Z(x) − Z(x)
= c T x − cT x
= cT (x − x)
= cT δx.
We have x and x feasible solutions:
A.x = b....(1)
A.x = b.....(2)
xisabasicf easiblesolution
=⇒x is a solution to problem (LPP).
EN ≤ 0
The inequality EN ≤ 0 is necessary for the optimality of the feasible basic
solution x if it is not degenerate i.e. If x is a non-degenerate optimal solution,
then EN ≤ 0
4
S Delenda
Chapter 3
Primal method for solving a linear program
Maximize z =A +2B
Subject to A ≤ 10
2A + B ≥ 5
A, B ≥ 0
5
S Delenda
Chapter 3
Primal method for solving a linear program
them in such a way that the new solution gives a greater value of the objec-
tive function.
Reasoning about the number of optimal solutions:
— If the domain is empty, then no optimal solution.
— If the domain is non-empty, bounded: 1 or an infinity of solutions optimal
(give graphic illustration).
— If the domain is non-empty, not bounded: 0 or 1 or an infinity of optimal
solutions or infinite solution.
A resolution algorithm could then be interested in the vertices of the poly-
hedron uniquely. This is what the simplex algorithm does to find out if we
can improve our initial basic feasible solution.
max x1 + x2
s:t: x1 + 3x2 ≤ 9
2x1 + x2 ≥ 8
x1 ; x2 ≥ 0
We can rewrite it as
max x1 + x2
s:t: x1 + 3x2 + s1 = 9
2x1 + x2 − s2 = 8
x1 ; x2 ; s1 ; s2 ≥ 0
and s1 ; s2 are slack variables. Indeed, 2x1 + x2 − s2 = 8 ⇐⇒ 2x1 + x2 =
8+s2 ≥ 8 for s2 ≥ 0, and similarly x1 +3x2 +s1 = 9 ⇐⇒ x1 +3x2 = 9−s1 ≤ 9
for s1 ≥ 0.
With these slack variables, we now write our problem in matrix form:
6
S Delenda
Chapter 3
Primal method for solving a linear program
maximize cT x
subject to Ax = b
x ≥ 0,
where
a11 a12 ... a1n 1 0 ... 0
a21 a22 ... a2n 1
: : : : : : :
: : : : : : :
am1 am2 ... amn 0 ... 0 1
c1 x1
c2 x2
b1
: :
b2
: :
b= : , C = ; and x =
cn xm
:
O x1+n
bm
: :
0 xn+m
We wish to introduce a notation for matrices that will allow us to break up the
matrix product Ax analogously. To this end, let B denote an m × m matrix
whose columns consist precisely of the m columns of A that are associated
with the basic variables. Similarly, let N denote an m x n matrix whose
columns are the n nonbasic columns of A. Then we write A in a partitioned-
matrix form as follows:
A=[B N]
7
S Delenda
Chapter 3
Primal method for solving a linear program
maximiserZ = 3x + 5y + 6w
x + 2y + 4w ≤ 70
2x + y + w ≤ 80
3x + 2y + 2w ≤ 60
(x, y, w) ≥ 0
If we put
1 2 4 x 70 3
A+ 2 1 1 , x= y ,b= 80 ,c= 5 ,
3 2 2 w 60 4
x 3
y 5
1 2 4 1 0 0
w
4
A = 2 1 1 0 1 0 ,x =
e1 ,c = 0
3 2 2 0 0 1
e2
0
e3 0
the program is written in the following canonical and standard matrix forms:
Ax ≤ b, x ≥ 0 Ax = b, x ≥ 0
T =⇒
maximiserZ = c x maximiserZ = cT x
8
S Delenda
Chapter 3
Primal method for solving a linear program
9
S Delenda
Chapter 3
Primal method for solving a linear program
Maximize P = 2x1 + x2
Subject to: x1 + x2 ≤ 5
−2x1 + 3x2 ≤ 6
2x1 − 3x2 ≤ 6
x1 , x2 ≥ 0
M aximize P = 2x1 + x2
Subject to: x1 + x2 + s1 = 5
10
S Delenda
Chapter 3
Primal method for solving a linear program
-2x1 + 3x2 + s2 = 6
2x1 − 3x2 + s3 = 6
x1 , x2 , s1 , s2 , s3 ≥ 0
The Initial Table The first table of the simplex will be constructed as
follows(figure 6):
Pn
maxz
Pn = j=1 cj Xj
s.c. j=1 aij xj ≤ bi i = 1...m
xj ≥ 0withj = 1...n
then
11
S Delenda
Chapter 3
Primal method for solving a linear program
= nj=1 cj xj
P
Pminz
s.c. nj=1 aij xj ≥ bi i = 1...m
xj ≥ 0j = 1...n
the standard form of the linear program satisfies these two properties.
- Among the variables of the standard problem, there are m variables which
appear with a non-zero coefficient in each constraint (in our example: x3 , x4 , x5 , x6
and x7 ). The values of the right hand side of the constraints (the components
of vector b) are positive.
Then a basic feasible solution is obtained by canceling the (n-m) decision
variables and the value of the deviation variables is directly given by the
right hand side.
- The second property ensures the satisfaction of the non-negativity con-
straints of the deviation variables.
Example
Let’s write the model in its standard form; we must add a deviation variable
in the type constraints≤ and subtract a deviation variable in the type con-
straints
≥. (figure(7).
M inZ = 3x1 + 4x2
S.C : 5x1 + 5x2 ≤ 60
x1 + 3x2 ≥ 12
x1 + 2x2 ≥ 2
x1 ≥ 6
x 2 ≤ 8
x1 , x2 ≥ 0
then
we have the standard form:
M inZ = 3x1 + 4x2 + 0x3 + 0x4 + 0x5 + 0x6 + 0x7
S.C : 5x1 + 5x2 + x3 = 60
x1 + 3x2 − x4 = 12
x1 + 2x2 − x5 = 2
x1 − x6 = 6
x2 + x7 = 8
x1 , x2 , x3 , x4 , x5 , x6 , x7 ≥ 0
We have n =7and m= 5 ; we must cancel (n-m )= 7- 5 =2 variables to hope
for a feasible solution.
If we cancel x1 and x2 , we obtain: x3 x4 x5 x6 x7 = 80, −12, −2, −6, 8 Variables
x4 , x5 x6 being negative.
In the case of constraints of type ≥ or type =, in addition to subtracting
a deviation variable for constraints of type ≥ or type =, add an artificial
12
S Delenda
Chapter 3
Primal method for solving a linear program
variable
in these respective constraints
M inZ = 3x1 + 4x2 + 0x3 + 0x4 + 0x5 + 0x6 + 0x7 + 1x8 + 1x9 + 1x1 0
S.C : 5x1 + 5x2 + x3 = 60
x1 + 3x2 − x4 + x8 = 12
x1 + 2x2 − x5 + x9 = 2
x1 − x6 + x1 0 = 6
x2 + x7 = 8
x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9 , x1 0 ≥ 0
We can then obtain a starting solution by canceling(n-m)=10-5=5 variables,
i.e. the two decision variables x1 x2 ,And x4 x5 x6 (those which have been sub-
tracted). The basic solution is then: x3 = 60, x8 = 12, x9 = 2, x1 0 = 6, x7 = 8
and x1 = x2 = x4 = x5 = x6 = 0
Remark
- Regular LPP we use the Simplex Methode:
→ All constraints sign are (≤)
→ So the objective function must be Max.
- Irregular LPP we use two phasse or M methode → All constraints sign
allowable.
→ the objective could be Max or Min.
13
S Delenda
Chapter 3
Primal method for solving a linear program
x becomes X1
y becomes X2
As the independent terms of all restrictions are positive no further ac-
tion is required. Otherwise there would be multiplied by ”-1” on both
sides of the inequality (noting that this operation also affects the type
of restriction).
2X1 + X2 + e1 = 18
2·X1 + 3X2 + e2 = 42
3·X1 + X2 + e3 = 24
14
S Delenda
Chapter 3
Primal method for solving a linear program
rows). The Cb column contains the coefficients of the variables that are
in the base.
The first row consists of the objective function coefficients, while the
P reduced costs Zj −Cj .
last row contains the objective function value and
The last row is calculated as follows: Zj = (Cbi Pj ) for i = 1..m,
where if j = 0, P0 = bi and C0 = 0, else Pj = aij . Although this
is the first tableau of the Simplex method and all Cb are null, so the
calculation can simplified, and by this time Zj = −Cj .
15
S Delenda
Chapter 3
Primal method for solving a linear program
So the pivot is normalized (its value becomes 1), while the other val-
ues of the pivot column are canceled (analogous to the Gauss-Jordan
method).
Calculations for e3 row are shown below:
16
S Delenda
Chapter 3
Primal method for solving a linear program
P reviousP 4row 42 2 3 0 1 0
- - - - - -
Previous value in pivot column 2 2 2 2 2 2
× × × × × ×
New value in pivot row 8 1 1/3 0 0 1/3
= = = = = =
New e3 row 26 0 7/3 0 1 -2/3
Table 1: Calculations for P4 row
8. When checking the stop condition is observed which is not fulfilled since
there is one negative value in the last row, -1. So, continue iteration
steps 6 and 7 again.
6.1- The input base variable is X2 , since it is the variable that corre-
sponds to the column where the coefficient is -1.
6.2- To calculate the output base variable, the constant terms RHS
column) are divided by the terms of the new pivot column: 2 / 1/3
[=6] , 26 / 7/3 [=78/7] and 8 / 1/3 [=24]. As the lesser positive quo-
tient is 6, the output base variable is e1 .
6.3- The new pivot is 1/3.
7.Updating the values of tableau again is obtained:(figure 10
17
S Delenda
Chapter 3
Primal method for solving a linear program
9. Checking again the stop condition reveals that the pivot row has one
negative value, -1. It means that optimal solution is not reached yet
and we must continue iterating (steps 6 and 7):
6.1. The input base variable is e2 , since it is the variable that corre-
sponds to the column where the coefficient is -1.
6.2. To calculate the output base variable, the constant terms (RhS)
are divided by the terms of the new pivot column: 6/(-2) [=-3] , 12/4
[=3] , and 6/1 [=6]. In this iteration, the output base variable is e2 .
6.3. The new pivot is 4 7. Updating the values of tableau again is
obtained:(figure 11)
10. End of algorithm. It is noted that in the last row, all the coefficients
are positive, so the stop condition is fulfilled.
The optimal solution is given by the val-ue of Z in the constant terms
column (RHS column), in the example: 33. In the same column, the
point where it reaches is shown, watching the corresponding rows of
input decision variables: X1 = 3 and X2 = 12.
Undoing the name change gives x = 3 and y = 12.
18
S Delenda
Chapter 3
Primal method for solving a linear program
Steps
1. Modify the constraints so that the RHS of each constraint is nonnegative
(This requires that each constraint with a negative RHS be multiplied by -1)
1. Remember that if you multiply an inequality by any negative number,
the direction of the inequality is reversed!). After modification, identify each
constraint as a ≤, ≥, or = constraint.
2. Convert each inequality constraint to standard form (If constraint i is a
≤ constraint, we add a slack variable si ; and if constraint i is a ≥ constraint,
we subtract an excess variable ei ).
3. Add an artificial variable ai to the constraints identified as ≥ or = con-
straints at the end of Step 1. Also add the sign restriction ai ≥ 0.
4. If the LP is a max problem, add (for each artificial variable) −M ai to the
objective function where M denote a very large positive number.
5. If the LP is a min problem, add (for each artificial variable) M ai to the
objective function.
6. Solve the transformed problem by the simplex . Since each artificial vari-
able will be in the starting basis, all artificial variables must be eliminated
from row 0 before beginning the simplex. Now (In choosing the entering
variable, remember that M is a very large positive number!).
If all artificial variables are equal to zero in the optimal solution, we have
found the optimal solution to the original problem.
If any artificial variables are positive in the optimal solution, the original
problem is infeasible!!!
Example
Min Z = 60x + 160y
Subject to
2x + 8y ≥ 80
4x + 4y ≥ 80
x + y ≤ 250
x, y ≥ 0
set:
x = x1 , y = x2
Convert the constrains to equations
2x1 + 8x2 − s1 + A1 = 80
4x1 + 4x2 − s2 + A2 = 80
x1 + x2 + s3 = 250
x1 , x2 , s1 , s2 , s3 , A1 , A2 ≥ 0
calculate Zj we have Zj = 2 ∗ M + 4 ∗ M + 1 ∗ 0f orx1 , Zj = 8 ∗ M + 4 ∗ M +
19
S Delenda
Chapter 3
Primal method for solving a linear program
1 ∗ 0f orx2 . . . . . .
Remark
1- If objectif function is Max then
-if Cj − Zj > 0 then we start with the the biggest value as a pivot column
- If Cj − Zj ≤ 0 so the optimal solution is arrived
2- If objectif function is Min then
- If Cj − Zj < 0 then we start with the the minimum value as a pivot column
- If Cj − Zj ≥ 0 so the optimal solution is arrived
The first table
the Pivot value is 3
because : all value of cj −Zj are positive or zero the solution x2 = 20/3, x1 =
40/3, s3 = 230
20
S Delenda
Chapter 3
Primal method for solving a linear program
able (including slack and surplus variables) and -1 to each of the artificial
variables.
b. Using simplex method, try to eliminate the artificial varibles from the
basis.
c. The solution at the end of Phase-1 is the initial basic feasible solution
for Phase-2
Step-2: Phase-2
21
S Delenda
Chapter 3
Primal method for solving a linear program
x1 + 7x2 ≥ 7
and x1 , x≥ 0;
->Phase-1<————————————————
Minimum ratio is 1 and its row index is 2. So, the leaving basis variable
is A2 .
R2 (new) = R2 (old)7
22
S Delenda
Chapter 3
Primal method for solving a linear program
Minimum ratio is 1.62 and its row index is 1. So, the leaving basis vari-
able is A1 .
R1 (new) = R1 (old)7/13
R2 (new) = R2 (old) − 1/7R1 (new)
Since all Cj − Zj ≥ 0
Hence, optimal solution is arrived with value of variables as : x1 = 21/13, x2 =
10/13
M inZ = 0
–>Phase-2<————————————————
23
S Delenda
Chapter 3
Primal method for solving a linear program
we eliminate the artificial variables and change the objective function for
the original,
Since all Cj − Zj ≥ 0
24