I have a road network graph consist of set of nodes N={1,2,3,...} and set of edges between two pair of nodes as E={(1,3), (1,5), (2,3), (2,4)....}. I want to define set of paths as well, as a set of sequences of edges, such that Links= {((1,3),(3,2),(2,4)),((1,3), (3,5)), ((2,3),(3,6),(6,5),(5,2)),...}.
Here is the initialization of my code, as an example:
int N={1,2,3,4,5,6}
tuple edge
{int i;
int j;
}
{edge} E={<1,3>, <1,5>, <2,3>, <2,4>, <3,2>, <3,4>, <3,5>, <3,6>, <5,6>, <5,4>, <6,4>};
Here I dont know how to continue to define the set of paths as a set of sequences of edges. I will be really appreciated if you can help me! thanks in advance..
you could try array of sets:
{int} N={1,2,3,4,5,6};
tuple edge
{int i;
int j;
}
{edge} E={<1,3>, <1,5>, <2,3>, <2,4>, <3,2>, <3,4>, <3,5>, <3,6>, <5,6>, <5,4>, <6,4>};
{edge} Links[E]= [{<1,3>,<3,2>,<2,4>},{<1,3>, <3,5>}];
execute
{
writeln(Links);
}
and then if you need a dvar boolean array
{int} N={1,2,3,4,5,6};
tuple edge
{int i;
int j;
}
{edge} E={<1,3>, <1,5>, <2,3>, <2,4>, <3,2>, <3,4>, <3,5>, <3,6>, <5,6>, <5,4>, <6,4>};
{edge} Links[E]= [{<1,3>,<3,2>,<2,4>},{<1,3>, <3,5>}];
execute
{
writeln(Links);
}
tuple t
{
edge e;
int rank;
}
{t} s=union(e in E) {<e,i> | i in 1..card(Links[e])};
execute
{
writeln(s);
}
dvar boolean x[s];
subject to
{
}