question

Pieter Cecat avatar image
0 Likes"
Pieter Cecat asked Pieter Cecat commented

dempirical shows variability

Hi everyone, Hi @steven.hamoen

I am using the 'dempirical' function to distribute items from one queue over 5 other queues according to a distribution. I defined 5 scenarios, each of which have a unique way of distributing the items across the 5 queues. However, the items are not precisely distributed according to any of the 5 defined scenarios. I read that the distribution works fine, i.e. accurate, only if you create a mass of items e.g. 10000. If you have a relative small number of items, which is the case for me, the distribution behaves as a random distribution does. There is always a deviation.

My question is if there is a way of having the exact proportions distributed over the queues once a scenario is selected.

My "SCENARIOS" table defines 5 possible scenarios and looks like this:

I am using the function as follows in my triggers:

>>> to get a scenario according to the table above

>>> to get the table of the scenario that occurred in order to distribute my items according to that table (see table below for example scenario 2)

EXAMPLE: if scenario 2 occurs and the number of items to be distributed is 100, then the items should be exactly distributed as follows:

  1. Grade1 = 5
  2. Grade2 = 10
  3. Grade3 = 20
  4. Grade4 = 25
  5. Grade5 = 40

Thanks for your help!! Appreciate it :)

FlexSim 16.0.9
queuerandomdempirical
vppwi.png (1.8 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.

1 Answer

Steven Hamoen avatar image
1 Like"
Steven Hamoen answered Pieter Cecat commented

@Pieter Cecat Are the numbers you want to distribute known upfront? If not, this is quite complex. How are you going to send 25% of 103 to a certain port?.

· 8
5 |100000

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

Pieter Cecat avatar image Pieter Cecat commented ·

Yes they are! In fact, they are always multiples of 20 (e.g. 20, 40, 60...), so I guess it should be possible to precisely distribute the items over the 5 queues given a distribution is selected.

Thanks Steven for your time. Again.

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

Hi @Pieter Cecat,

In that case I would have a simple table with the amounts for each port and subtract 1 when you send out through that port and when it reaches 0 you take the next port.

0 Likes 0 ·
Pieter Cecat avatar image Pieter Cecat Steven Hamoen commented ·

Sorry @steven.hamoen I think I am not explaining it properly. It is a bit more complicated than that. Items are created and pushed to a Global List which I linked (using Process Flow) to the queue from which I want to distribute, let's call it the "distributor queue".

I have also defined a table (called "GRADING") with the quantities that need to be distributed every month (I change these values for different experiments), recall they are multiples of 20.

The Process Flow then moves the quantity defined in the table "GRADING" from the Global List to the "distributor queue", which then immediately distributes the items according to the selected scenario (which is chosen using 'dempirical'). The items are thus at no time in the queue (they just pass through it when being moved from the Global List to one of the 5 other queues).

In other words, I cannot create a table which multiplies the quantity to be distributed with the probability for each queue as I do not know in advance which scenario will be selected (recall that each scenario has a unique distribution).

Thanks for your help, strongly appreciated as usual!

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen commented ·

@Pieter Cecat You are contradictory yourself. "The items are thus at no time in the queue" vs "the they just pass through it" When they pass through they are in the queue. The big question here is if the send to port is used to send the items to the 5 queues? Because if they are you can use my solution and on the send to port you can write something like:

if( gettablenum("aTable", 1, 1) > 0)
{
	settablenum("aTable", 1, 1, gettablenum("aTable", 1, 1) - 1 );
	return 1;
}
elseif( gettablenum("aTable", 2, 1) > 0)
{
etc..
 

So let me know why this cannot work

0 Likes 0 ·
Pieter Cecat avatar image Pieter Cecat Steven Hamoen commented ·

My apologies, that was contradictory.

Send to Port is indeed used. In the onEntry trigger of the queue I use 'dempirical' and set the itemtype for the incoming items. The items are then (immediately) send to each port by expression (itemtype).

2 remarks:

1/ If I apply your method, do I need to remove the 'dempirical' and set itemtype in my onEntry trigger? And how can I make sure that port 1 returns itemtype 1, port 2 itemtype 2 etc...(with different colors)?

2/ If I apply your method, will I have to define 5 tables, one for each possible scenario s and manually calculate the numbers to be entered (= itemtype probability under scenario s * quantity) with the rows corresponding to ports (port1, port2 etc...) and the columns corresponding to months (month1, month2 etc...)?

Thanks!!

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen Pieter Cecat commented ·

@Pieter Cecat

1. to set the itemtype and color just expand the code

if( gettablenum("aTable", 1, 1) > 0)
{
	settablenum("aTable", 1, 1, gettablenum("aTable", 1, 1) - 1 );
	setitemtype(item, 1);
	setcolor(item, 1, 0, 0); (i'm not sure to enter 0-1 or 1-255 )
	return 1;
}

2. That sounds right. You could use excel to calculate everything and copy paste it into Flexsim or do the calculations in Flexsim. Your column number would be the month in the above code and the table can be constructed in the same as described in your own post.

1 Like 1 ·
Pieter Cecat avatar image Pieter Cecat commented ·

Hi @steven.hamoen

I tried to do as you said (created 5 new tables, one for each scenario) but I must have made a small error as only 1 queue (the first one) is used for distributing the items (see table 'GRADING PROCESS"). I attach the model for clarity's sake. The relevant global tables are opened.

The GRADED_CORES_INVENTORY queue distributes the items across the five queues above it. The label on the inventory queue shows the scenario that has been selected in a particular month, which is then used to refer to the right table when distributing the items.

I suppose I am again overlooking something small.It would be great if I could solve this before the weekend so I can continue working!

Thanks again! Much appreciated.

2m.fsm

0 Likes 0 ·
2m.fsm (72.5 KiB)
Steven Hamoen avatar image Steven Hamoen commented ·

@Pieter Cecat

Yes it was a small thing. The sendtoport function should return the portnumber through which the item should leave, but you use "return 1" everywhere. So the second if should read "return 2" and the third one "return 3" etc.

Also I would suggest to use local variables to make your code easier readable and a lot shorter. Here is an example:

(sorry can't seem to be able to post any code here. I'll try another time)

<strong><em><br></em></strong>
0 Likes 0 ·