Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 28

Date: 30th July, 2022

Homework Assignment 2
Term – 4

Submitted to

Professor Jitamitra Desai


PGP 2021-23

Submitted by: Group 4


Joshika Agarwal 2111452
Naveena Kandhala 2111475
Param Shah 2111503
Siddharth Mittal 2111505
Patel Fenil Pramodbhai 2111419
Q1.

Ans)
u l l
2 1 3 0 0 0
Basic
Cb Variables x1 x2 x3 s1 s2 s3 Values
0 s1 3 1 1 1 0 0 3
0 s2 -1 1 0 0 1 0 7
0 s3 0 1 2 0 0 1 8
Cj - Zj 2 1 3 0 0 0 6

x3 is the entering variable (since Cj – Zj is positive and highest for x3 while being at lower bound)

z 6 3
s1 3 -1
s2 = 7 + delta 0
s3 8 -2
x3 0 1

z = 6 + delta * 3
s1 = 3 – delta
Delta <= 3
s2 = 7 + 0 * delta
7 >= 0
s3 = 8 – 2 * delta
Delta <= 4
x3 = 0 + delta <=
4 Delta <= 4
s1 leaves the basis
u l l
2 1 3 0 0 0
Basic
cb Variables x1 x2 x3 s1 s2 s3 Values
3 x3 3 1 1 1 0 0 3
0 s2 -1 1 0 0 1 0 7
0 s3 -6 -1 0 -2 0 1 2
Cj - Zj -7 -2 0 -3 0 0 15

x1 is the entering variable


z 15 -7
x3 3 -3
s2 = 7 - delta 1
s3 2 6
x1 3 1

Z = 15 + delta * 7
X3 = 3 + delta * 3
Delta <= 1/3
S2 = 7- delta
Delta <= 7
S3 = 2 – delta * 6
Delta <= 1/3
X1 = 3- delta
Delta <= 3

S3 leaves the basis


l l l
2 1 3 0 0 0
Basic
cb Variables x1 x2 x3 s1 s2 s3 Values
3 x3 0 1/2 1 0 0 1/2 4
0 s2 0 7/6 0 1/3 1 -1/6 20/3
2 x1 1 1/6 0 1/3 0 -1/6 8/3
Cj - Zj 0 -5/6 0 -2/3 0 -7/6 52/3
Cj – Zj < 0 and all basic variables are fixed at lower bound. Optimal
solution:
X1 = 8/3
X2 = 0
X3 = 4
S1 = 0
S2 = 20/3
S3 = 0
Z = 52/3

Q2. Consider the following problem:


Maximize 3 x 1+2 x 2 subject ¿: x 1 +2 x2 ≤ 8x 1+ x2 ≤5
0 ≤ x1 ≤3
0 ≤ x2 ≤ 4

(a) Draw the feasible region, indicating slack variables associated with each constraint,
gradient of the objective function, and graphically identify the optimum.

Adding the slack variables –


x 1+ 2 x 2 +s 1=8x 1+ x2 + s2=5
0 ≤ x1 ≤3
0 ≤ x2 ≤ 4

Optimal point is at (3,2) and optimal value is 13

(b) Beginning with x1 and x2 respectively at their upper bounds, add artificial variables
and find an initial basic feasible solution to the problem.

Taking Xa1 and Xa2 are artificial variables, and sum of the variables has to be minimized.
Minimize X a 1+ X a 2=¿ Maximize−X a 1−X a 2
subject ¿:−x1−2 x 2−s1 + X a 1=−8−x 1−x 2−s2 + X a2 =−5
0 ≤ x1 ≤3
0 ≤ x2 ≤ 4
s1 ≥0 ; s2 ≥ 0
On fixing s1 = 0, s2 = 0, x1=3 and x2=4, we obtain values from constraints -> Xa1= 3, Xa2 = 2.

  U U l l  
cj 0 0 0 0 -1 -1
cb Basic Variables x1 x2 s1 s2 Xa1 Xa2 Values
-1 Xa1 -1 -2 -1 0 1 0 3
-1 Xa2 -1 -1 0 -1 0 1 2
cj-zj -2 -3 -1 -1 0 0 Z=-5 

x2 enters the basis as it is at its upper limit and cj-zj<0


Using line search algorithm,

[ ][ ] [ ]
z −5 −3
Xa1 3 2
= −∆
Xa2 2 1
x2 4 1

3
X a1 =3−2 ∆ ≥ 0->∆ ≤
2
X a 2=2−∆≥ 0 -> ∆ ≤ 2
x 2=4−∆ ≥ 0-> ∆ ≤ 4

3
∆≤ is the binding constraint. So, Xa1 leaves the basis
2
5 1 −1
x 2= ; X a2 = ; z =
2 2 2

  U l l l  
cj 0 0 0 0 -1 -1
cb Basic Variables x1 x2 s1 s2 Xa1 Xa2 Values
0 x2 0.5 1 0.5 0 -0.5 0 2.5
-1 Xa2 -0.5 0 0.5 -1 -0.5 1 0.5
cj-zj -0.5 0 0.5 -1 -1.5 0 Z=-0.5 

x1 enters the basis as it is at its upper limit and cj-zj<0

[ ][ ] [ ]
z −0.5 −0.5
x2 2.5
= −∆ −0.5
Xa2 0.5 0.5
x1 3 1

x 2=2.5+0.5 ∆≤ 4->∆ ≤ 3
X a 2=0.5−0.5 ∆ ≥0 -> ∆ ≤ 1
x 1=3−∆ ≥ 0-> ∆ ≤ 3

∆ ≤ 1 is the binding constraint. So, Xa2 leaves the basis


x 2=3 ; x 1=2; z =0

  l l l l  
cj 0 0 0 0 -1 -1
cb Basic Variables x1 x2 s1 s2 Xa1 Xa2 Values
0 x2 0 1 1 -1 -1 1 3
0 x1 1 0 -1 2 1 -2 2
cj-zj 0 0 0 0 -1 -1 Z=-0 

As there is no variable entering the basis and all artificial variables have left the basis, this is the
feasible solution. x 1=2 ; x2 =3; z =12(3∗2+2∗3)

(c) Starting with this basic feasible solution, determine the optimum using the lower-upper
bounded simplex method.

  l l  
cj 3 2 0 0
cb Basic Variables x1 x2 s1 s2 Values
2 x2 0 1 1 -1 3
3 x1 1 0 -1 2 2
cj-zj 0 0 1 -4 Z=12 

s1 enters the basis as it is at its lower limit and cj-zj>0

[][ ] [ ]
z 12 1
x2 3 −1
= +∆
x1 2 1
s1 0 1
x 2=3−∆ ≥ 0->∆ ≤ 3
x 1=2+∆ ≤ 3-> ∆ ≤ 1
s1=∆ ≥0
∆ ≤ 1 is the binding constraint. So, x1 leaves the basis
x 1=3 ; x 2=2; z =13
  U l  
cj 3 2 0 0
cb Basic Variables x1 x2 s1 s2 Values
2 x2 1 1 0 1 3
0 s1 -1 0 1 -2 2
cj-zj 1 0 0 -2 Z=13 

There is no entering variable. Hence the optimal solution is x 1=3 ; x 2=2; z =13

Q3. Show that the following two problems are equivalent:


.
P1: Maximize ctx P2: Maximize ctx
Subject to: b1 ≤ Ax ≤ b2; Subject to: Ax + s = b2;
x≥0 x≥0
0 ≤ s ≤ b2 – b1
Use the simplex method for lower-upper bounded variables to solve the following problem after
reformulating it as shown above:

Maximise: -3x1 + 4x2


Such that: 3 ≤ x1 + x2 ≤ 4
-15 ≤ 3x1 – 5x2 ≤ 2
given (x1, x2) ≥ 0
Solution:
Let s ≥ 0 be the slack variable such that Ax + s = b2.
Similarly, let v ≥ 0 be the surplus variable such that Ax - v = b1. Equating Ax:
⇒ b2 – s = b1 + v
⇒ v = b2 – b1 – s
⇒ As v ≥ 0 and s ≥ 0 ⇒ 0 ≤ s ≤ b2 – b1
Hence proved.

Maximise: -3x1 + 4x2


Such that: x1 + x2 + s1 = 4 ..(1)
3x1 – 5x2 + s2 = 2 ..(2)
s1 ≤ 1, s2 ≤ 17
given (x1, x2, s1, s2) ≥ 0

Using lower and upper bound simplex:


We will start with unbounded variables x1 and x2 as basis and fix bounded variables s1 and s2 at their
upper bounds.
On fixing s1 = 1 and s2 = 17, we obtain values from constraints (1 and 2) for x1= 0, x2 = 3.
We then obtain the following simplex tableau:

  U U  
cj -3 4 0 0
cb Basic Variables x1 x2 s1 s2 Values
-3 x1 1 0 0.625 0.125 0
4 x2 0 1 0.375 -0.125 3
cj-zj 0 0 0.375 0.875 Z=12 

Since both s1 and s2 are at their upper bounds, and the cj-zj values for both are positive, neither of
them will enter the basis. We are therefore at optimality with maximized f(x1, x2) at Z=12 at x1=0
and x2=3.
Q4. Categorize each of the functions below as convex, concave, or nonconvex. Be sure to
provide adequate reasoning. Also, consider if a function is in more than one category.

a) f ( x )=x 2 , x ∈ R
2 2 2
b) f ( x 1 , x 2 ) =x1 −x2 , ( x 1 , x 2 ) ∈ R
2 2 2
c) f ( x 1 , x 2 ) =x1 + x 2 , ( x 1 , x 2 ) ∈ R
3
d) f ( x 1 , x 2 , x3 ) =2 x 1 +3 x 2−4 x 3 , ( x1 , x 2 , x 3 ) ∈ R
e) f ( x )=cT x , x ∈ R n , c ∈ Rn , where c is a constant vector
f) f ( x )=cT x , x ∈ R n , c ∈ Rn ,where c is not a constant vector
2 2 3 3
g) f ( x 1 , x 2 , x3 ) =−x 1−3 x 2−2 x 2−4 x 1 x 2 +2 x 1 x3 + 4 x 2 x 3 , ( x 1 , x 2 , x 3 ) ∈ R

