Presenting the profiler example

Discusses the model profiler.mod.

The profiler example is a variation of the transportation example (see Profiling in the Samples manual).

Use the File > New > Example menu command to open the profiler example.

The IDE displays the profiler project in the OPL Projects Navigator. Open the model in the editing area.

Model of the Profiler example (profiler.mod)

int n = 300;
range r = 1..n;
int Values1[r][r];

execute INIT_Values1 {
  for( var i in r )
    for( var j in r )
      if ( i == 2*j ) 
        Values1[i][j] = i+j;
  writeln(Values1);          
}

int Values2[i in r][j in r] = (i==2*j) ? i+j : 0;

execute INIT_Values2 {
  writeln(Values2);
}

tuple T {
  int i;
  int j;
}
{T} indexes = { < i , 2 * i > | i in r };
int Values3[<i,j> in indexes] = i+j;

execute INIT_Values3 {
  writeln(Values3);
}

The profiler example is supplied with no data file. This example is a dummy unrealistic model where the same data is created in three different ways so as to demonstrate how the profiler helps you find which data is slow and/or memory consuming.

The previous code extract shows that the identical data to be created is a structure of values depending on two indices i and j. Non-null values exist only when i is equal to 2*j. The values are then i+j.

In the supplied example, i and j range from 1 to 300. This range makes the execution run in an acceptable amount of time on an average laptop computer. Still, the model is not too small, so that differences in modeling significantly affect execution time and memory consumption. You can change the value of the upper range limit n to adjust the execution time if it is too fast or too slow on your own machine.