question

Vanessa Buen Abad avatar image
0 Likes"
Vanessa Buen Abad asked Sam Stubbs commented

Problem in round robin

Hello

I have a problem in a model. The general idea is a source2 creating pallets and filling 4 random racks. Then another source1 creating orders (boxes) with a label "NumPallets" which tells the number of pallets (1 minimun or 2 maximum) of the order. This created order goes to a separator in which the boxes are split by the number of pallets (if the number of pallets is 1 it creates 1 box but if it is 2, 2 boxes are created). Then this boxes goes to a queue with an onEntry trigger with this code:

int rnd=0;
treenode yourRack1= centerobject(current, 1);
treenode yourRack2= centerobject(current, 2);
treenode yourRack3= centerobject(current, 3);
treenode yourRack4= centerobject(current, 4);

rnd=duniform(1,4,0);

if (content(yourRack1)>0) {
	if (rnd==1) {
		openoutput(yourRack1);
		closeoutput(yourRack2);
		closeoutput(yourRack3);
		closeoutput(yourRack4);
	}
}

if (content(yourRack2)>0) {
	if (rnd==2) {
		openoutput(yourRack2);
		closeoutput(yourRack1);
		closeoutput(yourRack3);
		closeoutput(yourRack4);
	}
}

if (content(yourRack3)>0) {
	if (rnd==3) {
		openoutput(yourRack3);
		closeoutput(yourRack2);
		closeoutput(yourRack1);
		closeoutput(yourRack4);
	}
}

if (content(yourRack4)>0) {
	if (rnd==4) {
		openoutput(yourRack4);
		closeoutput(yourRack2);
		closeoutput(yourRack3);
		closeoutput(yourRack1);
	}
}

The code generates a random number from 1 to 4 and depends on this number is the center port which opens and the others close. On each of the racks there are 2 triggers on exit and on reset which close all ports if the condition is true.

The idea is when a box enters to this queue1, a pallet from the racks have to go out to the queue2. At the end the total number of boxes in queue1 (pallets orders) must be the same of queue2 (real pallets that have to go out).

It happens when the interarrival time of the pallets is like 30 secs (forum-1-ok.fsm) but does not happens when the interarrival tiem of the pallets is like 200 secs or more (forum-2-ng.fsm). Maybe it can be solved by substituting my code with a "round robin if available" code but I really do not understand it.

Can you help me please? I attached the two models. Thank you so much

forum-2-ng.fsm

forum-1-ok.fsm

Choose One
routinground robinflowitem routing
forum-1-ok.fsm (18.2 KiB)
forum-2-ng.fsm (18.4 KiB)
forum-1-ok.fsm (18.2 KiB)
· 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.

Vanessa Buen Abad avatar image Vanessa Buen Abad commented ·

Okay I understand. Thank you so much

One more question please! Let's suppose at the end of the model I want queue1 to have the same content of queue2, I must have interarrival time too high and I dont need to pull the pallets from the racks with 25% of probability. I just want queue1 to have the same content of queue2 no matter from which rack the queue2 pulls it.

Is there a easier code to put on that onEntry trigger?

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Vanessa Buen Abad commented ·

If you open the output of the racks, the queue1 starts to pull items as it is ruled in the Pull by Requirement function. You have to write a code or build a ProcessFlow that overrules the standard requirement and pulls the items with same features stored as in the queue2 at an event at the end of the simulation run. This event can be a delayed message or a user event. In the OnMessage trigger, for example, you initiate the pulling of item through a loop which tests if the rack item matches the item of the queue2. The commands are holditem in combination with pullitem. You find both in the command manual. Or you write in the pullrequirement the testing procedure which starts if the simulation time is near the end or label value is changed for this purpose.

All items you want to hold in the rack are getting the return value of 0 the items being pulled a value of 1. But you must compare each item in the Pullrequirement with the stored items in the queue1 and exclude the successful tested items in the queue from any other testing or comparing. You can achieve this by setting a new label on those items.

0 Likes 0 ·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Sam Stubbs commented

The Entry Trigger does not fire if you need an object. There are two different methods Flexsim works at all. Push by Send To and Pull by Pull From. Only if an item moves by those two functions a trigger fires. In the way of opening and closing the output you limit the time an object can move items by pull or push method. You don't initiate the move at all. If there isn't an released or pulled item in the time the rack has an open output, no item moves. As @Jeff Nordgren has already described your approach works only if all your racks store enough items and their dwell times had been finished. Your approach let fill up the racks instead of making them empty. You have to wait until the racks are storing enough items. Then you have to wait until the random number generator opens a rack's output at the event of entering the queue which fills the following racks. But if all stored items are ready for release in this rack, all items go to next objects if the capacity to receive those items match the number of items that have been released. Or another entering item in the queue which fills the racks closes the output again and opens another rack which isn't empty.

If you want that at every entering event in the queue a rack releases at least an item there has to be items to be released and the output of the populated rack has to be open. You can close the output of the rack right after an item has left or you define some conditions when the output is closed again.

I think your current approach works well as it is but you have to wait long periods to see racks to release items. This becomes even more true as you control more racks this way.

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

Vanessa Buen Abad avatar image Vanessa Buen Abad commented ·

Yes thank you so much for answering. I got it, but that's why I want a round robin if available code in the onEntry trigger of the queue because if there is no pallet in rack 1 for example, I need to look for a pallet in the other 3 racks to satisfy the demand.

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel commented ·

Back to your current problem to release in round robin fashion. That won't work better than your current method. First you choose a random rack to release items, then the rack must store at least one item, then the rack must be the rack which is the next in the order of racks which released last time an item.

Instead I would insert a variable, which stores the center port number of the rack that has got content. This variable is initiated with the value "0". If the random chosen statement becomes true the variable is set to "-1". At the end of your source code there are three scenarios possible defined in this variable. The variable is greater than 0 you have at least inside of a rack content and the last rack that has got content is connected to the center port with the number of the variable's value. The variable is lower than 0 then the standard approach works. The variable is 0 then the racks are empty.

You can alter this method if you store the rack's center port number in an integer array if the rack has got content. After all the content tests you have a filled array of possible racks that can release items. Now you begin to choose a random center port number out of the numbers of fields of the array.

	duniform(1, arraysize(var array))

Then you close the output of all racks and you open the output of the random chosen rack by its center port connection.

The next step is to enhance the possibility of the racks, which have got content, but their output haven't been opened. You store the array for example in a label reduced by the field that has been chosen. You initiate the new array of the Entry trigger with this stored array from the label. The array becomes bigger at each event, but the racks which have got content over more entering events are more often in the array and their chance to be chosen becomes greater.

There are existing more methods to chose the rack which should open its output, but that's your decision to implement.

0 Likes 0 ·
Jeff Nordgren avatar image
2 Likes"
Jeff Nordgren answered

@Vanessa Buen Abad,

I don't believe that the problem is with your code, per se. What I believe is happening is that when the interarrival time for the pallets is set low, there is always a supply of pallets in the racks to be sent to Queue2. But when the interarrival time for the pallets is set too high, then when a pallet is supposed to be sent to Queue2 but there isn't one in the rack to be sent, it just gets ignored and no pallet gets sent to Queue2.

As long as there is a supply of pallets in the racks, your model will work fine. If the racks are being "starved", then no pallet(s) will be sent to Queue2, which accounts for the difference in numbers that you are seeing. I hope that made some sense?

5 |100000

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

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.