0 / 0
Sample models and notebooks for Decision Optimization
Last updated: Nov 21, 2024
Decision Optimization sample models and notebooks

Several examples are presented in this documentation as tutorials. You can also use many other examples that are provided in the Decision Optimization GitHub, and in the Resource hub.

Decision Optimization GitHub DO-samples

See Decision Optimization GitHub for a repository of samples for use with IBM watsonx.ai. For Decision Optimization experiment UI samples, see the following section Decision Optimization experiment UI samples. This repository also contains Jupyter notebook samples that can be imported into watsonx.ai. See Jupyter notebooks.

Java example

See the Java model example provided in the Decision Optimization Java™ worker boilerplate in the Java worker GitHub.

Examples described in this documentation

The following table lists example models that are described in this documentation, and that show you how to use Decision Optimization.

Table 1. Decision Optimization documentation examples
  Examples

Learn how to ...

See

Create scheduling models by using the Modeling Assistant.

House Construction example

  • Create, edit, and solve a planning and scheduling model with the Modeling Assistant.
  • Create and examine different scenarios.

Solving a model using the Modeling Assistant

Create Python optimization models by using the Decision Optimization experiment UI.

Diet example

  • Create and solve a Python model that is generated from an existing scenario.
  • Create and examine a new scenario.

Solving a Python DOcplex model

Multiple scenario example

  • Create a Python model from a Python notebook imported into Decision Optimization and solve it.
  • Generate multiple scenarios from a Python notebook by using randomized data.
  • Export tables from scenario.

Working with multiple scenarios

Create or import DOcplex Python notebooks.

Decision Optimization notebook examples

  • Download a notebook and add it to a project.
  • Run a notebook.

Running Decision Optimization notebooks

Decision Optimization experiment samples (Python, OPL, Modeling Assistant)

For a step-by-step guide to build, solve and deploy a Decision Optimization model, by using the user interface, see the Quick start tutorial with video.

The following table lists the Decision Optimization samples that are provided in DO-samples in the Decision Optimization GitHub. All these assets use the Decision Optimization experiment UI and contain data.

Note:

To run models, you must associate a watsonx.ai Runtime instance with your Project and associate a deployment space with your Decision Optimization experiment. You must also have the Editor or Admin role in the deployment space.

To use these samples:
  1. Download and extract all the DO-samples on to your computer. You can also download just the one sample, but in this case, do not extract it.
  2. Open your project or create an empty project.
  3. On the Manage tab of your project, select the Services and integrations section and click Associate service. Then select an existing Machine Learning service instance (or create a new one ) and click Associate. When the service is associated, a success message is displayed, and you can then close the Associate service window.
  4. Select the Assets tab.
  5. Select New asset > Solve optimization problems in the Work with models section.
  6. Click Local file in the Solve optimization problems window that opens.
  7. Browse to the Model_Builder folder in your downloaded DO-samples. Select the relevant product and version subfolder. Choose your sample .zip file and click Open. Alternatively drag the sample into the window.
  8. If you haven't already associated a watsonx.ai Runtime service with your project, you must first select Add a Machine Learning service to select or create one before you choose a deployment space for your experiment.
  9. Click New deployment space, enter a name, and click Create (or select an existing space from the drop-down menu).
  10. Click Create.

    A Decision Optimization model is created with the same name as the sample.

Table 2. Decision Optimization Models
Models for Decision Optimization Problem type Model type
BridgeScheduling Scheduling Modeling Assistant
Diet Blending Python
DietLP Blending LP (CPLEX)
EnvironmentAndExtension Using an environment with an extension that contains a library file and YAML code. Python
HouseConstructionScheduling Scheduling with assignment Modeling Assistant
IntermediateSolutions Enabling intermediate solutions for CPLEX and CPO models Python
MarketingCampaignAssignment Resource Assignment (Scenarios 1 - 4)

Selection and Allocation (Scenario 4 - Selection)

Modeling Assistant
Multifiles Using a model with multiple files. Python and LP
PastaProduction Production OPL
PortfolioAllocation Selection & Allocation Modeling Assistant
PythonEngineSettings Geometrical puzzle with customized engine settings Python
ShiftAssignment Resource Assignment with custom decisions and a custom constraint Modeling Assistant
StaffPlanning Multi-Scenario Planning

(to be used with CopyAndSolveScenarios.ipynb)

Python
SupplyDemandPlanning Supply & Demand Planning Modeling Assistant
TalentCPO Movie scheduling CPO (CP Optimizer)

Jupyter notebook samples

Jupyter notebooks are also provided in the Decision Optimization GitHub that do not use the experiment UI. To use these Python notebook samples :
  1. Download and extract all the DO-samples on to your computer. You can also download just one sample.
  2. Open your project or create an empty project.
  3. Select the Assets tab.
  4. Select New asset > Work with data and models in Python or R notebooks in the Work with models section.
  5. Select the From file tab in the new window that opens.
  6. Name your notebook, click Drag and drop files or upload and browse to the notebook in the jupyter folder in your downloaded DO-samples. Select the relevant product and version subfolder.
  7. Click Create. The notebook is added to your project.

Python notebooks in the Resource hub

Decision Optimization Python notebooks are available from the Resource hub. To use these notebooks in an existing project, open a notebook in the Resource hub, click Add to project, select your Project, and click Create.

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more