Page 1 of 1

Assigning values for mappings

Posted: Mon Jan 14, 2019 7:20 am
by alper
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

Re: Assigning values for mappings

Posted: Mon Jan 14, 2019 7:47 am
by bussieck
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