OPL models

Describes the process for building OPL models in Watson Studio.

You can create an OPL model in the model builder by selecting Create>OPL in the model selection window. You can also import OPL models from a file or import a scenario zip file containing the OPL model and the data. The data must be in .csv format.

Inputs and Outputs

In an OPL model, you must declare a tupleset for each table that you have imported in the Prepare data view using the same name. The schema for each tupleset must have same number of columns as the table and use the same field names. For example, if you have an input table in your Prepare data view called Product with the attributes name, demand, insideCost, and outsideCost, your OPL model must contain the following:
tuple TProduct {
   key string name;
   float demand;
   float insideCost;
   float outsideCost;
 };

{TProduct}     Product = ...;
Similarly if you want to display a table in the Explore solution view, you must define a tupleset for this output table in your OPL model. For example, this code will produce a output table with 3 columns in the solution.
/// solution
 tuple TPlannedProduction {
   key string productId;
   float insideProduction;
   float outsideProduction; 
 }

You can find this example OPL model for a pasta production problem on the Decision Optimization GitHub.

For more information about the OPL language see