Question regarding linprog formulation
Show older comments
Dear MATLAB users,
I am trying to solve a simple linear problem without success. I have tried reading the `linprog' manual several times, and I have searched the forum finding no similar question, prior to posting here. So, there I am, stuck and asking for your help.
I have written a script to solve a linear problem -both script and problem shared with you in the following- that gives me different results to the one I tested in Excel (using Open Solver) and R accordingly. I am fairly confident that the Excel solver gives me correct results, which I also validated in R later on. Therefore, I am sure that there's something wrong with this script.
Anyway, I am trying to solve the following problem:

where, I have 8 variables ( out1, out2, out3, inp1, inp2, inp3, inp4, inp5) with 70 observations (j=1,2,....,70), and starting from observation 1 (jo=1), I want to maximize μ1*out1(jo)+μ2*οut2(jo)+μ3*out3(jo) // where μ1,μ2,μ3 varying cells, subject to ν1*inp1(jo) + ν2*inp2(jo) + ν3*inp3(jo) + ν4*inp4(jo) + ν5*inp5(jo) = 1 // where ν1,ν2,ν3,ν4,ν5 again, varying cells and subject to μ1*out1(all j=1,...,70)+μ2*οut2(all j=1,...,70)+μ3*out3(all j=1,...,70) <= ν1*inp1(all j=1,...,70) + ν2*inp2(all j=1,...,70) + ν3*inp3(all j=1,...,70) + ν4*inp4(all j=1,...,70) + ν5*inp5(all j=1,...,70) and finally, ν1,ν2,ν3,ν4,ν5,μ1,μ2,μ3 >=0.
Admittedly, this should be a straightforward easy formulation for linprog, and I have tried myself coding it, yet I get different results, so I am sure that I am stuck at some point that I cannot seem to find myself.
For your convenience, I attach the matlab file and the script, which I also quote in the following:
n=70;
j0=1;
i = setdiff(1:n,j0);
f=[out1(j0), out2(j0), out3(j0), 0,0,0,0,0];
lb=[0 0 0 0 0 0 0 0];
ub=[inf inf inf inf inf inf inf inf];
A=[out1(:), out2(:), out3(:), -inp1(:), -inp2(:), -inp3(:), -inp4(:), -inp5(:)];
b=zeros(n,1);
Aeq=[0, 0, 0, inp1(j0),inp2(j0),inp3(j0),inp4(j0),inp5(j0)];
beq = 1;
m = linprog(f,A,b,Aeq,beq,lb,ub);
obviously, I start with io=1, and I enclose this into a loop later on, so that I solve this problem for every observation io=1....70.
I greatly appreciate your help and time considering my question in advance!
Sincerely, M.
Accepted Answer
More Answers (0)
Categories
Find more on Solver Outputs and Iterative Display 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!