Dear all, I need your help with a modelling issue, I think this will be way easy to most of you, I was up until 3 am and couldn't figure this out.
I have been working on a network model lately and though I got it working, thanks to some index programming, I cannot help but notice certain patterns in the constraints where I have used such indexed programming, this makes me thinks there must be a way to write the code so that the model itself finds the connections between the nodes I am using for my network.
The situation is the following, say I have a set of nodes w(i) /v1*v12/ and every node has more than one edge connecting to the next nodes, so for instance I can have the following edges from " v1" to a "vn":
v1.v2
v1.v3
v1.v5
So as you can see there are several edges coming out of "v1" but in the end only one edge must connect to the next element in the set v, so that if there are some edges arriving to node v2 for example v1.v2 and v3.v2, I want my model to select the best option.
Later on I want to perform some calculation with the nodes.
I have included a simplified version of the data and the code I have typed so far and I would like you to please give me a hand with constraints R2 to R7. I think there is a way to write all of those constraints into one or maybe fewer constrains without the need of using indexed programming.
I thought that the following would make the trick but no luck:
*R11(w).. SUM[m$arcos(w,m),x(w,m)] =G= 1; With this I'm trying to say there are some edges coming out of splitter w to splitters m
*R12(m).. SUM[w$arcos(w,m),x(w,m)] =E= 1; With this I'm trying to say there is only one edge coming in splitter m from splitters w
Thanks a lot for reading this and most of all thanks a lot for your valuable help, you guys rock.
A little help
A little help
 Attachments

 NETWORKING.gms
 (8.36 KiB) Downloaded 4 times
Re: A little help
Hi,
You might want to pinpoint us to the part of the solution you don't like (e.g. that you have two arcs with flow coming out if v4 (v4>v7, v4>v8)) and why the equations your though about are "no luck".
Michael
You might want to pinpoint us to the part of the solution you don't like (e.g. that you have two arcs with flow coming out if v4 (v4>v7, v4>v8)) and why the equations your though about are "no luck".
Michael
Re: A little help
Hi Michael, thanks a lot for your reply, I really appreciate it.
I am trying to learn the most I can about GAMS and feel happy with what I've learned so far but there's a lot more to learn.
As for the situation I want to improve, here is the thing, it is possible to have two or more arcs with flow coming out of say v4, just as you mention in your example and that's perfect, so v4 > v7 and v4 > v8 are valid arcs as long as there are no other arcs connecting to v7 and v8,.
Then, it is possible to have some arcs coming out a node but only should arrive to its destination.
The equations I tried previously didn't work for me as I got an error message regarding the RHS values.
*R11(w).. SUM[m$arcos(w,m),x(w,m)] =G= 1;
*R12(m).. SUM[w$arcos(w,m),x(w,m)] =E= 1;
When I typed an asterisk in front of both equations and ran the code I got the following arcs in the output:
S > v4
v7 > a17 v7 > a18 v7 > a19
v8 > a20 v8 > a21
v4 > a22
The problem with such an output is that there were some arcs missing as the output shows no arcs leading to v7 and v8.
When I used indexed programming for the arcs that go from vi to vn:
R2('v6').. SUM[w$arcos(w,'v6'),x(w,'v6')] =E=1;
R3('v7').. SUM[w$arcos(w,'v7'),x(w,'v7')] =E=1;
R4('v8').. SUM[w$arcos(w,'v8'),x(w,'v8')] =E=1;
I got this other output:
S > v4
v4 > v6
v6 > v7 v6 > v8
v7 > a17 v7 > a18 v7 > a19
v8 > a20 v8 > a21
v4 > a22
This output provided me with a series of arcs where everything is connected, there are two arcs with flow coming of v4 and v6.
Also there is only one arc leading to v6 and that is v4 > v6.
Similarly no other arcs lead to v7 but v6 > v7 and the same goes with v6 > v8.
Reviewing my equations where I used indexed programming got me wonder, there might be a better way, perhaps some "if" statements or something like it but since I got little experience programming I am having a problem tryng to figure it out.
Michael, again thanks a lot for your time and help.
 Juan Carlos
I am trying to learn the most I can about GAMS and feel happy with what I've learned so far but there's a lot more to learn.
As for the situation I want to improve, here is the thing, it is possible to have two or more arcs with flow coming out of say v4, just as you mention in your example and that's perfect, so v4 > v7 and v4 > v8 are valid arcs as long as there are no other arcs connecting to v7 and v8,.
Then, it is possible to have some arcs coming out a node but only should arrive to its destination.
The equations I tried previously didn't work for me as I got an error message regarding the RHS values.
*R11(w).. SUM[m$arcos(w,m),x(w,m)] =G= 1;
*R12(m).. SUM[w$arcos(w,m),x(w,m)] =E= 1;
When I typed an asterisk in front of both equations and ran the code I got the following arcs in the output:
S > v4
v7 > a17 v7 > a18 v7 > a19
v8 > a20 v8 > a21
v4 > a22
The problem with such an output is that there were some arcs missing as the output shows no arcs leading to v7 and v8.
When I used indexed programming for the arcs that go from vi to vn:
R2('v6').. SUM[w$arcos(w,'v6'),x(w,'v6')] =E=1;
R3('v7').. SUM[w$arcos(w,'v7'),x(w,'v7')] =E=1;
R4('v8').. SUM[w$arcos(w,'v8'),x(w,'v8')] =E=1;
I got this other output:
S > v4
v4 > v6
v6 > v7 v6 > v8
v7 > a17 v7 > a18 v7 > a19
v8 > a20 v8 > a21
v4 > a22
This output provided me with a series of arcs where everything is connected, there are two arcs with flow coming of v4 and v6.
Also there is only one arc leading to v6 and that is v4 > v6.
Similarly no other arcs lead to v7 but v6 > v7 and the same goes with v6 > v8.
Reviewing my equations where I used indexed programming got me wonder, there might be a better way, perhaps some "if" statements or something like it but since I got little experience programming I am having a problem tryng to figure it out.
Michael, again thanks a lot for your time and help.
 Juan Carlos
Re: A little help
Juan,
I still don't get the problem. You try to explain by example. It really helps if you have you math straight. Try to explain the problem in as few words as possible or better mathematics. The latter one can be very easily translated into GAMS. If you have a short and consistent problem definition I am sure you also get some help here.
Michael
I still don't get the problem. You try to explain by example. It really helps if you have you math straight. Try to explain the problem in as few words as possible or better mathematics. The latter one can be very easily translated into GAMS. If you have a short and consistent problem definition I am sure you also get some help here.
Michael