linprog cannot find solution

5 visualizzazioni (ultimi 30 giorni)
Dany
Dany il 20 Set 2020
Commentato: Dany il 23 Set 2020
I am running a problem with constraints of equality, inequality and the limits of the variables. The formulation of the problem is correct, but the solver returns empty, or "no feasible solution found". How do I get linprog to find a solution?. Next I show the matrices and the result.
f = [ 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
A = [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 -2 0 0 0 0 0 0 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 0 0 1 0 -1 0 0 0 1 0 -1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 0 0 3 0 0 1 0 0 -1 0 0 1 0 0 -1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 0 3 0 0 0 1 0 -1 0 0 0 1 0 -1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 0 0 3 0 0 1 0 0 -1 0 0 1 0 0 -1 ];
beq = [ 0.8000
2.4000
0.4000
1.6000
2.4000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0];
lb = [ -1 -0.8 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 -10 -10 -10 -10 -10 0 0 0 0 0 0 0 0 0 0 0 0 ];
ub = [1.0, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.5, 3.6, 6.0, 2.4, 1.6, 2.4, 10.0, 10.0, 10.0, 10.0, 10.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0, 1000.0];
options=optimoptions('linprog','Display','off');
options.Display='off';
X = linprog(f,A,b,Aeq,beq,lb,ub,options);
X = []
  1 Commento
John D'Errico
John D'Errico il 20 Set 2020
Modificato: John D'Errico il 20 Set 2020
How do you know a solution exists? Said differently, why do you THINK a solution exists?

Accedi per commentare.

Risposte (1)

John D'Errico
John D'Errico il 20 Set 2020
Modificato: John D'Errico il 20 Set 2020
While you claim a solution exists, initially, I sincerely wonder if it truly does. I may learn differently by the time I am done with this response...
>> size(Aeq)
ans =
30 31
>> rank(Aeq)
ans =
24
>> rank([Aeq,beq])
ans =
24
So your euality constraints are not even full rank, although beq does lie within the column space of Aeq.
On top of that, you have 32 inequality constraints, and possibly tight bounds on the problem. That makes me wonder.
Turning off the output from a solver is usually a bad idea. So first, let me run linprog, to see what it does
>> X = linprog(f,A,b,Aeq,beq,lb,ub)
Solver stopped prematurely.
Linprog stopped because it exceeded its allocated memory.
X =
[]
So linprog did not fail because no feasible solution was found, but because it had memory problems. Interesting. Let me try intlinprog, a newer solver.
>> X = intlinprog(f,[],A,b,Aeq,beq,lb,ub)
LP: Optimal objective value is 5.842744.
Optimal solution found.
No integer variables specified. Intlinprog solved the linear problem.
X =
0.12495
0.083301
0.38257
2.2399e-14
0
0.085593
0.13267
0
1.5
0.55719
0
2.4
1.5321
1.9107
-0.04998
-0.04998
-0.04998
-0.076513
-0.04998
0.15303
0.053068
0.053068
0.053068
0
0.053068
0.076513
0.026534
0.026534
0.026534
0
0.026534
So a solution does exist after all. It does seem to satisfy the constraints. linprog has been around a while, but I would almost never turn optimization output off, at least not until I am sure there won't be anything useful I can learn from that display.
  1 Commento
Dany
Dany il 23 Set 2020
Dear John..!
Your responce was very helpful for me.
Thank you so much.

Accedi per commentare.

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by