Assigning values for mappings

Problems with modeling
Post Reply
alper
User
User
Posts: 1
Joined: 3 months ago

Assigning values for mappings

Post by alper » 3 months ago

Hello everyone,
I I'm getting error assigning a value using a mapping below

Code: Select all

Sets
 i         /650,646,645,632,633,634,611,684,671,692,675,652,680/
 j(i,i)   /632.645, 632.633, 633.634, 645.646, 650.632, 684.652, 632.671, 671.684, 671.680, 671.692, 684.611, 692.675/;
 
 Parameter C(j)   /632.645    1000/;
 Display C;
 
 


Thanks in advance

User avatar
bussieck
Moderator
Moderator
Posts: 276
Joined: 2 years ago

Re: Assigning values for mappings

Post by bussieck » 3 months ago

The compiler complains with:

Code: Select all

   5   Parameter C(j)   /632.645    1000/;
****               $122                $148
**** 122  One dimensional set expected
**** 148  Dimension different - The symbol is referenced with more/less
****         indices as declared
Even though j is two-dimensional, GAMS declaration statements need one-dimensional domain sets, so you need to declare this as C(i,i). Unfortunately, there is no domain checking with j on the tuples you specify, as long as the first and second index are part of i. You can make a run-time error check:

Code: Select all

Sets
 i         /650,646,645,632,633,634,611,684,671,692,675,652,680/
 j(i,i)   /632.645, 632.633, 633.634, 645.646, 650.632, 684.652, 632.671, 671.684, 671.680, 671.692, 684.611, 692.675/;
 
 Parameter C(i,i)   /632.645    1000, 650.650 1/;
 Display C;
 
set CnotJ(i,i); alias (i,ip);
CnotJ(i,ip)$C(i,ip) = not j(i,ip);
abort$card(CnotJ) 'Some records in C not present in j', CnotJ;
-Michael

Post Reply