PDA

View Full Version : Send flowitems to different ports by percentage!


DilAmaya
09-01-2009, 04:51 PM
Good Evening,

In my model I have a rack connected to three different queues and I want that the items flow to the queues according to certain percentages. I know that this can be done with the "by percentage" option in the rack's flow; the problem is that my model needs to have 52 racks connected to 104 queues and that exceeds the "by percentage" capacity (it only accepts up to 10 ports).

I need to know how can I make this possible, maybe if I use a table...but please let me know!!

Need some urgent help!

Dil Amaya

Tom David
09-02-2009, 01:06 AM
You are right, if you use the Template Code, you only have 10 entries for the percentage. But what you can do is extend the code in the Code Edit by adding local variables (percent and result/port), adjust the percentage calculation and the return code. But this would be quite some effort, I guess.
Another way would be to use arrays for the local variables (percent and result/port) to make it more flexible. Define a local variable for the array size and this information can be used e.g. in a loop. You could then e.g. use a table to fill the array or directly do it in the code.
That’s the way I would try to go.

I modified your model a bit and it seems to work. I added a Global Table and changed the code in the Send To Port trigger.

Pablo Concha
09-02-2009, 09:14 AM
Hello,

What would be the difference between using the arrays option and just using the table ("PercentArray" in Tom's model) and calling it by the default "Discrete Empirical Distribution" option in the Send to Port field...

regards..

Pablo Concha E.

Phil BoBo
09-02-2009, 10:52 AM
Tom's code does almost the same thing as the dempirical command. Good suggestion to use that pick option, Pablo.

Tom David
09-02-2009, 10:56 PM
Pablo,

You are right it would be good first to search through the pick options before writing own code. ;) Thanks for pointing this out.

Jamie Santa Ana
10-06-2009, 04:38 PM
Hello,

I'm trying to send 25% of items to a processor, and 75% of items to a conveyor. But, if the processor is busy processing, I want the items to go straight to the conveyor instead of waiting for the processor. So, I've tried adding code at the end of the template code for percentage, but with no success. I've attached a sample model trying trying to accomplish this. Thanks for any help.

Brandon Peterson
10-06-2009, 04:56 PM
Jamie,

If you have 1 processor and 1 conveyor then you could do the following:

1.Connect the first output port to the processor and the second one to the conveyor.
2.In the function that you are using to send to port return 0 for the processor and 2 for the conveyor.

Returning 0 for the processor basically tells the item to go to the first open port. Because the processor is connected to port 1 it will try the processor first and if it is busy then it will go to the conveyor lilke you want.

Good Luck,
Brandon