Queue logic

Queue logic

xinyan_chua188
Participant Participant
243 Views
10 Replies
Message 1 of 11

Queue logic

xinyan_chua188
Participant
Participant

[ FlexSim 20.1.3 ]

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

0 Likes
Accepted solutions (1)
244 Views
10 Replies
Replies (10)
Message 2 of 11

joerg_vogel_HsH
Mentor
Mentor
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
Message 3 of 11

moehlmann_fe
Enthusiast
Enthusiast
Accepted solution

"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;
0 Likes
Message 4 of 11

ryan_c10
Not applicable

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
Message 5 of 11

xinyan_chua188
Participant
Participant

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
Message 6 of 11

moehlmann_fe
Enthusiast
Enthusiast
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
Message 7 of 11

xinyan_chua188
Participant
Participant

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
Message 8 of 11

moehlmann_fe
Enthusiast
Enthusiast

Each item the robots pick up at that point have their own task sequence. Whether or not a task executer can "acquire" mutiple task sequences at the same time is determined by the "Break To" setting. For example, setting it to "Same Load Station" would mean, after loading the first item, only task sequences that originate from the same object could be assigned to the robot.

Each task sequence that is acquired that way will move in front of the previous sequence so the robot first picks up all items, then delivers them. This has the side effect, that the items are unloaded in the opposite order they are loaded in. The item that is loaded first is indeed unloaded at the nearest queue, it just happens as the last action.

Other than the first unload happening slightly later, this shouldn't have a large effect. The total time for all deliveries should be the same either way. I also don't know of a good way one might reverse the unloading order in this case.

0 Likes
Message 9 of 11

ryan_c10
Not applicable

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
Message 10 of 11

xinyan_chua188
Participant
Participant
Hi @Felix Möhlmann the model works well now. thank you so much for the help !
0 Likes
Message 11 of 11

moehlmann_fe
Enthusiast
Enthusiast
That's great to hear! Always happy to help.
0 Likes