Solution:

a) f ( x )=x 2 , x ∈ R
Calculating the second derivative of the function,
f ' ' ( x ) =2
As the second derivative is strictly greater than zero for all x ∈ R , the function is convex.

2 2 2
b) f ( x 1 , x 2 ) =x1 −x2 , ( x 1 , x 2 ) ∈ R

[ ][
∂f

∇ f (x 1 , x 2 )=
∂ x1
∂f
∂ x2
=
2 x1
−2 x 2 ]
. Therefore, H=
2 0
0 −2
. [ ]
Since all diagonal elements are not greater than equal to zero, the function is non-convex and non-
concave.

2 2 2
c) f ( x 1 , x 2 ) =x1 + x 2 , ( x 1 , x 2 ) ∈ R

[ ][ ]
∂f

∇ f ( x 1 , x 2 )=
∂ x1
∂f
=
2 x1
2 x2
. Therefore, H=
2 0
0 2
. [ ]
∂ x2
Since all diagonal elements are greater than equal to zero, and the determinant is greater than
zero, the function is convex.

3
d) f ( x 1 , x 2 , x3 ) =2 x 1 +3 x 2−4 x 3 , ( x1 , x 2 , x 3 ) ∈ R

[]
∂f
∂ x1

[] [ ]
2 0 0 0
⃗ ∂f
∇ f ( x 1 , x 2 , x 3 )= = 3 . Therefore, H= 0 0 0 .
∂ x2
−4 0 0 0
∂f
∂ x3

Since the Hessian is positive semi definite, and negative semi definite, the function is both convex
and concave (essentially a linear function). The Hessian is positive semi definite as it is symmetric,
and all diagonal elements are greater than equal to zero, and the determinant of the sub matrix with
super diagonalisation process is zero. Similar logic holds for negative semi definite.

e) f ( x )=cT x , x ∈ R n , c ∈ Rn , where c is a constant vector

[]
c1
c2
c= [ c1 c 2 c 3 … … c n ], ∇ f ( x )= c 3

cn

( )
0 ⋯ 0
H= ⋮ ⋱ ⋮ . From the reasoning specified in part d), this function is also concave and convex.
0 ⋯ 0

f) f ( x )=cT x , x ∈ R n , c ∈ Rn ,where c is not a constant vector


 If c is assumed to be some function of x, that is: c = g(x)
o In this case, depending on g(x), the Hessian will yield that f(x) is concave, convex
or non-convex.
 If c is assumed to be piecewise constant
o By “c is not a constant vector”, the assumption is that there are piecewise ranges
over which c is constant, and it is across those boundaries that c will change.
Therefore, the function will be combination of piecewise linear components for
range of x where c is constant. For this function, the ∇ f ( x ) would not be defined
over Rn. Hence, over Rn the function is non-convex.
2 2 3 3
g) f ( x 1 , x 2 , x3 ) =−x 1−3 x 2−2 x 2−4 x 1 x 2 +2 x 1 x3 + 4 x 2 x 3 , ( x 1 , x 2 , x 3 ) ∈ R

[ ] [ ]
−2 x 1−4 x 2 +2 x3 −2 −4 2
∇ f = −6 x 2−6 x 22−4 x 1+ 4 x 3 , H f = −4 −6−12 x 2 4
2 x 1 +4 x 2 2 4 0
Since the first element of diagonal is negative, therefore the function is not convex. We will check for
concavity, using positive semi definite test on negative Hessian.
[ ] [ ]
2 4 −2 2 4 −2
- H f = 4 6+12 x 2 −4 . Performing row operations, we get 0 12 x 2−2 0 . Examining the
−2 −4 0 0 0 −2

2x2 matrix obtained [


12 x 2−2 0
0 ]
−2
. Since a diagonal element is negative, the negative Hessian is
also not positive semi definite. Therefore this function is non-convex, and non-concave.

Q5. Minimize

3
(x1 – )2 + (x2 −5)2
2

subject to:

−x1 + x2 £ 5

2x1 +3x2 £ 11

(x1, x2 ) ³ 0 .

(a) Draw the feasible region and contours of the objective function. Graphically identify the optimum
solution.

(b) How would the solution change if the objective function changes to a maximization problem?

Answer:

X2

Contour of Objective
function

Feasible region

X1

(a) Feasible region is shown in the above graph. Shape of feasible region is triangular bounded by
2*x1+3*x2 = 11, x1>0 and x2>0. Values of contours of objective function are increasing they
move away from the center (1.5,5). Minimum value of objective function occurs when contours
touches the first point in feasible region that is x1=11/26 and x2=44/13. The value of objective
function at that point is 3.77.

(b) If it is a maximization problem, then it occurs when objective function touches the x1=5.5 and x2=0.
Hence, for maximization problem, value of objective function is 41.

Q6. Consider the following nonlinear programming problem:

