Exporting external data

Describes how to export externally-initialized data.

The IDE also enables you to export external data in a model to an output file (a .dat file in most cases). All data elements in a .mod file declared by means of the ellipsis syntax


= ...;

are external. For example, Products, Components, Demand, Profit, and Stock are external data in the following sample (gas.mod).

{string} Products = ...;
{string} Components = ...;

float Demand[Products][Components] = ...;
float Profit[Products] = ...;
float Stock[Components] = ...;

Since these data elements are resolved from data sources (such as databases, spreadsheets) when the OPL model is instantiated, exporting external data amounts to dumping the data from such data sources to a local .dat file.

To export external data:

  1. Expand the project in the OPL Projects view and highlight the Run Configuration you want to export data for. Then open the Run menu and choose Browse As. Alternatively, you can execute the run configuration you want to export data for instead of browsing it.
  2. When the run has completed, open the Run menu and choose Export external data.

    A dialog box appears that allows you to choose the filename and location of the saved file. The default extension of the generated file is .dat, and by default, the file is saved in the same directory as the model file.

  3. Type a name for the file (for example, gasext.dat to avoid overwriting the distributed gas.dat file), and click Finish.
  4. Check for the resulting file (for example, in Windows Explorer) in the location you specified.

    The generated data file looks like a regular data file and you can open it in a text editor or in the IDE (although it does not appear in the project tree).