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.
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
- Requirements
- To edit and run Decision
Optimization models, you must have the following prerequisites:
- Admin or Editor roles
- You must have Admin or Editor roles in the project. Viewers of shared projects can only see experiments, but cannot modify or run them
- watsonx.ai Runtime service
- You must have a watsonx.ai Runtime service that is associated with your project. You can add one when you create a Decision Optimization experiment.
- Deployment space
- You must have a deployment space that is associated with your Decision Optimization experiment. You can choose a deployment space when you create a Decision Optimization experiment.
Open any Decision
Optimization model in the Decision
Optimization
Modeling Assistant. This example uses the
sample, that is available in the DO-samples, and uses the
Shift
Assignment
scenario. The AssignmentWithOnCallDuties
scenario in this same sample shows you the completed model with this custom constraint already
added.AssignmentWithCustomRule
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.
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.
Read more in this Decision Optimization blog on custom constraints with Python found on the IBM Data Science community page.
Procedure
To create a new advanced custom constraint: