# Adding multi\-concept constraints and custom decisions: shift assignment #

This  Decision Optimization Modeling Assistant example shows you how to use multi\-concept iterations, the `associated` keyword in constraints, how to define your own custom decisions, and define logical constraints\. For illustration, a resource assignment problem, `ShiftAssignment`, is used and its completed model with data is provided in the **DO\-samples**\.

## Procedure ##

To download and open the sample:

<!-- <ol> -->

1.  Download the  ShiftAssignment\.zip file from the  Model\_Builder subfolder in the **[DO\-samples](https://github.com/IBMDecisionOptimization/DO-Samples)**\.  Select the relevant product and version subfolder\.
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 locally to find and choose the  ShiftAssignment\.zip archive that you downloaded\. Click  Open\. Alternatively use drag and drop\.
8.  Associate a **Machine Learning service instance** with your project and reload the page\.
9.  If you haven't already associated a  Machine Learning 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\.
10. Click **Create**\.A  Decision Optimization model is created with the same name as the sample\.
11. Open the scenario pane and select the `AssignmentWithOnCallDuties` scenario\.

<!-- </ol> -->

<!-- <article "class="topic task nested1" role="article" id="task_multiconceptiterations" "> -->

## Using multi\-concept iteration ##

### Procedure ###

To use multi\-concept iteration, follow these steps\.

<!-- <ol> -->

1.  Click   Build model in the sidebar to view your model formulation\.The model formulation shows the intent as being to assign employees to shifts, with its objectives and constraints\.
2.  Expand the constraint `For each Employee-Day combination , number of associated Employee-Shift assignments is less than or equal to 1`\.

<!-- </ol> -->

<!-- </article "class="topic task nested1" role="article" id="task_multiconceptiterations" "> -->

<!-- <article "class="topic task nested1" role="article" id="task_customdecision" "> -->

## Defining custom decisions ##

### Procedure ###

To define custom decisions, follow these steps\.

<!-- <ol> -->

1.  Click   Build model to see the model formulation of the `AssignmentWithOnCallDuties` Scenario\.![Build model view showing Shift Assignment formulation](https://dataplatform.cloud.ibm.com/docs/content/DO/DODS_Mdl_Assist/images/CloudStaffAssignRunModel.png)
    
    The custom decision `OnCallDuties` is used in the second objective. This objective ensures that the number of on-call duties are balanced over Employees.
    
    The constraint ![On call duty constraint](https://dataplatform.cloud.ibm.com/docs/content/DO/DODS_Mdl_Assist/images/StaffAssignOncallDuty.jpg) ensures that the on-call duty requirements that are listed in the Day table are satisfied.
    
    The following steps show you how this custom decision `OnCallDuties` was defined.
2.  Open the  Settings pane and notice that the  Visualize and edit decisions is set to `true` (or set it to true if it is set to the default false)\.
    
    This setting adds a  Decisions tab to your  Add to model window.
    
    ![Decisions tab of the Add to Model pane showing two intents](https://dataplatform.cloud.ibm.com/docs/content/DO/DODS_Mdl_Assist/images/DecisionsTab.jpg)
    
    Here you can see `OnCallDuty` is specified as an assignment decision (to assign employees to on-call duties). Its two dimensions are defined with reference to the data tables `Day` and `Employee`. This means that your model will also assign on-call duties to employees. The Employee-Shift assignment decision is specified from the original intent.
3.  Optional:  Enter your own text to describe the `OnCallDuty` in the  \[to be documented\] field\.
4.  Optional:  To create your own decision in the  Decisions tab, click the  enter name, type in a name and click enter\. A new decision (intent) is created with that name with some highlighted fields to be completed by using the drop\-down menus\. If you, for example, select  assignment  as the  decision type, two dimensions are created\. As assignment involves assigning at least one thing to another, at least two dimensions must be defined\. Use  select a table fields to define the dimensions\.

<!-- </ol> -->

<!-- </article "class="topic task nested1" role="article" id="task_customdecision" "> -->

<!-- <article "class="topic task nested1" role="article" id="task_impliedconstraints" "> -->

## Using logical constraints ##

### Procedure ###

To use logical constraints:

<!-- <ol> -->

1.  Look at the constraint ![Logical constraint suggestion](https://dataplatform.cloud.ibm.com/docs/content/DO/DODS_Mdl_Assist/images/impliedconstraint.jpg)This constraint ensures that, for each employee and day combination, when no associated assignments exist (for example, the employee is on vacation on that day), that no on\-call duties are assigned to that employee on that day\. Note the use of the `if...then` keywords to define this logical constraint\.
2.  Optional:  Add other logical constraints to your model by searching in the suggestions\.

<!-- </ol> -->

<!-- </article "class="topic task nested1" role="article" id="task_impliedconstraints" "> -->

<!-- </article "role="article" "> -->