prepare

OPL keyword for scripting statements in data files

Purpose

OPL keyword to introduces IBM ILOG Script function definitions.

context
Data files (.dat)

Syntax

Prepare_opt: /* empty */
          | Prepare

Prepare: "prepare" "(execute-block)"


Description

This keyword introduces IBM ILOG Script function definitions to be used in some other part of the .dat file.

A .dat file can contain 0 or 1 prepare blocks.

Example

In the model file:

float t[1..3]=...;

execute
{
   writeln("after invoke");
   writeln("t=",t);
}

In the data file:

prepare {                                      
   function transformIntoHours(t, name) {   
      writeln("t=",t);                
      for(var a=1;a<=t.size;a++) t[a]=t[a]/60;
      return true;
   }   
}
// t is given in minutes and has to be converted into hours
t = [600,240,150] invoke transformIntoHours;

Result:

// The display is
// t= [600 240 150]
// after invoke
// t= [10 4 2.5]