About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Creating advanced custom constraints with Python
Last updated: Nov 21, 2024
This Decision Optimization Modeling Assistant example shows you how to create advanced custom constraints that use Python.
Before you begin
Shift
Assignment
sample, that is available in the DO-samples, and uses the
AssignmentWithOnCallDuties
scenario. The AssignmentWithCustomRule
scenario in this same sample shows you the completed model with this custom constraint already
added.About this task
The Modeling Assistant provides you with many constraint suggestions for your problem domain which can be customized. You might, however, want to express constraints beyond those that are predefined for the given domains. You can achieve this by using more advanced custom constraints that use Python DOcplex. This example illustrates how you can create these.
Video disclaimer: Some minor steps and graphical steps in this video might differ from your platform. The user interface is also frequently improved.
Read more in this Decision Optimization blog on custom constraints with Python found on the IBM Data Science community page.
Note: To create and run Optimization models, you must have
both a Machine Learning service added to your project and a
deployment space that is associated with your experiment:
- Add a Machine Learning service to your project. You can either add this service at the project level (see Creating a Watson Machine Learning Service instance), or you can add it when you first create a new Decision Optimization experiment: click Add a Machine Learning service, select, or create a New service, click Associate, then close the window.
- Associate a deployment space with your Decision Optimization experiment (see Deployment spaces). A deployment space can be created or selected when you first create a new Decision Optimization experiment: click Create a deployment space, enter a name for your deployment space, and click Create. For existing models, you can also create, or select a space in the Overview information pane.
Procedure
To create a new advanced custom constraint:
Was the topic helpful?
0/1000