Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to generate random true/false result in Anylogic

Iam new to anylogic. I want to generate random true false results to control parameter in Select Output.

I used this if else conditions in my source


if(randomTrue(0.25)){
    if(randomTrue(0.5)){
        agent.isOnlineRezerve = true;
    }else { 
        agent.isOnlineRezerve = false;
    }
}else{
    agent.isOnlineRezerve = false;
}

My condition of source output is

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

agent.isOnlineRezerve

Every time I run it it gives me 128 out of 1000 true and the rest false

I want to get a number other than 128 each time, but I couldn’t do it. I would be glad if you help.

>Solution :

AnyLogic is using a fixed seed to the random number generator, so that independent runs produce equivalent results. To switch to a random seed:

To set up random number generator seed

  1. In the Projects view, select the experiment you are currently working with.

  2. Go to the Randomness section of the Properties view.

  3. In the Random number generation group of buttons:

  • To set random seed, choose the Random seed (unique experiments) option.

  • To set fixed seed, choose the Fixed seed (reproducible experiments) option > and enter the seed value in the Seed value edit box.

From https://anylogic.help/anylogic/stochastic/random-number-generator.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading