How can I model distances between nodes easier?

Problems with modeling
Post Reply
fpsathas
User
User
Posts: 2
Joined: 3 years ago

How can I model distances between nodes easier?

Post by fpsathas »

Hello,

I want to model 4 levels of material flow for a supply chain: field -> storage -> manufacturing -> end users

I am importing these 4 sets and their coordinates from an excel file like this example for the storage below:

set=s rng=indices!a2:a8 rdim=1
set s(*);
$load s

Also I have 3 matrix parameters which is the distance between the different nodes.
dist_fs(f,s), dist_sm(s,m) and dist_me(m,e)

I was wondering if there is a way to only have only 1 parameter matrix and calling an n by n matrix (with all the nodes) like so: dist(f,s), dist(s,m), dist(m,e).
I tried doing it but I get an error about uncontrolled sets.
How do I model this in GAMS?
abhosekar
Moderator
Moderator
Posts: 295
Joined: 3 years ago

Re: How can I model distances between nodes easier?

Post by abhosekar »

Here is an example

Code: Select all

* nodes
set n /n1*n10/;
alias(n, nn);
* distance between nodes
parameter dist(n, n);

* let's assume all distances are 10 units
* You will read this from excel file
dist(n,nn)$(ord(n) ne ord(nn)) = 10;

* distances between same nodes is 0
dist(n,nn)$(ord(n) eq ord(nn)) = 0;

* individual entities as subset of nodes
set
f(n) /n1, n2/
s(n) /n3*n5/
m(n) /n6*n8/
u(n) /n9, n10/
;

* now an example of dist_fs
* ideally with this logic you don't even need this
* you can simply use dist(f,s)
* but let's say you still need it. You can do the following
parameter
dist_fs
;

dist_fs(f, s) = dist(f, s);

display dist_fs;

You can copy this and run in GAMS. You will see dist_fs displayed in the .lst file. Hope this helps.

- Atharv
Post Reply