question

Brayan Leonardo Gil Guevara avatar image
0 Likes"
Brayan Leonardo Gil Guevara asked Adrian Haws commented

How to send items to specific output ports

Hi, good afternoon.

I'd like some help. The file attached "samplemodel.fsm" works as follows:

- The Queue 1 has the "Send to Port: 1" (Processor 5).

- If the item stays more than 300 time units at Queue1, the item will be send to Queue2. (In order to do that, it has three Triggers working on Queue1. OnEntry, OnExit, OnMessage).

What I'd like to do is to send the item to the FIRST RANDOM AVAILABLE of the 3 Processors that Queue1 has connected.

What should I do in order to send the items from Queue1 randomly to a list of processors?

FlexSim 16.1.0
FlexSim 7.7.0
listsend to portitem flowrandom listspecific output ports
1.png (168.6 KiB)
queu1.png (14.2 KiB)
samplemodel.fsm (16.9 KiB)
5 |100000

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

Matthew Gillespie avatar image
3 Likes"
Matthew Gillespie answered Brayan Leonardo Gil Guevara commented

I would suggest using a list where the first queue pushes to that list and the processors and the second queue pull items from that list. Here is an example model that shows this method.

In the Queue's Send To Port field it pushes each item to a list.

The processors then pull items from that list using their Pull Strategy field.

Queue2 also pulls from the list, but with a query of age > 300. I had to add a list reevaluation event to the list for the old items to be reconsidered.

Alternatively you could use Process Flow to control the items that time out. Here is an example modell of that.


· 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.

Brayan Leonardo Gil Guevara avatar image Brayan Leonardo Gil Guevara commented ·

Brilliant ! I found very useful your answer. I'm running a larger model, and this "Lists" make things simpler. Thank you so much! I'll stick to it.

0 Likes 0 ·
Adrian Haws avatar image
1 Like"
Adrian Haws answered Brayan Leonardo Gil Guevara edited

There is a drop-down list by Send To Port with several options. It sounds like the best option for what you'd like to do is Random->Random Available Port.

· 2
5 |100000

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

Brayan Leonardo Gil Guevara avatar image Brayan Leonardo Gil Guevara commented ·

Hi @Adrian Haws,

But since Queue2 is connected as an Outport to Queue1, the items will be also send to Queue2. That should only happen when the item has stayed more than 300 time units.

0 Likes 0 ·
Adrian Haws avatar image Adrian Haws Brayan Leonardo Gil Guevara commented ·

Yes, that's true. You just need to go into the General tab of Queue1's properties, select Output Ports, and move Queue2 down to the last rank. Then open the Code Editor for the Send to Port (after you've changed it to Random Available Port) and replace line 10 with the following:

for ( int index = 1; index <= arraysize - 1; index++) {
                    

The only difference is that it will now only send to the first three output ports (since we said arraysize - 1).

1 Like 1 ·
Edward Ellis avatar image
0 Likes"
Edward Ellis answered Adrian Haws commented

Hi @Matthew Gillespie @Adrian Haws I have a quick question.

I want to validate the itemtype and in the case that it has getitemtype(item) == 1 or 2 I want it to go to certain ports. It is working when I state getitemtype(item) == 1 but how do I add to validate for 2 as well?

Do I use commas, or, what do I do to validate the itemtype for both 1 or 2?

Thank you for your help!

Edward Ellis

· 2
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

Edward,

I would suggest asking this as a new question. Your question seems related to the title of the question, but I don't see how it is related to the specifics of the original question. This question has already been marked as answered, and since we prioritize answering questions that haven't been marked as answered yet, you'll be much more likely to get a prompt response. Furthermore, you've asked your new question by adding a new answer to this question, so it doesn't really look like a question.

If in your new question you want to reference this question, you can always provide a link to it and explain how your question is similar or different.

For your reference, here is our page about the best practices for using this site.

Welcome to answers!

1 Like 1 ·
Adrian Haws avatar image Adrian Haws commented ·

@Edward Ellis I reposted this question here, as Matthew mentioned.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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