Minimize ( x1−4 )2+ ( x 2−2 )2 subject ¿: 4 x 21 +9 x 22 ≤ 36x 21+ 4 x 2=4( x 1 , x 2 ) ∈ X ≡ {( x 1 , x 2 )∨2 x1 ≥−3 } .

(a) Draw the feasible region and contours of the objective function. Graphically identify the
optimum solution.
(b) How would the solution change if the objective function changes to a maximization problem?

Solution:

a) The following plot depicts the contours of the objective function and the feasible region. Contours of the
objective (in R 2) are circles with centre at x 1=4 , x 2=2. Specifically, we have plotted contours for objective
values = 5, 8, 17, 32.69.

The given objective function is convex in nature, and hence proceeding in direction of the
gradient starting from global minimum increases the objective value. The minimum value,
under the constraints, is therefore achieved at the closest point of intersection (tangential here),
at x 1=2 , x 2=0 which gives z=8 .

b) The maximum will be achieved at the point furthest in the feasible region from the global
minimum. The feasible region will not have any change, nor would the objective contours change.
As depicted in the above figure, optimal point is x 1=−1.5 , x2 =−0.4375 with objective value
z=32.69

Q7. Let f(x1, x2) = 2x1 + 6x2 − 2x12 − 3x22 + 4x1x2 , where¿1, x 2¿ ∈ R 2. Maximize f (x1, x2) using the line search
method, beginning with the initial solution ( x 1 , x 2)=(-1,-1). You will need to write a small script (in any
language of your choice) to generate the optimum solution.

Solution:
f(x1, x2) = 2x1 + 6x2 − 2x12 − 3x22 + 4x1x2
⃗0
x =( x 1 , x 2 )=(−1 ,−1)

Objective: Maximize using line search method

[ ][
∂f

Gradient of f = ⃗
∇ f ( x 1 , x 2 )=
∂ x1
∂f
∂ x2
=
2−4 x 1+ 4 x 2
6−6 x2 + 4 x 1 ]
⃗0 ∇ f ( ⃗
Direction of steepest ascent = d =⃗
0
x )=
2
8 []
Let λ ( λ ≥ 0) be the step length in the direction of steepest ascent, such that new point


x =⃗
1
x +λ ⃗
0 0
d=
−1
−1 [ ] [][
2 −1+2 λ
+λ =
8 −1+8 λ ]
Now, maximizing f ( ⃗
x1 ) =f ( ⃗
x 0+ λ ⃗
d0)

¿ f (−1+2 λ ,−1+ 8 λ )

2 2
¿ 2 (−1+ 2 λ ) +6 (−1+8 λ ) −2 (−1+2 λ ) −3 (−1+8 λ ) +4 (−1+2 λ ) (−1+ 8 λ )

¿−136 λ2 +68 λ−9

df
For maximizing, setting =0;
dx

⇒ 68−272 λ=0 ; 𝜆 = 0.25


[−1+8 λ ][ ]
x 1= −1+ 2 λ = −0.5
1

⃗1 ∇ f ( ⃗
Direction of steepest ascent = d = ⃗
1
x )=
8
−2 [ ]

x =⃗
2
x +λ⃗
1 1
d=
1 [ ] [ ][
−0.5

8
−2
=
−0.5+8 λ
1−2 λ ]
And so on.

For maximizing f ( ⃗
x ) repeatedly with respect to λ we wrote a GAMS script (attached along with the
i

report) and obtained the following values:

Iteration λ x1 x2 x1' x2' d1 d2 z


1 0.25 -1 -1 -0.5 1 2 8 -
2 0.17 -0.5 1 0.836 0.666 8 -2 5.167
3 0.25 0.836 0.666 1.164 1.9977 1.32 5.348 8.937
7
4 0.17 1.1647 1.9977 2.055 1.7760 5.331 -1.3272 11.456
1 9
5 0.25 2.055 1.776 2.28 2.66 0.883 3.564 13.135
6
6 0.17 2.275 2.664 2.868 2.5165 3.554 -0.881 14.256
6
7 0.25 2.869 2.516 3.016 3.1104 0.591 2.376 15.04
5
8 0.17 3.016 3.110 3.413 3.011 2.376 -0.596 15.502
9 0.25 3.413 3.011 3.510 3.405 0.390 1.588 15.834
10 0.17 3.510 3.405 3.775 3.339 1.579 -0.388 16.056
11 0.25 3.775 3.339 3.838 3.601 0.257 1.064 16.203
12 0.17 3.838 3.601 4.016 3.558 1.051 -0.253 16.301
13 0.24 4.016 3.558 4.057 3.733 0.169 0.714 16.367
14 0.17 4.057 3.733 4.177 3.704 0.701 -0.166 16.411
15 0.24 4.177 3.704 4.204 3.821 0.111 0.480 16.441
16 0.17 4.204 3.821 4.282 3.802 0.470 -0.112 16.46
17 0.25 4.282 3.802 4.302 3.881 0.079 0.316 16.473
18 0.17 4.302 3.881 4.355 3.868 0.316 -0.079 16.482
19 0.25 4.355 3.868 4.368 3.921 0.052 0.212 16.488
20 0.17 4.368 3.921 4.404 3.912 0.210 -0.051 16.492
21 0.24 4.404 3.912 4.411 3.946 0.032 0.144 16.495
22 0.18 4.411 3.946 4.436 3.941 0.138 -0.030 16.496
23 0.22 4.436 3.941 4.440 3.963 0.019 0.100 16.498
24 0.19 4.440 3.963 4.457 3.960 0.090 -0.015 16.498
25 0.19 4.457 3.960 4.459 3.974 0.009 0.071 16.499
26 0.22 4.459 3.974 4.472 3.973 0.058 -0.005 16.499
27 0.17 4.472 3.973 4.472 3.982 0.003 0.052 16.499
28 0.27 4.472 3.982 4.482 3.981 0.037 0.000 16.5
29 0.16 4.482 3.981 4.481 3.9880 -0.003 0.040 16.5
8
30 0.24 4.4818 3.9880 4.488 3.988 0.024 -0.0006 16.5
7
31 0.17 4.4877 3.9878 4.488 3.992 0.000 0.0238 16.5
5
32 0.24 4.4878 3.9920 4.492 3.992 0.016 -0.0006 16.5
7
33 0.18 4.4917 3.9918 4.492 3.995 0.000 0.0159 16.5
5
34 0.23 4.4918 3.9946 4.494 3.994 0.011 -0.0005 16.5
3
35 0.07 4.4943 3.9945 4.494 3.995 0.000 0.0104 16.5
6

