Changing default environments and adding Python extensions for additional Python libraries
You can change the default environment for your experiment from the Overview tab. For example, you can change the Python version or CPLEX version that is used by default. You can also create a new environment and add more Python libraries by using a new Python extension.
Before you begin
- Required permissions
- To view environments, you can have any role in a deployment space. To edit or create environments, you must have the Editor or Admin role in the space. For more information, see Deployment space collaborator roles and permissions.
About this task
When you use the Decision Optimization experiment UI, the necessary environments are created for you automatically. However, you might want to configure your environment to use a particular version of Python, hardware, CPLEX or use Python extensions. You can configure the environment to be used for your solve, by changing the default environment. This environment is then applied to all scenarios in your experiment, when you click Run.
The environment depends on your model type: Python, OPL, CPLEX, CPO, or Modeling Assistant. Python is used to run Decision Optimization models formulated in DOcplex in both Decision Optimization experiments and Jupyter Notebooks. Modeling Assistant models also use Python because DOcplex code is generated when models are run or deployed. Models that are formulated in OPL or in specific file formats for CPLEX or CP Optimizer, such as LP or CPO formats, do not use Python environments.
The Decision Optimization environment currently supports Python 3.11 and 3.10 (deprecated). The default version is Python 3.11.
Python versions are regularly updated. However, if you have explicitly specified an older Python version in your model, you must update this version specification or your model will no longer work. You can either create a new Python environment or edit one from Manage experiment environments.
Updating your environment is also useful if you want to select a different version of CPLEX for your
default environment. As CPLEX engine performance improves with each new version, older versions are
deprecated and removed over time. Runtimes, based on these engines, are used in building and
deploying Decision Optimization models. Currently, the do_22.1
runtime, based on CPLEX 22.1 is used automatically when
you create and run scenarios. The do_20.1
runtime
based on CPLEX 20.1 is also available.
This video provides a visual method to learn the concepts and tasks in this documentation.
After you load the example in your Decision Optimization experiment, you can follow the video.
Video disclaimer: Some minor steps and graphical steps in this video might differ from your platform. The user interface is also frequently improved.
The following procedure shows you how to change the default environment for DOcplex and Modeling Assistant models. Changing the default environment can be useful for checking if your model works with the latest version of CPLEX, or for testing your model with larger data sets that require more hardware. Or perhaps you need to update the Python version or want to include some particular Python libraries using Python extensions.
Procedure
To change the default environment for DOcplex and Modeling Assistant models:
Results
Example
See the EnvironmentAndExtension example in the Model_Builder folder of the DO-samples in the Decision Optimization GitHub. This example uses an environment with an extension that contains a library file and YAML code.