How can I add innequalities to a minimum cost-flow problem?

Hello everyone. I have the following optimization code:
f =[2 , 4 , 9 , 3 , 1 , 3 , 2 ] ;
Aeq=[1 1 1 0 0 0 0
-1 0 0 1 0 0 0
0 -1 0 -1 1 0 0
0 0 -1 0 0 1 -1
0 0 0 0 -1 -1 1 ] ;
Beq=[50; 40 ; 0 ; -30; -60] ;
lb =[0 0 0 0 0 0 0 ] ;
ub=[10 inf inf inf 80 inf inf] ;
intcon =[1 ,2, 3, 4, 5, 6, 7 ] ;
[x, v, s]= intlinprog( f, intcon, [], [], Aeq , Beq , lb , ub )
LP: Optimal objective value is 490.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).
x = 7×1
0 40 10 40 80 0 20
v = 490
s = 1
This code represents a minimum cost-flow problem in which, the same amount of product goes from two sources to two desiny nodes as per the attached image called problem.PNG. However, my slides say that if there is an excess of demand, (E demands 70 units instead), the conditions on nodes D and E would be:
from And from
I have tried to implement this by introducing A and B as:
f =[2 , 4 , 9 , 3 , 1 , 3 , 2 ] ;
Aeq=[1 1 1 0 0 0 0;
-1 0 0 1 0 0 0;
0 -1 0 -1 1 0 0] ;
A=[0 0 -1 0 0 1 -1;
0 0 0 0 -1 -1 1];
B=[-30; -70];
Beq=[50; 40 ; 0] ;
lb =[0 0 0 0 0 0 0 ] ;
ub=[10 inf inf inf 80 inf inf] ;
intcon =[1 ,2, 3, 4, 5, 6, 7 ] ;
[x, v, s]= intlinprog( f, intcon, A, B, Aeq , Beq , lb , ub)
No feasible solution found. Intlinprog stopped because no point satisfies the constraints. x = [] v = []
s = -2
Unfortunately, as it can be seen, I obtain unfeasible as result.
Can someone please tell me if they can spot my mistake?
Best regards.

7 Comments

I think -60 instead of -70 (see above).
Again a typo ? :-)
@Torsten Hi, thanks for your suggesion. However, I am editing my the code to its original form. If the demand increases from 60 to 70 in node E, I am trying to reflect this in the code by introducing two innequalities, as A and B=[-30; -70];
This comes from the attached image, in which, my slides suggest to use these equations to represent an excess of demand in node E from 60 to 70, thus having an offer of 90 and a demand of 100.
Demand cannot be greater than supply.
Supply is 50 + 30 = 80, demand would be 70 + 30 = 90 if you increase the demand in node E from 60 to 70.
What I have in my slide is as follows:
If a demand excess exists, such as node E demands 70 units ()
then, the function restrictions would be
Node A
Node B
Node C
Node D
Node E
In this case, the porblem's solution would be
x=[0 40 10 40 80 0 10]
fval=47000
That is what I am trying to implement, is the slide wrong?
>= instead of <= :
f =[2 , 4 , 9 , 3 , 1 , 3 , 2 ] ;
Aeq=[1 1 1 0 0 0 0;
-1 0 0 1 0 0 0;
0 -1 0 -1 1 0 0] ;
A=[0 0 1 0 0 -1 1;
0 0 0 0 1 1 -1];
B=[30; 70];
Beq=[50; 40 ; 0] ;
lb =[0 0 0 0 0 0 0 ] ;
ub=[10 inf inf inf 80 inf inf] ;
intcon =[1 ,2, 3, 4, 5, 6, 7 ] ;
[x, v, s]= intlinprog( f, intcon, A, B, Aeq , Beq , lb , ub)
LP: Optimal objective value is 470.000000. Optimal solution found. Intlinprog stopped at the root node because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).
x = 7×1
0 40 10 40 80 0 10
v = 470
s = 1
@Torsten Well, thanks for the answer. It seems to work, but I don't understand why. You have multiplied A and B by -1. I will try to figure it out.
Yes, what arrives in D must be less or equal 30, not greater or equal 30, and what arrives in E must be less or equal 70, not greater or equal 70. If you use >= in both cases, you cannot satisfy this demand because in sum it would be >=100, but as supply you only have 90 to distribute among D and E.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2021a

Commented:

on 16 Jul 2022

Community Treasure Hunt

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

Start Hunting!