Decision Optimization model builder views and scenarios
The Decision Optimization model builder is an interface with different views in which you can select data, create models and solve different scenarios and visualize the results.
In this section:
When you click Add to Project and choose Decision Optimization as the asset type, you open the Decision Optimization model builder.
The Decision Optimization model builder allows you to create prescriptive models. Optimization models allow you to focus on a specific business problem that you want to solve.
To run Optimization models you must associate a Watson Machine Learning instance with your Watson Studio project. This can be selected in the model builder when you first create a new Decision Optimization model or, for existing models, see the Run Model view section that follows.
You can create a Decision Optimization model from scratch by simply entering a name or from a zip file and then and selecting Create.. Scenario 1 opens.
With the Decision Optimization model builder, you can create several scenarios, using different data sets and optimization models. This allows you to create and compare different scenarios and see how big an impact changes can have on a given problem.
For each of the following views, you can organize your screen as full-screen or as a split-screen. To do this, hover over one of the view tabs (Prepare data, Run model, Explore solution) on the left, for a second or two. A menu then appears where you can select Full Screen, Left or Right. For example if you choose Left for the Select Data view, and then choose Right for the Prepare Input Data view, you can see both these views on the same screen.
Prepare data view
When you create a new Decision Optimization
model in your project, the Prepare data
view opens. In this view you can browse and import data sets that you
already have in your Project in Watson Studio.
You can also choose to add data that you want to add to your model. Click add data and then Browse in
the Find and Add data pane to browse and select your files and click open. Note that
csv files can be imported in Decision Optimization for Watson Studio. When you add a data set in this way, it
appears listed in the Prepare data
view as well as in the Data sets listed in your
Select the files you want to import to your Scenario and click Import.
If you subsequently modify, replace or delete a data set in your Project, or re-upload a new version of a table using the add data set button or Find and Add data pane in the Prepare data view, this will have no impact on your scenario unless you choose to import it into your scenario.
- Rename or delete a table.
- Edit the data directly in a table. You can scroll the table to see more rows (or Open the table in full mode to see the whole table and edit it in a new window)
- Rename column names.
- Re-size columns.
- Add or remove rows.
- Search and filter table values. See Table search and filtering.
If you re-import a file at any time you can choose to import it with a new name. This can be useful if you want to use different versions of the same data table. You can also choose to update and overwrite the current table in your Scenario. If you choose to re-import and update a table, a notification message will appear at the top of the screen to remind you of which tables have been overwritten.
Changes you make in the Prepare data view will be saved in your scenario, but not in the Project Data sets. Similarly if you make changes to the Project Data sets, unless you import these changes into your scenario, they will not appear in the Prepare data view.
You can access your imported data from your Python DOcplex model using the syntax
inputs['tablename']. See Input and output data.
Run model view
This view allows you to formulate or import optimization models and run them.
There are several options to create a model:
- Create and edit a Python or OPL model in the Decision Optimization model builder.
- Use the Modeling Assistant to formulate models in natural language. See Formulating and running a model: house construction scheduling for a tutorial on formulating models with the Modeling Assistant.
- Import and edit a Python optimization model from an existing notebook or from an external file. Use this option to import a notebook from your local machine or to use a notebook you have already imported into Decision Optimization for Watson Studio.
- Import and edit an OPL model from a file.
- Import a scenario zip file (which contains both model and data). This can be a new scenario or one that you have previously exported from the Decision Optimization model builder and edited locally.
- Generate a Python model from your current scenario (Python and Modeling Assistant models only). This will create a Python notebook optimization model in your project.
You can create a Python or OPL model using multiple model files by clicking the + tab next to MODEL and selecting Add new empty or Upload Files. The tab named MODEL must always contain your main model. If you try to upload another file with the same name, for example model.py, you are prompted to upload it with new name or replace your main model. You can also replace a model by clicking the Import icon.
When you edit your model formulation in the Decision Optimization model builder your content is saved automatically and the Last save time is displayed on the top of the page.
Once you have created a model, the Replace option appears in the upper-left of the window. If you click Replace, you return to the Model wizard. Note that if you create a new model, the previous one is deleted.
When you have finished editing your model, you can solve it by clicking the Run button in this view.
To run models you must associate a Watson Machine Learning instance with your Watson Studio project. To do this, in the Overview tab of your project, scroll to find the Associated deployment space section and click Add a Machine Learning service. In the window that opens, select a Machine Learning service from the drop-down list and click Select. If you have no associated service defined when you try to run a model, you obtain the error "Run FAILED: cannot deploy model to wml".
You can also set and modify certain optimization parameters by clicking the Configure run icon next to the Run button. These parameters will be then applied each time you click Run.
When you click the Run Configuration icon next to the Run button in the Model view, a window opens showing you the currently set parameter values.
Here you can select and edit different run configuration parameters. For more details, see Run parameters.
Once you have set the run configuration parameters they will be used with those values for all subsequent runs for that scenario.
You can remove set parameters by hovering over the parameter and clicking the remove button.
Explore solution view
During the run, a graphical display shows the feasible solutions obtained until the optimal solution is found.
When your run completes successfully, the solution is displayed in one or several tables in the Explore Solution tab. The result tables are automatically displayed in alphabetic order. Note that the result tables are not editable but can be filtered. See Table search and filtering.
You can define output tables to appear in this view in a Python DOcplex model using the syntax
outputs['tablename'], see Input and output data.
The Conflicts page shows relaxations and conflicting constraints if these options have been chosen. The optimization engine log file is displayed in the Log page.
For multi-objective models formulated with the Modeling Assistant, the solution table also displays the slider weights and scale factors that were set in the model. The combined objective is the sum of all the objective values (positive additions for minimize objectives and negative for maximize objectives) multiplied by the scale factor (1 by default) and the weight factor. The weight factor is 2 to the power of the slider weight minus 1. For example, a slider weight of 5, the weight factor is 25-1= 24= 16.
In the Solution view, you can also find information about the run status (processed, stopped, or failed) and download run logs.
To run models you must associate a Watson Machine Learning instance with your Watson Studio project. If you have no associated service defined when you try to run a model, you obtain the error "Run FAILED: cannot deploy model to wml". See previous section on Run model view.
When you create a new Decision Optimization model, a scenario is automatically created along with the model. A scenario contains data sets, a model, and a solution.
- Make sure a specific model works with a variety of data
- See how different data sets impact the solution to a given problem
- See how a model formulation impacts the solution to a given problem
The Scenario panel allows you to easily manage different scenarios of a Decision Optimization model.
To open the Scenario panel, click the Manage scenarios button .
- Create new scenarios (create a new scenario from scratch, duplicate your current scenario or import a new scenario from a file).
- Select the scenario you want to work in.
- See existing scenarios and their details (input data, model, solution).
- Manage existing scenarios (duplicate, rename, delete).
- Generate a Python notebook from a scenario.
- Export the scenario as a zip file.
If you export the scenario as a zip file, a scenario.json file is also included in the zip which describes the exported model. If you make changes locally to this scenario (for example you add a table to your model), you can then edit this json file to include these changes and then re-import your scenario and these changes will appear in your scenario.
New scenarios can be imported by choosing From file in the Create Scenario menu and then selecting the zip file containing your new scenario.
You can also use this method to create a new scenario from a debug zip file that you have generated (see Custom Parameters) and downloaded. The debug zip file will provide you with a scenario containing data, model, solution and the run configuration parameters.
You can switch scenarios while running a model and see in the scenario pane which scenarios are running or are queued.