# Question:Solving Optimization problem using the Karush Khun Tucke conditions

## Question:Solving Optimization problem using the Karush Khun Tucke conditions

Maple 18

Hi everyone, I have problem solving a given optimization problem using the Karush Khun Tucke conditions. The working is as follows:

restart;
with(linalg);
f := 49*x[1]+94*x[2]+90*x[3]+24*x[4]+6*x[5]+63*x[6]+17*x[7]+65*x[8]+72*x[9]+40*x[10]+67*x[11]+99*x[12]+97*x[13]+53*x[14]+22*x[15]+47*x[16]+60*x[17]+36*x[18]+54*x[19]+67*x[20]+46*x[21]+55*x[22]+42*x[23]+70*x[24];
49 x[1] + 94 x[2] + 90 x[3] + 24 x[4] + 6 x[5] + 63 x[6]

+ 17 x[7] + 65 x[8] + 72 x[9] + 40 x[10] + 67 x[11] + 99 x[12]

+ 97 x[13] + 53 x[14] + 22 x[15] + 47 x[16] + 60 x[17]

+ 36 x[18] + 54 x[19] + 67 x[20] + 46 x[21] + 55 x[22]

+ 42 x[23] + 70 x[24]
g[1] := x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+x[8]+x[9]+x[10]+x[11]+x[12]-475;
x[1] + x[2] + x[3] + x[4] + x[5] + x[6] + x[7] + x[8] + x[9]

+ x[10] + x[11] + x[12] - 475
g[2] := x[13]+x[14]+x[15]+x[16]+x[17]+x[18]+x[19]+x[20]+x[21]+x[22]+x[23]+x[24]-30;
x[13] + x[14] + x[15] + x[16] + x[17] + x[18] + x[19] + x[20]

+ x[21] + x[22] + x[23] + x[24] - 30
for i from 3 to 26 do g[i] := -x[i] end do;
h[1] := 54-x[1];
54 - x[1]
h[2] := 30-x[2];
13 - x[2]
h[3] := 13-x[3];
13 - x[3]
h[4] := 41-x[4];
41 - x[4]
h[5] := 97-x[5];
97 - x[5]
h[6] := 11-x[6];
11 - x[6]
h[7] := 62-x[7];
62 - x[7]
h[8] := 59-x[8];
59 - x[8]
h[9] := 35-x[9];
35 - x[9]
h[10] := 42-x[10];
42 - x[10]
h[11] := 19-x[11];
19 - x[11]
h[12] := 12-x[12];
12 - x[12]
vars := [x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]];
[x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10],

x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19],

x[20], x[21], x[22], x[23], x[24]]
H := Hessian(f, vars);
Hessian(49 x[1] + 94 x[2] + 90 x[3] + 24 x[4] + 6 x[5] + 63 x[6]

+ 17 x[7] + 65 x[8] + 72 x[9] + 40 x[10] + 67 x[11] + 99 x[12]

+ 97 x[13] + 53 x[14] + 22 x[15] + 47 x[16] + 60 x[17]

+ 36 x[18] + 54 x[19] + 67 x[20] + 46 x[21] + 55 x[22]

+ 42 x[23] + 70 x[24], [x[1], x[2], x[3], x[4], x[5], x[6],

x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15],

x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]])
Del(49 x[1] + 94 x[2] + 90 x[3] + 24 x[4] + 6 x[5] + 63 x[6]

+ 17 x[7] + 65 x[8] + 72 x[9] + 40 x[10] + 67 x[11] + 99 x[12]

+ 97 x[13] + 53 x[14] + 22 x[15] + 47 x[16] + 60 x[17]

+ 36 x[18] + 54 x[19] + 67 x[20] + 46 x[21] + 55 x[22]

+ 42 x[23] + 70 x[24], [x[1], x[2], x[3], x[4], x[5], x[6],

x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15],

x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]])
for i to 26 do grad_g[i] := Del(g[i], vars) end do;
for i to 12 do grad_h[i] := Del(h[i], vars) end do;
eq[1] := grad_f+sum(mu[i]*g[i], i = 13 .. 26)+sum(lambda[i]*h[j], j = 1 .. 12) = 0;
Error, (in sum) summation variable previously assigned, second argument evaluates to 13 = 13 .. 37
eq[2] := g[i] <= 0;
-x[13] <= 0
eq[3] := h[j] <= 0;
h[j] <= 0
eq[4] := mu[i] >= 0;
0 <= mu[13]
eq[5] := lambda[j] <= 0;
lambda[j] <= 0
eq[6] := mu[i]*g[i] = 0;
-mu[13] x[13] = 0
eval(solve({eq[1], eq[2], eq[3], eq[4], eq[5], eq[6]}, [vars, lambda[j], mu[i]]));
Error, invalid input: too many and/or wrong type of arguments passed to solve; first unused argument is [[x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15], x[16], x[17], x[18], x[19], x[20], x[21], x[22], x[23], x[24]], lambda[j], mu[13]]

﻿