0

Good Morning guys, I really need your help, I'm trying to figure out a problem in my implementation of a min cost flow problem in AMPL. I have to create the code for the problem in the image: min cost multiflow problem

I tried this code, but I'm not able to solve the problem of unsplittable flow and I don't know how to put constraints on origin and destination nodes.

set nodes;


param commodity1{nodes};


set arcs within {nodes cross nodes};
param cap{arcs} >= 0;
param cost{arcs} >= 0;
var flow{arcs} >= 0;

minimize z:
        sum{(i,j) in arcs} cost[i,j]*flow[i,j];

subject to c1{ (i,j) in arcs}:
    flow[i,j] <= cap[i,j];
subject to c2{i in nodes}:
    -sum{ (j,i) in arcs} flow[j,i] + sum{(i,j) in arcs} flow[i,j] = commodity1[i];

data;

set nodes := 1 2 3 4 5 6 ;


param: arcs: cap cost :=
        1,2  15    3
        2,3  1     6
        3,4  6     3
        4,1  6     8
        2,4  10    4
        2,5  10    4
        5,6  10    4
        5,3  4     12
        3,6  7     8
        4,6  8     10;
        
param commodity1 :=
        3 6,
        4 0,
        1 4,
        2 0,
        6 -4,
        5 -6
        
;

I hope someone can help me. Thank you !

vimuth
  • 5,064
  • 33
  • 79
  • 116
Alessia
  • 1
  • 1

0 Answers0