Kuhn-tucker conditions matlab

84 views (last 30 days)
Kai
Kai on 20 Apr 2014
Edited: Matt J on 21 Apr 2014
I am solving a maximisation problem subject the the restriction that xi<=delta*TR(x1,x2) for i=1,2. There are two lagrangians associated with my problem:
L1=U1(x1,x2)+lambda1*(delta*TR(x1,x2)-x1)
L2=U2(x1,x2)+lambda2*(delta*TR(x1,x2)-x2)
I need to solve for the vector (x1,x2)
I am investigating two cases:
Case 1: The restriction is binding in both lagrangians i.e. xi=delta*TR(x1,x2) for i=1,2. The Kuhn-Tucker conditions for this require that lambda1>0 and lambda2>0. Thus, I have four FOCS's:
(i) dL1/dx1
(ii) dL1/dlambda1
(iii) dL2/dx2
(iv) dL2/dlambda2
I used FSOLVE with a system of 4 equations and got the result that I was looking for. So this case works fine.
Case (ii)
The restriction xi<=delta*TR(x1,x2) is only binding in the first lagrangian (L1). The Kuhn-Tucker conditions for this require that lambda1>0 and lambda2=0.
My question is: How do I incorporate lambda1>0 and lambda2=0 into my system of equations? Do i need to drop one of the first order conditions? Or do I need to drop the lambda2(delta*TR(x1,x2)-x2) term in the second lagrangian?
I realise that this is more of a maths question than Matlab question, but I would greatly appreciate any help!
Thanks, Kai

Accepted Answer

Matt J
Matt J on 20 Apr 2014
Edited: Matt J on 20 Apr 2014
You can use LSQNONLIN, which is very similar to FSOLVE, but allows you to incorporate bounds like lambda1>=0.
On the other hand, even if this is homework, if you are allowed to use solvers like FSOLVE, I wonder why you wouldn't be allowed to just use FMINCON to solve the whole problem for you, instead of manually attacking the KKT conditions.
  2 Comments
Kai
Kai on 20 Apr 2014
Edited: Kai on 21 Apr 2014
When using FSOLVE I have to put the FOC in a function file and then I use the following code in my script file.
clear
b=1;
n=4.5;
c=1;
e=0;
m=6;
f=5;
d=0.05:0.05:0.5;
xyl=zeros(4,max(size(d)));
v0=[1;1;10;4];
options =optimset('Display','iter','MaxFunEvals', 1000,'TolFun',1e-5);
%'TolFun',1e-5,'MaxFunEvals',2000,'MaxIter',2000);
%'FunValCheck', 'on', 'PlotFcns', @optimplotfval
for i=1:max(size(d))
[xylf,FVAL,EXITFLAG,OUTPUT,JACOB] = FSOLVE(@(v) myfunc3(v,d(i),f,m,n,b,c,e),v0,options);
xyl(:,i) = xylf ;
end
How can I change this to use LSQNONLIN? And where do I insert code for the restrictions that I need on x1 and x2.
Cheers, Kai
Matt J
Matt J on 21 Apr 2014
Edited: Matt J on 21 Apr 2014
It is very similar to FSOLVE and should be obvious from the documentation for LSQNONLIN
>> doc lsqnonlin

Sign in to comment.

More Answers (0)

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!