Bit context on the model I am trying to build-(You can skip to the issue description at bottom)
I am trying to figure out how I can assign tasks from same order to the same resource. i.e. I do not want the tasks to be split among different resources.
1. Tasks from same order can come at different times. For example, Resource 1 could have processed a task for Order 1 and moved to another task for Order 2. If a new task for order 1 arrives, it must be assigned to Resource 1 the next time it is available to accept task
2. Resources accept at least 3 tasks per processing cycle. If 3 task from same order is not available, the resource will try to pull more eligible tasks. Eligible tasks would either be part of an order that was partially processed in that resource earlier or they would be part of orders that were never processed in any other resource.
3. The resource can process less than 3 tasks if there are no eligible tasks available to pull from
Here is my approach and test model-
1. I have a list of tasks that is partitioned by resources. I have an "unassigned partition" for all new orders that were never processed in any resource
2. Resource tries to pull 3 tasks from the task list within its own partition. If it is unable to find the required tasks, it tries to pull from unassigned partition.
3. If tasks from unassigned partition (new orders) were pulled, then I try to pull all the tasks for those orders from unassigned partition and push it back into the partition for respective resources.
Issue I am running into -
I have 3 tokens corresponding to 3 resource trying to pull tasks. The tokens do not find any eligible task in the respective resource partitions of the task list, it then tries to pull task from the unassigned partition. Resource 2 pulls 2 tasks for Order 2 (O2) and the third task is from Order 3 (Task P6). Since one task in order 3 is assigned to Resource 2, all the remaining tasks in O3 also should be assigned to Resource 2. But instead, the token for Resource 3 is able to pull the remaining 3 tasks even though one of the task from order 3 is assigned to resource 2. I checked the Event List and looks like there is a race condition between the token to modify the partition of remaining Order 3 task and the Resource 3 token. These event take place at the same clock time. I tried placing breathe (Delay of 0) at some places but they did not help. Any help is appreciated. Apologies for the long question.
Example model - Task_Assignment_test.fsm
Current output -
Expected Output-
P14 and P15 can either be processed in Resource 1 or on Resource 3
P.S. This question has additional constraints on top of my previous question (https://answers.flexsim.com/questions/137771/assigning-all-task-in-an-order-to-same-resource.html), so asking it in a separate question. @Jason Lightfoot