Search code examples
anylogic

injecting groups through a source block using probabilities


So, the problem i'm facing is the following:

In a student cafeteria, students arrive every 30 seconds in group sizes of 1, 2, 3 or 4. The probabilities for the 4 groups sizes are 50% , 20% , 5% and 25% respectively.

How can I make sure that my source block can achieve this sort of injection?


Solution

  • The cleaner way to do this is using custom distributions like this:

    custom distribution

    and then you only need one line of code:

    mySource.inject(customDistribution());