Randomized Round Robin

Randomized Round Robin

maksymilian_jaworski
Not applicable
177 Views
2 Replies
Message 1 of 3

Randomized Round Robin

maksymilian_jaworski
Not applicable

[ FlexSim 7.5.4 ]

Hello

Background: New conveyors with one input and multiple outputs (as you can see in the picture). At the beggining (on the right) you have decision point which is connected with 20 different decision points (in 'output' conveyors)

228-13318420-1095942283805621-102563879-n.png

What I need is sending items quite randomly, but 'not too much' so they will not stop the system. I am looking for something like round robin, but with each round it would change the order of 'outputs'. For example let say that we have 5 outputs:

1st round - sending item to port 1, 2, 3, 4, 5 2nd round - sending item to port 2, 3, 5, 1, 4 3rd round - sending item to port 5, 3, 1, 2, 4

Ports can be chosen randomly, as long as I will not have situation when I am waiting at one port very long for item, while it has sent 5 items in a row to a different one.

I've tried some statistical distributions (e.g. normal, uniform, multiple bernoulli) and none of them has worked. Also, in decision points there is no option 'Round Robin' in Send Item in trigers.

Thanks in advance for your help

Accepted solutions (1)
178 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

242-randomroundrobin.gif

In the attached model I have two different solutions to this.

Code in On Arrival Trigger

I added a portOrder label to the decision point and generated a randomized list of port numbers. The list is randomized using the algorithm mentioned in this question. Whenever an item arrives it pulls off the last number, unless there are no more, then it generates a new list.

/**Send Item*/
treenode portOrder = label(current, "portOrder");

//Generate the random list of ports if the list is empty
if(!content(portOrder)) {	
	int counts = nrop(current);
	int dummy = 0;
	intarray numset = makearray(counts);

	//Create a {1,2,3...10} array.
	for (int i = 1; i <= counts; i++)
		numset = i;

	//Randomize array
	//For each number i swap numset and numset and 
	//j is a random index between 1 and i.  
	for (int i = 1; i <= counts; i++){
		int j = duniform(1, i);
		dummy = numset;
		numset = numset;
		numset = dummy;
	}
	
	//Add randomized numbers as subnodes of my portOrder label
	for (int i = 1; i <= counts; i++){
		treenode subnode = nodeinsertinto(portOrder);
		nodeadddata(subnode, DATATYPE_NUMBER);
		set(subnode, numset);
	}
}

//Pull off the last subnode
int nextPort = get(last(portOrder));
destroyobject(last(portOrder));

//Send the item to the port number I just pulled off
treenode newDest = outobject(current, nextPort);
conveyorsenditem(item, newDest);

Process Flow

This time I used Process Flow so there's very little code. Similar to the other solution I have an Event Triggered Source that is listening to the On Arrival event of the decision point. The token tries to pull something off the list, but if it can't (because it's empty) it regenerates the list. A Create Tokens activity creates a new token for each output port and assigns it two labels: 1 - it's port number and 2 - a random number. These tokens then push themselves on the Order List. When a token representing an item pulls from the list it uses an SQL query to order the entries on the list by their second label (some random number). This way you pull off a random number.

237-randomlistpf.png



Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

maksymilian_jaworski
Not applicable

Thank you very much for help, it works perfectly now