I am trying to solve the following problem in matlab but facing some difficulty.
Min t
s.t.
t>= 0.0538λ_2 - 0.7071λ_1
t>= λ_1 - 0.3827λ_2
where 0<=λ_j<=1 for j=1,2
This is what I have so far:
f=[0;0;1]
A=[-0.7071 0.0538 -1;
1 -0.3827 -1]
B=[0;0]
ub=zeros(2,1)
lb=zeros(2,1)
linprog(f,A,B,[],[],lb,ub);
This problem is taken from a research paper and in that the author solved the above problem and found optimal value of t=−0.12698. I am not getting the correct answer with my implementation. Can someone help me please. Also how can I specify in linprog()
that I want to use the simplex method.
This should give you the correct result:
f=[1;0;0];
A=[-1 -0.7071 0.0538;
-1 1 -0.3827] ;
B=[0;0] ;
ub=[inf 1 1] ;
lb=[-inf 0 0] ;
options = optimset('Algorithm','simplex');
xres = linprog(f,A,B,[],[],lb,ub,[],options);
Note that linprog
expects your input in the format:
min x
s.t. Ax <=b
What I did here, is set the vector x = [t l1 l2]
, so the first entry in your result vector xres
corresponds with t
. You can set the algorithm using the optimset
function.
Also, you set lower and upper bounds for 2 of the 3 variables only, so matlab gave me some warnings in that regard. To be on the safe side, it is usually best to set 'dummy' limits for the unrestricted variables (i.e. here I set the upper limit of t
to inf
, and the lower limit to -inf
). That way, you make sure the right bounds apply to the right variables.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments