Search code examples
anylogic

Dynamically changing custom distribution


I have created custom distribution in my model using option list. enter image description here

First column is account ID. There are 3 types of account High , Low , Medium .

I want to create different scenarios in the model.

  1. if user selects the High type of accounts then agents with High type should get generated at the source. Currently all agents with all account type are generated.
  2. for a particular account type I want to change the custom distribution. e.g if user selects High type of account then the custom distribution for those account will be changed dynamically. If below two accounts are High type then I want to change the distribution using percentage
before --->>
Account      No of Observation        
A-3929180    10
A-5414929    20

Let's increase the distribution by 50%

After--->>
Account      No of Observation        
A-3929180    15
A-5414929    30

enter image description here

I couldn't see any help around creating custom distribution using Option list in Java.


Solution

  • To build a customDistribution that you change during simulation runtime in any way, you can do it yourself by definining it as follows:

    new CustomDistributionOfOptions(OptionList.values(),new double[] { 34.0, 4.0, 5.0,  })
    

    this is how you construct it programatically... so you have to create a variable of type CustomDistributionOfOptions and then set up a value for it as I mentionned.

    The following can be an example of a function you might want to use to change your custom distribution:

    double [] values=new double[OptionList.values().length];
    int i=0;
    for(OptionList o : OptionList.values()){
        values[i++]=uniform(1,15);
    }
    customDist=new CustomDistributionOfOptions(OptionList.values(),values);