Maximum flow problem-lingo solution

Lingo solves the maximum flow problem

Code

Extremely hope that CSDN can join the code coloring method of lingo, MATLAB and other modeling languages

model:

sets:
node/1..6/;
road(node,node):w,a,f;
endsets

data:
a=
0,1,1,0,0,0,
0,0,0,1,1,0,
0,0,0,1,1,0,
0,0,0,0,0,1,
0,0,0,0,0,1,
0,0,0,0,0,0;
w=
0,3,4,0,0,0,
0,0,0,6,4,0,
0,0,0,5,3,0,
0,0,0,0,0,7,
0,0,0,0,0,3,
0,0,0,0,0,0;
enddata

n=@size(node);

max=vf;
@sum(road(i,j)|i#eq#1:f(i,j))=vf;

@for(node(i)|i#gt#1 #and# i#ne#n: @sum(node(j):f(i,j)*a(i,j))=@sum(node(j):f(j,i)*a(j,i) ));

@for(road(i,j):f(i,j)<w(i,j));

Insert picture description here

operation result

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41563270/article/details/108451361