Chua X2 avatar image
Chua X2 asked Felix Möhlmann commented

Queue logic

Hi all,

FYI, the red and green item will go through 3 phases: green processor -> pink processor -> yellow processor. At most of the "out queues" (blue), the priority of the port connection is always the "in queue" within the same tower. If no queues are available, the robots will send the item to "BF for PMIC" queue.

The blue item will go through only 2 phases: green processor -> yellow processor. If no "in queues" are available, send the item to "BF for RF" queue.

My current model right now is sending first available for the el and pmic out queues ( see the code at those queues). I want to modify code at those out queues to be sent to the shortest queues if available queue but I am not sure how. Right now I am just doing the port rankings based on distance and I am not sure if it is also performing the same way as the shortest queue if available.

Finalised Current state model.fsm

FlexSim 20.1.3
queuesimulationmodelflow itemsshortest queue if available
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
There is a picklist option in Send To Port function in 3D property pane called shortest queue If available. If you select it, you can open the source code editor over the „parchment roll“ icon. Then you can see, how previously developer has solved this problem.
0 Likes 0 ·
Ryan Clark avatar image Ryan Clark commented ·

Hi @Chua X2, 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.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
Felix Möhlmann answered Felix Möhlmann commented

"Shortest Queue" sends the item to the queue with the least currently in it. Since all of your queues have a maximum capacity of 1 this setting wouldn't actually do anything, since the queues with an item in them aren't available anyway.

To send the items to the closest queue (by distance) ordering the ranks of the connections should be enough to achieve that with the current logic.

If the positions of the queues might change often, you can use code like the following to send to the closest available regardless of ranking.

int bestindex = 0;
double closest_dist = 999999;
for(int index = 1; index <= current.outObjects.length; index++)
    if(opavailable(current, index))
        Vec3 dist_vec = current.outObjects[index].getLocation(0.5, 0.5, 0) - current.getLocation(0.5, 0.5, 0);
        double dist = dist_vec.magnitude;
        if(dist < closest_dist)
            closest_dist = dist;
            bestindex = index;

// Return closest available queue
return bestindex;
· 7
5 |100000

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

Chua X2 avatar image Chua X2 commented ·

Hi @Felix Möhlmann , thank you! I also noticed that despite ranking them the nearest distance, the robots placed the flow items at the furthest input queue but second pick, it went to the nearest queue. Is this a flexsim bug?

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Chua X2 commented ·
Can you upload your current model and say at what model time you observe this? It's difficult to say what might be going wrong from just your description.
0 Likes 0 ·
Chua X2 avatar image Chua X2 Felix Möhlmann commented ·

Hi @Felix Möhlmann , as mentioned above, I did port rankings by nearest distance to make the closest queue if available logic. At 173s, this is the first time when both robots will pick the flow items at the input station queue and place the flow items on the input queues in front of the EL processor but they went for the furthest queue. After that, they went for the nearest queue which is correct. Why did the first time both robots go for the furthest queue?

Current state model - fix max.fsm

0 Likes 0 ·
Show more comments
Ryan Clark avatar image Ryan Clark Chua X2 commented ·

Hi @Chua X2,

In the future, please write any replies to answers as comments instead of separate answers. That helps to keep things organized. Please see Best practices for using this Answers site - FlexSim Community for more details. Thanks!

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.