Using undefined data - error K

Initialized, Assigned, Declared, Unknown Symbol

Top  Previous  Next

When data items are used which have not been declared (in a TABLE, PARAMETER or SCALE statement) one gets told they are an unknown symbol via error $140 simply stating GAMS doesn't know what they are.  In addition,  when declared items are used which have not received numerical values, one gets either:  1) message $141 when the items are used in calculations, or 2) messages $66 and $256 when the items are used in model equations.  One can also get message $141 when referring to optimal levels of variables (i.e., X.L or X.M) when a SOLVE has not been executed.  The example shorterr14.gms illustrates the first two such errors under the use of the errmsg=1 option which repositions the error message explanatory text.  This example also shows how $141 errors occur for all uses of .L and .M commands when GAMS stops and the actions undertake by solve are not checked because of earlier compiler errors.

 

   6  SET PROCESS   PRODUCTION PROCESSES /makechair,maketable,makelamp/

   7  RESOURCE  RESOURCES  /plantcap ,salecontrct ;

   8  PARAMETER PRICE(PROCESS)      PRODUCT PRICES BY PROCESS

   9                /makechair 6.5 ,maketable 3, makelamp 0.5/

  10            Yield(process)  yields per unit of the process

  11            RESORAVAIL(RESOURCE)  RESOURCE AVAILABLITY

  12               /plantcap 10 ,salecontrct 3/;

  13  parameter RESOURUSE(RESOURCE,PROCESS) RESOURCE USAGE

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

  15  VARIABLES          PROFIT              TOTALPROFIT;

  16  EQUATIONS          OBJT OBJECTIVE FUNCTION ( PROFIT )

  17                     AVAILABLE(RESOURCE) RESOURCES AVAILABLE ;

  18

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

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

****                                     $140

**** 140  Unknown symbol

  21  scalar x;

  22  x=sum(PROCESS,Yield(process));

****                    $141

**** 141  Symbol neither initialized nor assigned

****         A wild shot: You may have spurious commas in the explanatory

****         text of a declaration. Check symbol reference list.

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

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

  25

  26  MODEL RESALLOC /ALL/;

  27  SOLVE RESALLOC USING LP MAXIMIZING PROFIT;

****                                          $257

**** 257  Solve statement not checked because of previous errors

  30  solprod(PROCESS)= PRODUCTION.l(PROCESS);

****                               $141

**** 141  Symbol neither initialized nor assigned

****         A wild shot: You may have spurious commas in the explanatory

****         text of a declaration. Check symbol reference list.

 

while shorterr15.gms illustrates what happens when items without numerical value are used in equations.

 

  16  parameter RESOURUSE(RESOURCE,PROCESS) RESOURCE USAGE;

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

  18  VARIABLES          PROFIT              TOTALPROFIT;

  19  EQUATIONS          OBJT OBJECTIVE FUNCTION ( PROFIT )

  20                     AVAILABLE(RESOURCE) RESOURCES AVAILABLE ;

  21

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

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

  24  scalar x;

  25  x=sum(PROCESS,Yield(process));

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

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

  28

  29  MODEL RESALLOC /ALL/;

  30  SOLVE RESALLOC USING LP MAXIMIZING PROFIT;

****                                          $66,256

****  66  The symbol shown has not been defined or assigned

****         A wild shot: You may have spurious commas in the explanatory

****         text of a declaration. Check symbol reference list.

**** 256  Error(s) in analyzing solve statement. More detail appears

****      Below the solve statement above

**** The following LP errors were detected in model RESALLOC:

**** 66 RESOURUSE has no data

 

and shorterr15.gms shows what happens when a solve statement is not present and .L or .M variable or equation attributes are used in calculations.

 

  29  MODEL RESALLOC /ALL/;

  32  solprod(PROCESS)= PRODUCTION.l(PROCESS);

****                               $141

**** 141  Symbol neither initialized nor assigned

****         A wild shot: You may have spurious commas in the explanatory

****         text of a declaration. Check symbol reference list.