We obtained the optimal solution as ( x ¿ ¿ 1 , x 2)=( 4.494 , 3.995 ) ¿ and objective function value z = 16.5
using line search algorithm.

Q8.

Consider Problem 5. Is this a convex programming problem for parts (a) and (b)? Solve Problem 5(a) and 5(b)
using the KKT conditions. Do the KKT conditions yield a globally optimal solution in both cases? Why?

Answer:

Yes, it a convex programming problem for parts (a) as objective function and constraints are convex. For part
(b) it is not convex programming problem. Hessian matrix for objective function for maximization problem is

(−20 0
−2 )
which is positive definite everywhere.

Problem 5(a) using KKT conditions:

Minimize

3
(x1 – )2 + (x2 −5)2
2

subject to:

−x1 + x2 £ 5

2x1 +3x2 £ 11

x1 ³ 0 => -x1 £ 0

x2 ³ 0 => -x2 £ 0

Primal Feasibility:

−x1 + x2 £ 5

2x1 +3x2 £ 11

-x 1 £ 0
-x2 £ 0

Dual Feasibility:

[ ]
3
[ ]
−1
1
2
[]
*p1 + *p2 +
3
−1
0 [ ]
*p3 +
0
−1 [ ]
*p4 = -
2( x 1− )
2
2( x 2−5)

p1, p2, p3 and p4 are non-negative variables.

Complementary Slackness:

(−x1 + x2 - 5)*p1=0

(2x1 + 3x2 - 11)*p2=0

x1 *p3=0

x2 *p4=0

1) Assume x1 = 0

-p1 + 2*p2 - p3 = 3

p1 + 3*p2 - p4 = -2*(x2 -5)

( x2 - 5)*p1=0

(3x2 - 11)*p2=0

x2 *p4=0

Now Assume, p1=0

2*p2 - p3 = 3 => Hence, p2 > 0 => x2 = 11/3 => p4 = 0 => p2 = 8/9 => p3 < 0, which is not
possible.

Hence, p1>0, x2 = 5 => p2, p4 = 0 => (p1+ p3) = -3, which is not possible.

Hence, x1>0 and p3 = 0.

New equations are,

-p1 + 2*p2 = -2*(x1 -3/2)

p1 + 3*p2 - p4 = -2*(x2 -5)

(−x1 + x2 - 5)*p1=0
(2x1 + 3x2 - 11)*p2=0

x2 *p4=0

2) Assume x2 = 0

-p1 + 2*p2 = -2*(x1 -3/2)

p1 + 3*p2 - p4 = 10

(−x1 - 5)*p1=0

(2x1 - 11)*p2=0

From below equation,

(−x1 - 5)*p1=0 we can say that p1 = 0 as - ( x1+5) is < 0.

Hence, p1 = 0 => p2 >0 => x1 = 11/2 => p2 = -4, which is not possible.

Hence, x2 > 0 and p4 = 0.

New equations are,

-p1 + 2*p2 = -2*(x1 -3/2)

p1 + 3*p2 = -2*(x2 -5)

(−x1 + x2 - 5)*p1=0

(2x1 + 3x2 - 11)*p2=0

3) Assume p1 > 0

Hence, −x1 + x2 = 5

Assume p2 > 0

Hence, 2x1 + 3x2 = 11 => x1 = -4/5 and x2 = 21/5, which is not possible.

Now, Assume p2 = 0

-p1 = -2*(x1 -3/2)

p1 = -2*(x2 -5)

Which gives 2*(x1 -3/2) = -2*(x2 -5) => x1 + x2 = 13/2, which gives x1 = 3/4 and x2 = 23/4,
which is not possible as it violates primal feasibility 2x1 +3x2 £ 11.
Hence, p1 = 0.

