Professional Documents
Culture Documents
Homework Assignment 2 Term - 4: Submitted To Professor Jitamitra Desai PGP 2021-23
Homework Assignment 2 Term - 4: Submitted To Professor Jitamitra Desai PGP 2021-23
Homework Assignment 2
Term – 4
Submitted to
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
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
(a) Draw the feasible region, indicating slack variables associated with each constraint,
gradient of the objective function, and graphically identify the optimum.
(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
[ ][ ] [ ]
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
[ ][ ] [ ]
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
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
[][ ] [ ]
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
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.
[]
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
[ ] [ ]
−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
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.
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)
[ ][
∂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 λ )
df
For maximizing, setting =0;
dx
⃗
[−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
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.
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)
Complementary Slackness:
(−x1 + x2 - 5)*p1=0
x1 *p3=0
x2 *p4=0
1) Assume x1 = 0
-p1 + 2*p2 - p3 = 3
( x2 - 5)*p1=0
(3x2 - 11)*p2=0
x2 *p4=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.
(−x1 + x2 - 5)*p1=0
(2x1 + 3x2 - 11)*p2=0
x2 *p4=0
2) Assume x2 = 0
p1 + 3*p2 - p4 = 10
(−x1 - 5)*p1=0
(2x1 - 11)*p2=0
Hence, p1 = 0 => p2 >0 => x1 = 11/2 => p2 = -4, which is not possible.
(−x1 + x2 - 5)*p1=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*(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.
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.
2x1 + 3x2 = 11
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)
Complementary Slackness:
(−x1 + x2 - 5)*p1=0
x1 *p3=0
x2 *p4=0
1) Assume x1 = 0
-p1 + 2*p2 - p3 = -3
( x2 - 5)*p1=0
(3x2 - 11)*p2=0
x2 *p4=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
(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.
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.
(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.
−x 1 ≤ 0 ;−x2 ≤ 0
Dual Feasibility:
[ ] [] [ ] [ ]
2 x1
2 x2
1
π 1+ π 2 +
2
−1
0
π3 +
0
−1
π 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
Stage 1:
1 → 3 → 4 → 7→ 9 1 → 2 → 4 → 7→ 9
1→3→5→8→9
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
∑ ∑ 𝑖 ∗ 𝑥𝑖𝑗 ≤ 6
𝑗
𝑖
1 ≤ 𝑖 ≤ 4; 1 ≤ 𝑗 ≤ 3
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
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
Stage 3: Value of objective function for each value that x3 takes given s3