Problem While Doing Libprog (Problem is unbounded)

Hey guys, I was trying to write a code to solve for a problem of 9 variables but with 4 constraints. Here's the code:
A=[1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
0.1 0.1 0.4 0.6 0.3 0.3 0.3 0.5 0.2
0.1 0.3 0.5 0.3 0.3 0.4 0.2 0.4 0.3
0.8 0.6 0.1 0.1 0.4 0.3 0.5 0.1 0.5];
B=[1 0.3 0.3 0.4];
Z=[4.1 4.3 5.8 6.0 7.6 7.5 7.3 6.9 7.3];
[x,fval] = linprog(Z,A,B);
I need to get the final value of the problem which the problem needs to be minimize.

1 commentaire

Torsten
Torsten le 18 Mai 2022
The problem is unbounded.
Maybe you forgot to set x(i) >= 0 (i=1,...,9) as a constraint in "lb" ?

Connectez-vous pour commenter.

 Réponse acceptée

You can also check if a feasible solution exists in other solver such as fmincon.
A = [1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
0.1 0.1 0.4 0.6 0.3 0.3 0.3 0.5 0.2
0.1 0.3 0.5 0.3 0.3 0.4 0.2 0.4 0.3
0.8 0.6 0.1 0.1 0.4 0.3 0.5 0.1 0.5]
b = [1 0.3 0.3 0.4]
f = [4.1 4.3 5.8 6.0 7.6 7.5 7.3 6.9 7.3]
lb = zeros(length(f), 1);
ub = [];
x0 = repmat(100, length(f), 1);
[x, fval, exitflag] = fmincon(@(x) dot(f, x), x0, A, b, [], [], lb, ub)
x =
1.0e-06 *
0.4958
0.4733
0.3499
0.3378
0.2659
0.2696
0.2768
0.2935
0.2768
fval =
1.8233e-05
exitflag =
1
For more info, please look up the following:

Plus de réponses (1)

Loke Yan Kuang
Loke Yan Kuang le 18 Mai 2022

0 votes

Hi, I have found the mistakes in the code. This would be the new one and I will put in the result as well
A=[1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0
0.1 0.1 0.4 0.6 0.3 0.3 0.3 0.5 0.2
0.1 0.3 0.5 0.3 0.3 0.4 0.2 0.4 0.3
0.8 0.6 0.1 0.1 0.4 0.3 0.5 0.1 0.5];
B=[1 0.3 0.3 0.4];
Z=[4.1 4.3 5.8 6.0 7.6 7.5 7.3 6.9 7.3];
[X,New_Cost]=linprog(Z,[],[],A,B,zeros(size(Z)),[],[]) %
The result:
Optimal solution found.
X =
0
0.6000
0
0.4000
0
0
0
0
0
New_Cost =
4.9800

1 commentaire

Torsten
Torsten le 18 Mai 2022
You put A, b at the wrong position in the call to "linprog".

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear Programming and Mixed-Integer Linear Programming dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by