Open channel and Bernoulli distribution

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
FabianS
Posts: 5
Joined: Thursday 18 June, 2015 - 11:29

Open channel and Bernoulli distribution

Post by FabianS »

Hey guys,
i'm new here and i need your help :)
I connected 4 conveyors on a Queue but at first only 3 conveyors are open.
At 3o clock i want to close these 3 conveyors and open the 4th.
My problem is now that i used a bernoulli distribution for the 3 conveyors (for example Bernoulli(70,1,Bernoulli(70,2,3))).
After the 3 conveyors are closed the atoms should convey with the open 4th conveyor.
Problem is now that the distribution is still sending the atoms to the 3 closed conveyors and blockade the entrys.
Now I need a 4DScript which is sending the atoms to the 4th conveyor (last open channel) after 3 o clock.
Or is it possible to have 2 commands in one 4D Script with different start timings?

Sry for my english i hope you can replicate my problem...
Greetings Fabian
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Open channel and Bernoulli distribution

Post by HarryBunnik »

Ha Fabian,

Welcome to the community.

There are a few ways to solve this. I just picked one, to give you an idea. Perhaps later when you want to scale up your process you want to create different solutions, since they are easier to maintain.

I would create a check in an if statement what the simulation time is. when it's under 15 hr, you send them to the first part of the if-statement where you select (based on a percentage) which of the 3 exits to take, after 15 hr, you send all to nr. 4.

Code: Select all

Do(
  var([valDraw], vbValue, Uniform(0,100)), {a random chance between 0 and 100}
  var([valExitChn], vbValue), 
  
  If(
    Time <= hr(15), 
    valExitChn := Case(
      WhichIsTrue(
        valDraw <= 70,   {Smaller then 70%}
        valDraw <= 91,   {Bigger then 70%, smaller then 70% + 0.7 * 30%}
        valDraw <= 100   {Leftovers}
      ), 
      1, 
      2, 
      3
    ), 
    valExitChn := 4
  ), 
  valExitChn
)
  
As you see I use a different setup then the nested Bernoulli functions.

I hope I understood your question correctly and that this gives you some new ideas.

Regards,

Harry
FabianS
Posts: 5
Joined: Thursday 18 June, 2015 - 11:29

Re: Open channel and Bernoulli distribution

Post by FabianS »

Hi Harry,

thank you very much, your solution is perfect so my english wasnt too bad :D
Regards,

Fabian
FabianS
Posts: 5
Joined: Thursday 18 June, 2015 - 11:29

Re: Open channel and Bernoulli distribution

Post by FabianS »

Hey guys (Harry),
i got another problem.
My system i simulate is a Ski-area with lifts and tracks. At the end of the day i want to close the area so the persons have to go home.
Problem:
A lift with 4 seats is with a probability of 75% full. 10% there are just 3 guys on a lift...
At the end of the day when there are just a few persons left for example 2 guys want to make their last ride of the day i got a problem when the lift demands 3 or 4 guys. So the lift has to wait for another person who will not come cause they all left the system.

My first solution was to give the assembler the order at 16:00 to convey just one person each ride so each person will leave the system. But this solution is not perfect cause the number of persons in the area fluctuates so maybe there are so many people still on the pists that the lift needs too long to convey all these guys on single rides.
By the way a queue is connected before an assember.
The solution i need would be the following:
The assembler should check the queue before the assember and when the queue is longer than 4 the assember should use the probabilitys for the distribution. If the queue is <4 the persons will be single riders.
I hope you understand what i want would be awesome if someone can help me again :).

Thx and greetings Fabian
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Open channel and Bernoulli distribution

Post by HarryBunnik »

Ha Fabian,

What you can do is when a lift cabin comes in to the assembler (On entry channel 1) and the "time > hr(16)", is to indeed check on the content of the queue in front "content(in(1, c))". Then you can adjust the B.O.M. of the assembler accordingly.

But it sounds to me as if you've been doing something similar already, when you're adjusting the content of the cabins already? So I'm not entirely sure if I understand your question correctly?

Cheers,

Harry
FabianS
Posts: 5
Joined: Thursday 18 June, 2015 - 11:29

Re: Open channel and Bernoulli distribution

Post by FabianS »

Hey Harry :)

thx for your answer i will check this and will try it in my program later when i am at home :)
I will try something like this, so the assembler will never wait for a person anymore. (i hope so)
But yeah i have to check this first so i donk know if this is working or lets say i have to test a bit with the 4D Script or do you see any big mistakes i made cause i'm not sure with the BOM value...

Code: Select all

Do(
  var([valDraw], vbValue, Uniform(0,100)), {a random chance between 0 and 100}
  var([valBOM], vbValue), 
If(
    content(in(1,c) >= 4,
    BOM := Case(
      WhichIsTrue(
        valDraw <= 70,   {Smaller then 70%}
        valDraw <= 91,   {Bigger then 70%, smaller then 70% + 0.7 * 30%}
        valDraw <= 100   {Leftovers}
      ),
      1,   {4 guys in a cabine}
      2,   {3 guys in a cabine}
      3,   {2 guys in a cabine}
    ),
    BOM := 4  {1 guy in a cabine}
  ) ,
  valBOM
)
Thx and greetings Fabian :)
User avatar
HarryBunnik
Posts: 362
Joined: Monday 07 February, 2011 - 11:22

Re: Open channel and Bernoulli distribution

Post by HarryBunnik »

Ha Fabian,

I made a few changes, but I think that with code like this, you should indeed be able to manipulate the number of people who go into the cabin, when an empty cabin arrives into the assembler:

Code: Select all

Do(
  var([valDraw], vbValue, Uniform(0,100)), {a random chance between 0 and 100}
  var([valBOM], vbValue),
  
  If(
    And(
      Time > hr(16), 
      content(in(1,c)) < 4
    ), 
    {Not so many people left (after 16 hr). Only one in a cabin}
    valBOM := 4,
    
    {Normal operation}  
    valBOM :=
      Case(
        WhichIsTrue(
          valDraw <= 70,   {Smaller then 70%}
          valDraw <= 91,   {Bigger then 70%, smaller then 70% + 0.7 * 30%}
          valDraw <= 100   {Leftovers}
        ),
        1,   {4 guys in a cabine}
        2,   {3 guys in a cabine}
        3    {2 guys in a cabine}
      )
  ),
  Cell(2, 1, c) := valBom
)
The B.O.M. value in this case can be found in the Cell(2, 1, c) (Second row (channel) of the Assembler and the first product combination). This is the B.O.M. table of the assembler.

Success!

Harry
FabianS
Posts: 5
Joined: Thursday 18 June, 2015 - 11:29

Re: Open channel and Bernoulli distribution

Post by FabianS »

Hey Harry,

thank you very much this is the solution i was looking for.

Have a nice day Fabian :)
Post Reply