New equations are,

2*p2 = -2*(x1 -3/2)

3*p2 = -2*(x2 -5)

(2x1 + 3x2 - 11)*p2=0

4) Assume p2 = 0

Which gives x1 = 3/2 and x2 = 5, which is not possible as it violates primal feasibility 2x1 +3x2 £
11.

Hence, p2 > 0.

New equations are,

2*p2 = -2*(x1 -3/2) => p2 = -x1 + 3/2

3*p2 = -2*(x2 -5) => p2 = -2/3*x2 + 10/3

2x1 + 3x2 = 11

After eliminating p2 from above equations we get 3x1 - 2x2 = -11/2

Solving above equations we get x1 = 11/26 and x2 = 44/13.

Objective function value is 3.77.

a) Problem 5(b) using KKT conditions:

Maximize

3
(x1 – )2 + (x2 −5)2
2

subject to:

−x1 + x2 £ 5

2x1 +3x2 £ 11

x1 ³ 0 => -x1 £ 0
x2 ³ 0 => -x2 £ 0

Primal Feasibility:

−x1 + x2 £ 5

2x1 +3x2 £ 11

-x 1 £ 0

-x2 £ 0

Dual Feasibility:

[ ]
3
[ ]
−1
1
2
*p1 + *p2 +
3 []
−1
0
*p3 + [ ]
0
−1
*p4 = [ ]
2( x 1− )
2
2( x 2−5)

p1, p2, p3 and p4 are non-negative variables.

Complementary Slackness:

(−x1 + x2 - 5)*p1=0

(2x1 + 3x2 - 11)*p2=0

x1 *p3=0

x2 *p4=0

1) Assume x1 = 0

-p1 + 2*p2 - p3 = -3

p1 + 3*p2 - p4 = 2*(x2 -5)

( x2 - 5)*p1=0

(3x2 - 11)*p2=0

x2 *p4=0

Now Assume, p1>0

Hence, x2 = 5, which is not possible as it violates primal feasibility 2x1 +3x2 £ 11.

Hence, p1=0
From, 2*p2 - p3 = -3, it can be said that p3>0

3*p2 - p4 = 2*(x2 -5)

(3x2 - 11)*p2=0

x2 *p4=0

from primal feasibility it can be said that x2 £ 11/3 as x1 ³ 0. Hence, 3*p2 - p4 < 0 => p4 > 0
=> x2 = 0 => p2 = 0 => p4 = 10 => p3 = 3.

Hence, we can say that we get the solution x1 = 0 and x2 = 0.

We get the objective function value for maximization problem as 27.25.

In a similar way, If we assume x1>0 and x2=0, then we can see from KKT conditions that we get (x1
= 5.5 and x2 = 0) and (x1 = 1.5 and x2 = 0) with objective function value of 41 and 25 respectively.

Hence, we are getting more than one solution for part (b) of the problem.

Hence, it can be said that KKT conditions gives global minima for part (a) as it is a convex
programming and minimization problem. Same is not the case with the part (b).
We noted from problem 5 that global maxima for part (b) is at point (5.5,0) with objective
function value of 41. KKT conditions, in this case, are giving multiple solutions for
maximization problem. For a minimization problem, the KKT conditions are necessary and
sufficient conditions for convex objective, yielding the optimum. However, when the objective is
convex and it is maximization problem, the KKT conditions will only give feasible solutions
with respect to the constraints, since the problem would be unbounded (under no constraints) if
we were trying to maximize a convex function. Hence, from amongst the obtained feasible
solutions, we will pick the one giving maximum objective, as shown above.

Q9. Consider the following nonlinear programming problem:

Minimize ( x1−3 )2 + ( x 2−2 )2 subject ¿: x 21 + x 22 ≤ 5 x 1+ 2 x 2 ≤ 4


( x 1 , x 2 ) ≥0

(a) Draw the feasible region and contours of the objective function. Graphically identify
the optimum solution.
Feasible region has been shaded in the graph above. The optimum occurs at corner point of this region
2 2
where circle ( x 1−3 ) + ( x 2−2 ) is minimum i.e., at (2,1). Optimum solution at (2,1) is 2.

(b) Solve the problem using the KKT conditions.


2 2
Primal Feasibility: x 1+ x2 −5≤ 0
x 1+ 2 x 2−4 ≤ 0

−x 1 ≤ 0 ;−x2 ≤ 0

Dual Feasibility:

[ ] [] [ ] [ ]
2 x1
2 x2
1
π 1+ π 2 +
2
−1
0
π3 +
0
−1
π 4 =−¿

Complementary slackness: (x ¿¿ 12+ x 22−5) π 1=0 ¿;


( x ¿ ¿ 1+ 2 x 2−4) π 2 =0 ¿ ;
x 1∗π 3=0 ; x 2∗π 4 =0
Solving the KKT conditions:

 Case I: Can x1 = 0 and x2=0?


If x1=0, then π2- π3 = 6 (from DF)
If x2=0, then π2- π4 =4 (from DF)
Π1 = 0 (from CS)
Π2 = 0 (from CS)
 Π3= -6 and π4=-4 (from DF)
 Violates DF: π3>=0 and π4>=0

 Case II: Can x1 = 0 and x2 ≠ 0?


if x2 ≠ 0, then π4 =0 and x2>0
o Suppose π1 ≠ 0 and π2 ≠ 0
x 22=5 and 2 x2 =4
No solutions in this case
o Suppose π1=0
π2- π3 = 6 (from DF)
π2 = -x2+2
Using complementary slackness,
(2 x2 −4 ¿ π 2=(2 x 2−4)(2−x2 )=0
x2=2; π2=0; π3=-6
This violates πi >=0 for all i. Hence π1 cannot be zero
o Suppose π2=0 and π1>0
2
x 2=5 and π3= - 6
This violates πi >=0 for all i. Hence π2 cannot be zero

 Case III: Can x2 = 0 and x1 ≠ 0?


if x1 ≠ 0, then π3 =0 and x1>0
o Suppose π1 ≠ 0 and π2 ≠ 0
x 21=5 and x 1=4
No solutions in this case
o Suppose π1=0
π2 = -2x1 +6 (from DF)
2π2 – π4= 4
Using complementary slackness,
( x 1−4 ¿ π 2 =(x 1−4)(6−2 x 1 )=0
x1=3; π2 =0; π4=-4 (or)
x1=4; π2 =-2; π4=-8
Both violates πi >=0 for all i. Hence π1 cannot be zero
o Suppose π2=0 and π1>0
2
x 1=5 and π4= - 4 (from DF)
This violates πi >=0 for all i. Hence π2 cannot be zero

 Case IV: Can x1 ≠ 0 and x2 ≠ 0?


This implies that π3 =0 and π4 =0
Then, from DF
2 x1 π 1+ π 2 =−2 x 1 +6
2 x2 π 1+ 2 π 2=−2 x 2+ 4

o Suppose π1 = 0 and π2 = 0
x 1=3and x 2=2
But this solution doesn’t satisfy primal feasibility x 21+ x22 −5≤ 0
o Suppose π1=0, π2>0
Using complementary slackness,
( x 1+ 2 x 2−4 ¿=0=¿ x 1 +2 x 2=4
x1=2.4; x2= 0.8; π2 =1.2
But this solution doesn’t satisfy primal feasibility x 21+ x22 −5≤ 0
o Suppose π2=0 and π1>0
Using complementary slackness,
x 21+ x22 =5
π1>0; π2 =0
But this solution doesn’t satisfy primal feasibility x 1+ 2 x 2−4 ≤ 0
o Suppose π1>0 and π2>0
Using complementary slackness,
x 21+ x22 =5
( x 1+ 2 x 2−4 ¿=0=¿ x 1 +2 x 2=4
Solving this, we get
(x1, x2) = (2,1) or (x1, x2) = (-0.4,2.2)
The only solution that satisfies all KKT conditions are
x1=2; x2=1; π1=0; π2 =2; π3=0; π4 =0

So, Optimum value for our objective function as per KKT conditions:
2 2
( x 1−3 ) + ( x 2−2 ) =2

Q10. Find the shortest path from node 1 to node 9 using


dynamic programming.

Stage – Number of steps remaining to get to the destination


States (s) – list of nodes at each stage
Decision (x) - which node to go to from current stage
Objective function (f) – minimum distance to be traversed

Stage 1:

x1 f1(s1, x1) = ds1,x1 x1*


s1 9
7 3* 9
8 4* 9
Stage 2:
x2 f2(s2, x2) = ds2,x2 x2*
s2 7 8
4 1+3=4* 4+4=8 7
5 6+3=9 3+4=7* 8
6 3+3=6* 3+4=7 7
Stage 3:
x3 f3(s3, x3) = ds3,x3 x3*
s3 4 5 6
2 3+4=7* 2+7=9 4+6=10 4
3 4+4=8* 1+7=8* 5+6=11 4, 5
Stage 4:
x4 f4(s4, x4) = ds4,x4 x4*
s4 2 3
1 4+7=11* 3+8=11* 2, 3
Optimal Shortest paths:

1 → 3 → 4 → 7→ 9 1 → 2 → 4 → 7→ 9

1→3→5→8→9

Optimal distance for all these shortest paths is 11

Q11. The sales manager for a publisher of college textbooks has six traveling salespeople to assign to
three different regions of the country. She has decided that each region should be assigned at least one
salesperson and that each individual salesperson should be restricted to one region only. The following
table gives the estimated increase in sales (in appropriate units) in each region if it were allocated
various numbers of salespeople. Use dynamic programming to find

This problem can be formulated as:


maximize 𝑧 = 𝛴𝑥𝑖𝑗𝑐𝑖𝑗
s.t. ∑ 𝑥𝑖𝑗 = 1
𝑖

∑ ∑ 𝑖 ∗ 𝑥𝑖𝑗 ≤ 6
𝑗
𝑖

1 ≤ 𝑖 ≤ 4; 1 ≤ 𝑗 ≤ 3

Where 𝑥𝑖𝑗 → 𝑏𝑖𝑛𝑎𝑟𝑦 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒 𝑖𝑛𝑑𝑖𝑐𝑎𝑡𝑖𝑛𝑔 𝑎𝑠𝑠𝑖𝑔𝑛𝑚𝑒𝑛𝑡, 𝑐𝑖𝑗 → 𝐼𝑛𝑐. 𝑖𝑛 𝑆𝑎𝑙𝑒𝑠


i → number of salespeople assigned to region j

Defining stages, states, decisions, and objective function for solving via dynamic
programming
Stages: Region (3 Regions)
States: Salespeople remaining to be allocated (Total 6 available)
Decision: Number of salespeople allocated to current stage
Objective: Maximize sales
ai,j represented estimated increase in sales if i salespersons are assigned to region j.
Stage 3:
S3\x3 Objective function(ai,3) Optimum value(x3*)
1 28 1
2 41 2
3 63 3
4 75 4

We cannot have state value greater than 4 in stage 3 as available salespeople are 6 and at least
one should be assigned to each Stage (region).

Stage 2:
Objective function
f2(s2,x2) = a2,x2* + f3*(s2-x2)
S2\x2 1 2 3 4 5 X2*
1 - - - - - -
2 21+28 =49 - - - - 1
21+41 =
3 42+28=70 - - - 2
62
4 21+63 =84 42+41=83 56+28=84 - - 1 or 3
21+75 =
5 42+63=105 56+41=97 70+28=98 - 2
96

Each region should have at least one salesperson so the total number of remaining
salespersons should be greater than 1 in stage 2. It cant be 6 also as at least one salesperson
would be assigned to region 1.
Stage 1:
f1(s1,x1) = a1,x1* + f2*(s1-x1)
Optimum
S1\x1 1 2 3 4 5 6
solution
35+105
6 132 140 138 - - 1 or 3
=140

Hence we have multiple optimal solutions with a sales value of 140, they are given
as 1 Salespersons in region 1 , 2 Salespersons in region 2 , 3 Salespersons in region 3
3 Salespersons in region 1 , 2 Salespersons in region 2 , 1 Salespersons in region 3

ALTERNATE SOLUTION

As a dynamic programming problem,


 Stages: Salesperson to be allotted (= {1, 2, 3, 4, 5, 6})
 States: Salespersons in different regions (s1 = (1,0,0) and so on)
 Decision: Which cell to go from current stage
 Objective: Maximize total sales given constraints

Since each region needs to have at least one salesperson, starting state can be considered
as (1,1,1) i.e. each region has been allotted one sales person. Total increase in sales = 84

S2 F2(s2, x2) = s2*𝑐𝑠2 X1*


0; 1
(2,1,1) 105*;97 0
(1,2,1) 97; 105* 1
(1,1,2) 105*; 97 0

F3(s3, x3) = s3*𝑐𝑠3


S3 X2*
0; 1
(3,1,1) 118; 119* 1
(2,2,1) 119*; 118 0
(2,1,2) 119*; 110 0
(1,3,1) 118; 119* 1
(1,2,2) 119*; 118 0
(1,1,3) 119*; 97 0

F3(s4, x4) = s4*𝑐𝑠4


S4 X3*
0; 1
(4,1,1) 140*; 138 0
(3,2,1) 138; 140* 1
(3,1,2) 140*; 132 0
(1,4,1) 140*; 133 0
(2,3,1) 140*; 132 0
(1,3,2) 140*; 122 0
(1,1,4) 140*; 131 0
(1,2,3) 138; 140* 1
(2,1,3) 140*; 132 0

The final solution is to allot either (3,2,1) or (1,2,3) salespeople to


regions 1,2 & 3 respectively. The resulting increase in sales being 140.

Q12. Solve the following problem using dynamic programming.


Maximize 2 x21 +2 x 2+ 4 x 3−x 23 subject ¿: 2 x 1+ x2 + x 3=4
( x 1 , x2 , x3 ) ≥ 0
Defining stages, states, decisions, and objective function for solving via dynamic programming
Stage – Variables (x1, x2, x3)
States (s) – Number of units of constraint remaining (Total 4)
Decision (x) - Value each variable takes
Objective function (f) – Maximize 2 x21 +2 x 2+ 4 x 3−x 23

Stage 3: Value of objective function for each value that x3 takes given s3

Stage 2: Value of objective function: f(s2,x2) = 2x2 + f3(s2 – x2)

Stage 1: Value of objective function: f(s1, x1) = 2x1^2 + f(4 – 2x1)


  f(s3,x3) = 4x3 - x3^2
x3
s3 \ x3 0 1 2 3 4
0 0         0
1   3       1
2     4     2
3       3   3
4         0 4

  f(s2,x2) = 2x2 + f3(s2-x2)


x2
s2 \ x2 0 1 2 3 4
0 0         0
1 3 2       0
2 4 5 4     1
3 3 6 7 6   2
4 0 2 8 9 8 3
  f(s1,x1) = 2x1^2 + f(4-2x1)
x1
s1 \ x1 0 1 2
4 9 7 8 0

The final optimal solution is x1 = 0, x2 = 3, x3 = 1

You might also like