Would like to know why the code is written in this way

Hi,

I am a pretty new user of GAMS. Recently I have come across a code snippet which is follows:
IFI '%SUSD_TRAJECTORY_CHECK%' == YES Q_SU_PUMP_RAMPDOWN_TRAJECTORY0(CONVENTIONAL_STORAGE_GEN,INTERVAL)(ORD(INTERVAL) EQ 1)…
$IFI ‘%SUSD_TRAJECTORY_CHECK%’ == YES STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,“INITIAL_PUMP_MW”) - CONVENTIONAL_PUMP_SCHEDULE(CONVENTIONAL_STORAGE_GEN,INTERVAL)
$IFI ‘%SUSD_TRAJECTORY_CHECK%’ == YES =L= INTERVAL_LENGTH60STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,“PUMP_RAMP_RATE”)*
$IFI ‘%SUSD_TRAJECTORY_CHECK%’ == YES (STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,“INITIAL_PUMP_STATUS”)
IFI '%SUSD_TRAJECTORY_CHECK%' == YES - SUM(H(ORD(H) GE ORD(INTERVAL) AND (ORD(H) LE (ORD(INTERVAL) )))
$IFI ‘%SUSD_TRAJECTORY_CHECK%’ == YES ;

Now I would like to know why it is written in this way, since it is only a single equation but why the conditional statements are written that many times instead of just once.

Regards,

The “$IFI …” is done at compilation time, so a compile time switch SUSD_TRAJECTORY_CHECK (not unlike the “#if defined … #endif” in the C preprocessor) decides if a piece of code is included in the GAMS program or not. This seems to be old GAMS code before there was a block $ifThen. Nowadays, one would write this as:

$IfThenI '%SUSD_TRAJECTORY_CHECK%' == YES 
Q_SU_PUMP_RAMPDOWN_TRAJECTORY0(CONVENTIONAL_STORAGE_GEN,INTERVAL)$(ORD(INTERVAL) EQ 1)..
  STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,"INITIAL_PUMP_MW") - CONVENTIONAL_PUMP_SCHEDULE(CONVENTIONAL_STORAGE_GEN,INTERVAL)
  =L= INTERVAL_LENGTH*60*STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,"PUMP_RAMP_RATE")*
  (STORAGEVALUE(CONVENTIONAL_STORAGE_GEN,"INITIAL_PUMP_STATUS")
  - SUM(H$(ORD(H) GE ORD(INTERVAL) AND (ORD(H) LE (ORD(INTERVAL) )))
;
$endIf

-Michael

Thanks a lot.