unbounded problem in linprog but not in fmincon
Show older comments
HI,
I am running an optimization problem. It is just a linear problem. Which is why I used linprog to solve it.
However, when I ran the code it returned that the problem was unbounded an no solution could be found.
therafter, I tried solving the same problem with Fmincon. Now I did get the right outcome.
Does anyone know how this works or what could be the cause
2 Comments
John D'Errico
on 8 May 2019
We see nothing of what you did in either case. So we need to take your word for it that you wrote correct code in both cases to solve fundamentally identical problems. And we need to accept that you do know that you did, indeed find the "correct" solution with fmincon.
So, what could be the cause? Without seeing what you did, it would be just a wild guess.
Star Strider
on 8 May 2019
If I remember correctly, the original problem is described in this post: fmincon unidentified variable in objective function (link).
Accepted Answer
More Answers (1)
Matt J
on 8 May 2019
If the problem is as below, then I obtain the same solution essentially from both linprog and fmincon
FUN= @(x) 150*x(1)+230*x(2)+260*x(3)+238*x(5)-170*x(4)+210*x(7)-150*x(6)-36*x(8)-10*x(9);
%FUN= @v 150*v(1)+230*v(2)+260*v(3)+238*v(5)-170*v(4)+210*v(7)-150*v(6)-36*v(8)-10*v(9);
x0=[50,50,50,50,50,50,50,50,50];
A=[ 1 1 1 0 0 0 0 0 0; -2.5 0 0 1 -1 0 0 0 0;0 -3 0 0 0 1 -1 0 0;0 0 -20 0 0 0 0 1 1;0 0 0 0 0 0 0 1 0];
b=[500;-200;-240;0;6000];
lb=[zeros(1,9)];
ub=[];
[sol0,fval0,exitflag0] = fmincon(FUN,x0,A,b,[],[],lb,ub); %Using fmincon
F=[150 230 260 -170 238 -150 210 -36 -10]; %Using linprog
[sol1,fval1,exitflag1] = linprog(F,A,b,[],[],lb,ub);
this produces,
>> fval0,fval1
fval0 =
-1.1860e+05
fval1 =
-1.1860e+05
>> [sol0(:),sol1(:)]
ans =
1.0e+03 *
0.1200 0.1200
0.0800 0.0800
0.3000 0.3000
0.1000 0.1000
0.0000 0
0.0000 0
0.0000 0
6.0000 6.0000
0.0000 0
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming 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!