Decision Optimization notebooks
You can create and run Decision Optimization models in Python notebooks using DOcplex, a native Python API for Decision Optimization. There are several Decision Optimization notebooks already available for you to use.
The Decision Optimization environment currently supports Python 3.7. The Decision Optimization service includes the full CPLEX commercial edition.
- The Sudoku example, a Constraint Programming example in which the objective is to solve a 9x9 Sudoku grid.
- The Balance production of pasta example, a Linear Programming example in which the objective is to minimize the production cost for some pasta products and ensure that the customers' demand for the products is satisfied.
All Decision Optimization notebooks use DOcplex.
DOcplex
The Decision Optimization notebooks use DOcplex, a native Python API for modeling and solving Decision Optimization problems. The API is available by default in Cloud Pak for Data as part of the Python environment.
- Mathematical Programming Modeling for Python using
docplex.mp
- Constraint Programming Modeling for Python using
docplex.cp
from docplex.mp.model import Model
The API is licensed under the Apache License V2.0 and is numpy/pandas
friendly.
You can read the full DOcplex API documentation on rawgit. You can find DOcplex examples on the Decision Optimization GitHub.
Python scenario API
In addition to DOcplex, a scenario API is available for you to create scenarios in Cloud Pak for Data and handle models made in the Decision Optimization model builder. For example, see Generating multiple scenarios (Decision Optimization).
See the dd-scenario-client-python documentation. You can also find the previous example in the jupyter folder of the DO-samples.
Running Decision Optimization notebooks
Download a notebook from the jupyter folder of the DO-samples and run it in Cloud Pak for Data as follows.
- Click Add to project.
- Select Notebook as your asset type.
- Choose From file. Then click Choose file and browse to the notebook on your machine.
- Click Create Notebook. The notebook is added to your project.
If you have not already created a project in Cloud Pak for Data
- Create a new project: select Projects > View all Projects from the menu and click the New Project button.
- Select Create an empty project and in the window that opens enter a name and click Create.
- To create a new notebook, click the Add to Project button and select Notebook.
- Choose From File. Then click Choose file and browse to the notebook on your machine.
- Click Create Notebook. The notebook is added to your project.
To run your notebook, click Cell > Run All.
Example Python notebooks are provided in the Decision Optimization GitHub. To use these, see Jupyter notebook samples. These examples do not use the model builder.
Also a Python notebook that shows you how to generate multiple scenarios using randomized data is provided in the jupyter folder of the DO-samples. This can be useful to test a model made in the model builder with different data sets. See Generating multiple scenarios for how to do this.
Decision Optimization tutorials
You can find more DOcplex examples that will introduce you to the DOcplex Python API on the Decision Optimization GitHub:
-
Linear Programming
You can read the detailed description of this notebook here. You can clone or download this notebook here.
-
Beyond Linear Programming
You can read the detailed description of this notebook here. You can clone or download this notebook here.
-
Getting started with Scheduling in CPLEX for Python
You can read the detailed description of this notebook here. You can clone or download this notebook here.