Initialization and memory allocation
Describes how memory is allocated to data initialization.
In OPL, the initialization mode you choose affects memory allocation. Namely, external initialization from a .dat file, while enabling a more modular design, may have a significant impact on memory usage.
Internal initialization
Internal data (directly from the model file) is initialized
when first used. This is also called lazy initialization
.
Unused internal data elements are not allocated any memory. In other
words, internal data is pulled
from OPL
as needed.
Example of lazy initialization
int a=2;
int b=2;
int a2=2*a;
int b2=2*b;
execute
{
a2;
a++;
b++;
writeln(a2);
writeln(b2);
}
assert a2==4;
assert b2==6;
External initialization
In contrast, data from a data file is initialized while
the .dat file is parsed and is
allocated memory whether it is used by the model or not. In other
words, external data is pushed
to OPL.
See also Pitfall of lazy initialization of data.