# Solving an optimization problem with KKT-conditions

I've been studying about KKT-conditions and now I would like to test them in a generated example. My task is to solve the following problem:

$$\text{minimize}:\;\;f(x,y)=z=x^2+y^2$$ $$\text{subject to}:\;\;\;\; 38x+32y-24z+964=0$$

I generated a random plane as my constraint and I want to minimize $f(x,y)=x^2+y^2$. Could I get an illustration on how to proceed from here?

Here is an illustration of my function $f(x,y) = x^2+y^2$ and the constraint plane. I would like to minimize $f$ in the domain where $f$ and the plane intersect.

• the equation of the plane can't contain $z$. – mookid May 4 '15 at 11:55
• Hi @mookid I was wondering that actually :) And this was also what confused me a bit (which is why I posted my question)...do I need to insert $x^2+y^2$ in place of $z$ in the constraint? – jjepsuomi May 4 '15 at 11:58
• I would say this problem is not well defined, because it is not known if $z$ is a parameter or a value you are minimising. – 5xum May 4 '15 at 12:00
• it is just that you want to minimize a function of 3 variables: $g(x,y,z)=x^2+y^2$; $z=g(x,y,z)$ is a constrain, not a function. – mookid May 4 '15 at 12:01
• Thank you for you help all. Appreciate it. How should I proceed then? Does this mean that I can't solve this or that my problem is simply wrongly defined? If yes, how should I restate it? :) – jjepsuomi May 4 '15 at 12:11

KKT 1 (x) :$48hx-38h+2x = 0$

KKT 1 (y) :$48hy-32h+2y = 0$

domain: $-24x^2-24y^2+38x+32y+964 = 0$

solving KKT 1(x) respect $x = \frac{19h}{24h+1}$

solving KKT 1(y) respect $y = \frac{16h}{24h+1}$

replacing $x$ and $y$ in domain and solving we obtain two possible values for the dual variable $h$.

$h_1 = -0.03495126328$ and $h_2 = -0.04838207006$ the dual variable that minimizes the problem is $h_1$:

solution:

Objective function($z$) $=29.01644637$, $x = -4.120340730$, $y = -3.469760614$ and dual variable ($h$) $= -0.03495126328$.

To check the solution you can use AMPL:

var x;
var y;
minimize z: x^2 + y^2;
subject to c: 38*x + 32*y - 24*(x^2 + y^2) + 964 = 0;
solve;
display x,y,c.dual;
x = -4.12034
y = -3.46976
c.dual = -0.0349513

• Thank you, just what I needed :) Appreciate it – jjepsuomi May 4 '15 at 14:35
• You're welcome, I forgot var y; in AMPL code. Edited. – guille_NP May 4 '15 at 15:32