fladdimir / casymda

Discrete-Event-Simulation based on BPMN and SimPy

Home Page:https://fladdimir.github.io/post/casymda/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Entities stuck in loops

pedrocwb opened this issue · comments

Hey, first of all, thank you for your work in Casymda.

I'm building a system that will contain loops like this:

Screen Shot 2021-09-24 at 11 41 45

But I'm having a problem in which the delay C is waiting for to be free, E is waiting for F, F is waiting for B and B is waiting for C. The entities are stuck in the loop?

Did you have this issue before? Any suggestion on how to fix it?

Hi, yeah that's an interesting question.
Indeed the sketched process can lead to a deadlock, since each block's process could wait for the next block's resource to be free before releasing it's own resource.

One simple idea (you probably already came up with) could be to introduce a kind of "buffer" block (with unlimited capacity) into the loop.
Non-working sample sketch:

loop_with_buffer

Of course it might depend on your actual process whether that would be a suitable solution.

As an extension, you could additionally limit the number of entities cycling in a loop, e.g. to ensure that entities finish their loop before too many new entities are entering the loop. In this example, the number of entities in the inner area is limited to 3 (and the gateways have unlimited capacity and act as buffers here):

gated_loop

(using a "named" resource, which is seized/released when entities are passing through the connected seize/release blocks;
added example: https://github.com/fladdimir/casymda/tree/github/examples/resources_loop )

  • Does this support modelling your problem? Or are there different/custom features that would help?