question

Aditya Prakash avatar image
0 Likes"
Aditya Prakash asked Phil BoBo edited

Assigning SendToPort 0 on a subset of output ports.

Hi, I'm trying to build a model where consignments enter multiple upstream queues(Q3,Q4). As soon as a consignment is completely inside Q3/Q4, a functions looks for a calculated number (N) of processors downstream, which are available (P8,P9,P10,P11,P12) [Available means not processing any other consignment from other queue]. For example if a consignments(C1) gets completed in Q3, and N = 3(based on load). I look up for 4 processors and find 3(P8,P11,P12) successfully. I set their avail_flag = 0 so that no other consignment can use them. Then I releaseitem() all items of C1, and assign port to each item using duniform(1,3). This is a good strategy except that it's not accurate. What I want is that I could only open output port (P8,P11,P12) and assign SendToPort "0" for each item. This way item are free to enter any of the three port, instead of hard coding each item using duniform. But as we know closeip(current, port_num) doesn't work well with discrete events. What should I do ? Is there a better way than dunifrom() ?

PS: Consignment control in Q3/Q4 is achieved by holding item (SendToPort -1) for each entering item and when consignment completes, releaseitem(). For for releaseditems, SendToPort = random port assigned using duniform() .

FlexSim 16.0.1
send to portreleasecloseoutputopenoutputholditem
sample.png (443.4 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.

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Aditya Prakash commented

You could model this logic more easily by using Lists.

Below are some links in the User Manual that introduce Lists. I think if you read these sections, you will be able to figure out how to model your situation more easily than using ports and trying to customize the Send To Port.

List Key Concepts

List Connectionless Routing Example

If you would like an example of how to do this with your consignments as described in your question, please attach your model to the original question so that it can be used as a starting point for demonstrating how to adjust the flow logic.

Attached is a sample model that uses lists to control flow from 2 queues to 5 processors such that each processor does not start working on the next consignment until all of the items from the previous consignment have been pulled from the queues.

This essentially makes a FIFO from both queues as if they were a single queue.

You could do a similar thing in your model where you push each of the items in the consignment to the list once the entire consignment has been received by the queues.


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

Aditya Prakash avatar image Aditya Prakash commented ·

Hi @phil.bobo, I been trying to implement what you have suggested. But here's where I'm stuck. On every processor I have "input_id" label, and I Query Where itemtype = getlabel(current,input_label) on puller. Whenever I look for downstream resource (P1-P4) for a consignment(C1), as soon as I get an idle resource (activity flag), I set it's input_id label to itemtype(C1). Problem is when backorder was created input_id had a default "0" value. But when items are pushed and input_id label is changed on some processor I want Query to be updated so that items can be pulled. How do I do back order reevaluation for every change in "input_id" on puller. Attached is the model, I haven't implemented back order reevaluation in it.testing-hold-release-7.fsm

0 Likes 0 ·
Phil BoBo avatar image
4 Likes"
Phil BoBo answered Phil BoBo edited

You don't need that 170+ lines of code to determine which processors are available. You don't need to manually track the state of the objects using custom labels. The objects can handle this all by default.

You don't need to make assignments to each processor as to what consignment it is currently running. If you push the items to the list, they will be pulled in a first-in-first-out (FIFO) order. So your consignments will automatically be done one at a time by whatever processors are available.

Attached is a modified version of your model (simplified-consignments.fsm) with a simple ProcessFlow that handles all this logic in 5 activities.

How it works

It starts with an Event-triggered Source, which listens for each Queue's OnEntry.

This creates a token for each item in the queues.

These tokens are then batched based on the "consign_qty" label on the items and grouped by itemtype.

Once a full consignment is batched, it is pushed to the list.

Each of the processors pulls from the list without any stipulation in a FIFO manner.


5 |100000

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

Marco Baccalaro avatar image
0 Likes"
Marco Baccalaro answered Aditya Prakash commented

Maybe you could set a label "index" on the items and on the processors too having the same number, then use the "Pull Requirement" on the processor with the option "Specific label" in order to match the label "index" on the item with the label "index" on the processors (getlabel(current, "index")). The index label must be set differently for any consignment (it could be set to the number of outputs of the source).

This will let the first free processor to pull a matching item.

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

Aditya Prakash avatar image Aditya Prakash commented ·

@Marco Baccalaro Thanks! I was paying too much attention on SendToPort logic, that I totally forgot about pull. I generally try to avoid pull as much as possible, because it's not very intuitive if we compare natural way of item flow. (Upstream is generally responsible for routing of items). I just had one more follow up question. How do I force evaluate "Pull from port" ? (See notations)

Say for C1, I needed 4 processor but initially I found 2 idle processors(P1,P3). So I set the "Specific label" on P1,P3 to C1 and then release all items of C1 from Q3. Till now it's all fine. But by using senddelaymessage(), I found another Idle processor(P4) some time later. Now I set the "Specific label" on P4 to C1 as well. But how to force evaluate"Pull from port" P4. Earlier P1,P3 got evaluated because items were released. Now I'm not releasing any Item, they have all been released.

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.