Dynamic tuple set array initialization and population using OPL script

Technote (FAQ)


How do I dynamically initialize and populate tuple set arrays using OPL script?


Here's a sample to dynamically initialize and populate a tuple set array indexed over another tuple set:

tuple TIndex{
  key int id;
tuple TIndexedArray{
  key int id;
  key int value;
{TIndex} index;
{TIndexedArray} indexedArray[index];
execute {
  var i, j, k, ti;
  for (i=0; i<5; i++){
  for (i=0;i<5;i++){    
    ti = index.get(i);
    k = 10*i+j;

Users need to aware about the concepts of 'lazy initialization' in OPL. Care must be taken that the indexer tuple set is completely populated before touching the dependant tuple set array. More about the pitfalls of lazy initialization can be found in the here.

Cross reference information
Segment Product Component Platform Version Edition
Commerce IBM ILOG CPLEX Optimization Studio Area:ILOG Script for OPL/OPL Script AIX, Linux, Windows 12.4, 12.3,, 12.2 All Editions

Rate this page:

(0 users)Average rating

Document information

More support for:

IBM ILOG CPLEX Optimization Studio
Area:ILOG Script for OPL/OPL Script

Software version:

6.0, 6.0.1, 6.1, 6.1.1, 6.2, 6.3, 12.2, 12.3, 12.4

Operating system(s):

AIX, Linux, Windows

Software edition:

All Editions

Reference #:


Modified date:


Translate my page

Machine Translation

Content navigation