Multi-dimensional sets/mapping

57 views
Skip to first unread message

Rahul Sharma

unread,
Feb 20, 2012, 11:43:44 PM2/20/12
to AIMMS - The Modeling System
Hi,
I am looking for some reference on creating many-many mapping in a
set.
The text below is from the GAMS manual:
Consider a set whose elements are pairs: A = {(b; d); (a; c); (c; e)}.

set c "countries"
/ jamaica
haiti
guyana
brazil / ;

and the set of ports is
set p "ports"
/ kingston
s-domingo
georgetown
belem / ;

set ptoc(p, c) "port to country relationship"

/ kingston .jamaica
s-domingo .haiti
georgetown .guyana
belem .brazil /;
The dot between kingston and jamaica is used to create one such pair.

In AIMMS how do i associate the "." operation if i want to create
subsets and map them based on existing sets?

Guido Diepen

unread,
Feb 22, 2012, 3:44:31 AM2/22/12
to ai...@googlegroups.com
Hi,

you can do this by using parentheses around the combinations. Your example can be introduced as follows in AIMMS:

DECLARATION SECTION 

  SET:
     identifier :  Countries
     index      :  c
     definition :  data { jamaica , haiti , guyana , brazil } ;

  SET:
     identifier :  Ports
     index      :  p
     definition :  data { kingston , s-domingo , georgetown ,belem } ;

  SET:
     identifier :  PortToCountry
     subset of  :  (Ports,Countries)
     definition :  data { ( kingston, jamaica ), ( s-domingo, haiti ), ( georgetown, guyana ), ( belem, brazil ) } ;

ENDSECTION  ;

So instead of using the . in between, you just use ( ) around the combination.

Guido Diepen
AIMMS Specialist

Rahul Sharma

unread,
Feb 22, 2012, 2:53:39 PM2/22/12
to AIMMS - The Modeling System
Thanks!!
I have another question to add, if i want to associate two or more
entries for ex:
Kingston. Jamaica,Haiti..Can I still use the syntax: data {(kingston,
(jamaica,haiti))}

Guido Diepen

unread,
Feb 22, 2012, 4:26:55 PM2/22/12
to ai...@googlegroups.com
Hi,

It is not possible with the syntax you stated, but each combination must be given explicitly, so

data {(kingston, jamaica) , (kingston, haiti) } 

Guido Diepen
AIMMS Specialist

Rahul Sharma

unread,
Feb 24, 2012, 4:28:17 AM2/24/12
to AIMMS - The Modeling System
Thanks !! Helped me get clarified
Reply all
Reply to author
Forward
0 new messages