& Construction

Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
& Manufacturing

Professional CAD/CAM tools built on Inventor and AutoCAD
Integrated BIM tools, including Revit, AutoCAD, and Civil 3D
Professional CAD/CAM tools built on Inventor and AutoCAD
[ FlexSim 21.2.3 ]
Hi,
Is there any way to force the patients to leave the model after 5 PM other than creating several decide activities and locate them before/after some set of activities with this code in it:
Model.dateTime.hour<8 || Model.dateTime.hour> 16
The problem with this method is that tokens are stuck in the activity during the transition to off-schedule hours and will not leave the model. I was looking for an approach to trigger "left without being seen" unless the patient is in the process of MD visitation.
Thanks!
Solved! Go to Solution.
You can use the "Release Token" activity to achieve this.
In the attached example, each patient token creates a child token. This child token will wait for its parent token to acquire an MD. Before it enters the "Wait for Event" activity, it is assigned a label that is used as the maximum wait time in the activity and coincides with the start of the off-schedule hours. In the example that time is 9:00AM.
If no staff has been acquired at that time, the child token will be released through the second connector and enter the "Release Token" activity. This is set to release the parent from whereever it is (in the example this will be the acquire activity) to the last two activities in the main flow (walk and remove patient).
If the parent token that gets released might have already acquired some resource (staff/location/equipment), you would have to check for the respective label and route it through the corresponding release activity before removing the patient.
In the example model, the wait time also could have been used in the "Acquire Staff" activity directly, with a second connector leading to the end of the main flow. The advantage of using the "Release Token" activity is that the parent token can be moved regardless of its current position in the flow.
Thanks, @Felix Möhlmann Somewhere you mentioned that:" If the parent token that gets released might have already acquired some resource (staff/location/equipment), you would have to check for the respective label and route it through the corresponding release activity before removing the patient." How can I do that? I see some tokens stuck in the "Acquire Staff" activity?
Also why the event should be "On Exit"?
It's normal for tokens to accumulate in the "Acquire Staff" activity, since the example model was purposefully build that way to showcase the "Release Tokens" activity. (More patients arrive than can be processed)
What I meant with the highlighted text is that, if you send a token to the end of the flow, potentially skipping activities that would release resources (staff, equipment, location), that resource would stay acquired forever and eventually the model would become stuck. You can check whether the label of a given name exists with "patient.labelname?".
By using this in a decide activity, you can check for any acquired resources, and route the token through the respective "Release" activity to free it up again, before removing the patient.
I altered the example by expanding the process a bit and releasing tokens from a second acquire activity as well. To do this I simply create a new child token, before the main token enters that second acquire activity. I also added a second event to the "Wait for Event" to listen for the exit out of the second acquire activity.
I chose "On Exit" because the token child token waits for one of two possibilities: Either the wait time elapses and the parent token is moved to the end of the process flow. Or the parent token has reached a position in the flow, where a premature release is no longer wanted/needed. This is the case once the parent token has acquired a resource (thus "On Exit") and is now being processed.
Releasing them from an ongoing process is more difficult, because you would have to manually delete any pending events associated with the process. Otherwise FlexSim will show errors when those events come due and the corresponding patient doesn't exist anymore. I would recommend against releasing the tokens from anything but an acquire activity.
Instead of reusing the same flow, you can of course also make copies of the "Release by schedule" flow for each position you want to release tokens from.
Could you possibly post a screenshot of the relevant section(s) of the patient flow?
Some troubleshooting possibilities:
- The max. wait time is only exact to one second. That's why I placed a 1-second delay after the acquire activity: to prevent a token from acquiring a resource, that was just released by another patient, and entering an activity, before the child token releases it. (You can make the max. wait time more accurate by adding "Model.datetime.millisecond*0.001) to the calculation. Then a delay of 0.001s should suffice.)
- Are you only releasing tokens that are currently waiting in an "Acquire X" activity? As I mentioned in my previous post, I wouldn't recommend releasing/aborting tokens from an active process, such as an escort task.
I won't be able to see a private question, but if you link to this post for context, the US support staff will likely be able to help you with your problem.
Hi @Maryam H2, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.
If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.
How to buy
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © 2025 Autodesk Inc. All rights reserved
Type a product name