question

Shinya O avatar image
0 Likes"
Shinya O asked Jeanette F commented

Open/Close input port behavior

Hi,

I would like to understand Open/Close port, so I created a red, green and blue production line model.

In my guess, these production lines should end up with 60 flow items arriving in Queue3, but the red one is 31, the green one is 60, and the blue one is 59. Why is this?

Thanks in advance.

Open_Close_Input_Port.fsm

1669615707089.png


FlexSim 22.0.4
portsclose and open ports
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Shinya O, was Logan Gold's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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.

0 Likes 0 ·

1 Answer

Logan Gold avatar image
0 Likes"
Logan Gold answered Logan Gold edited

This does appear to be a bug.

When the On Exit trigger fires on Processor2 in the red and blue areas, openinput() is executed (because the condition is true), and the processor's input ports are opened. However, flowitems start to enter the processor even before On Exit finishes executing. For Processor2 in the green area, items don't begin to enter the processor until after On Exit finishes. This is true even when you increase the processing time to give the second batch of items long enough to enter Queue2.

As @Felix Möhlmann mentioned, having only one item enter Processor2 in the red area is strange. It makes sense that 29 items enter in the blue area, since there is technically still one item in the processor during the On Exit trigger. I'm not sure what the difference is between the two.

Whatever the case, I'm guessing the general issue has something to do with the normal logic that controls input and output ports on Fixed Resources and Task Executers (https://docs.flexsim.com/en/22.0/ConnectingFlows/Ports/KeyConceptsPorts/KeyConceptsPorts.html#open). However, I haven't been able to dig into it enough to know if that is the case.

I will send a bug report to the developers to help sort it out. For now, you will just need to follow one of the workarounds that Felix mentioned in their comment.



The original answer was deleted where Felix had commented, so here is the content of that comment:


There might be some confusion here based on the title of the post? They are using the default trigger pick option "Close and Open Ports" which use closeinput(), openinput(), closeoutput() and openoutput(), which, while deprecated, are valid commands and do (to my knowledge) the same as using the property.


This seems like a timing issue/bug with things happening in the wrong order. Though the "red" case in which only a single item enters the processor seems particularly weird.


As a workaround you can shift the trigger that opens the output to the next downstream object: Opening when the 30th item has entered the queue, rather than when it is about to leave the processor.


Alternatively, send a message with a delay of 0s to the processor in its exit trigger and open the input in the On Message trigger. That way, all items will have left the processor before new ones can enter.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.