Indexing problems - error E

More Domain errors

Top  Previous  Next

Parameters, variables, and equations are specified with a particular index order.  Errors can be made where one inadvertently alters that order in subsequent references (i.e., RESOURUSE(RESOURCE,PROCESS) is referred to as RESOURUSE(PROCESS,RESOURCE)).  One can also use too many [(RESOURUSE(RESOURCE,PROCESS,resource)] or too few [RESOURUSE(RESOURCE)] indices.  Cases where the order of sets are changed are marked with message $171.  Cases where more or less indices are used are marked with messages $148.  The example shorterr07.gms provides cases, where permutations of the RESOURUSE(RESOURCE,PROCESS)  are entered and the errmsg=1 option is used to reposition the messages.

 

  16  TABLE RESOURUSE(RESOURCE,PROCESS) RESOURCE USAGE

  17                     Makechair   Maketable  Makelamp

  18       plantcap         3          2          1.1

  19       salecontrct      1         -1;

  20  POSITIVE VARIABLES PRODUCTION(PROCESS) ITEMS PRODUCED BY PROCESS;

  21  VARIABLES          PROFIT              TOTALPROFIT;

  22  EQUATIONS          OBJT OBJECTIVE FUNCTION ( PROFIT )

  23                     AVAILABLE(RESOURCE) RESOURCES AVAILABLE ;

  24  OBJT.. PROFIT=E=   SUM(PROCESS,(PRICE(PROCESS)*yield(process)

  25                           -PRODCOST(PROCESS))*PRODUCTION(PROCESS)) ;

  26  AVAILABLE(RESOURCE).. SUM(PROCESS,RESOURUSE(PROCESS,RESOURCE)

****                                                     $171     $171

**** 171  Domain violation for set

  27                       *PRODUCTION(PROCESS))  =L= RESORAVAIL(RESOURCE);

  28  scalar x;

  29  x=sum((resource,process),RESOURUSE(RESOURCE,PROCESS,process));

****                                                             $148

**** 148  Dimension different - The symbol is referenced with more/less

****         indices as declared

30  x=sum(resource,RESOURUSE(RESOURCE));

****                                   $148

**** 148  Dimension different - The symbol is referenced with more/less

****         indices as declared