My own Code in Option Sent to

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Dino
Posts: 2
Joined: Sunday 22 December, 2013 - 12:58

My own Code in Option Sent to

Post by Dino »

Hi friend,

I recently started with this software with student license. I'm making a simple model. In my model i have 3 servers conected with 4 queues. Each server is connected with each queue.

The first queue wants the 80% of fresh of each server. The second queue wants the 10% of fresh of each server, the third queue wants the 2% of fresh of each server and the last queue wants the 8% of fresh of each server.

I need to make the 4D Scritp with this operations and i don't know how is this code.

Thank you!
Dino
Posts: 2
Joined: Sunday 22 December, 2013 - 12:58

Re: My own Code in Option Sent to

Post by Dino »

I wrote this instrucction...

Bernoulli(80,1,Bernoulli (10,2, Bernoulli (2,3,4)))
SimonvdW
Posts: 47
Joined: Thursday 06 January, 2011 - 09:52

Re: My own Code in Option Sent to

Post by SimonvdW »

Hi,

You can use the Bernoulli distribution, but you have to consider the order of the parameters in the script function Bernoulli.
The first paramer is the chance, the second the allocation when true and the third the

With your code: Bernoulli(80,1,Bernoulli (10,2, Bernoulli (2,3,4))) 80% will go to number 1; 10% of the remaining 20 % (=2% !!) to number 2, 2 % of 90% of 20 % (=0.36% !!) to number 3 and the remainder (17.64%) to number 4. That is not what you want.

So use instead: Bernoulli(80,1,Bernoulli (50,2, Bernoulli (20,3,4))). This results in : 80 - 10 - 2 - 8.

Another (easier) option is using the Emperical distribution atom (under Tools). Define a name of this distribuition (eg. 'SendDistr'), the number of Classes (4 in your case), Apply this, and use Edit Classes to assign chanses and values. Note: chances cumulative to 100%. So, in your case 80% value 1; 90% value 2; 92 % value 3 and 100% value 4.
Now you can just use the distribution name ('SendDistr') in the code of your servers. This automatically picks a value from the Emperical distribution and assigns that as sendto value.

Success,
Simon
Post Reply