1
votes

I am currently work on a small model on a emergency room. However, I have ran into a problem I can find a solution to:

I am trying to make reproducible model source arrivals when changing a parameter, such as nurse or doctors. I have a rate arrivals schedule in my source block. Running the simulation without changing the parameter gives me reproducible arrivals pattern, However changing the number of nurses in the model changes the arrivals pattern as well!! Why is this the case??. I look into the example model of a Trauma Center and here it does the same as my model. Even when a fixed seed is used. Try changing the number of doctors and you can see that the number of arrivals change ??

Best regards Morten

1

1 Answers

2
votes

Your entire model is using a single random number stream by default. Having more resources means patients might get to certain blocks in different sequences and certain blocks will be calling for random numbers more/less often than they were in other runs.

You can use another random number stream, besides the default, for the arrivals. This will keep the arrivals the same across experiments, even when other things change.

I would do this by using an event, whose action is to inject an agent into your source block (turn your source block to manual). After injecting one entity, reset the event to go off for the next arrival. If you have exponential inter-arrival times, you can do something like:

Arrivals.inject( 1 );

double dTimeUntilNextArrivale = exponential( 0.5, 1, myRandom);
// where myRandom is defined somewhere for the model to use - I would typically 
// define the variable in the class with the source block and then instantiate
// in the startup code
// example: Random myRandom = new Random();
self.restart( dTimeUntilNextArrival, TimeUnits.MINUTE );

Wanting to have different areas on different random number streams is common, so the code above is just one possible way to do this.

A few bigger picture things to consider:

  1. The AnyLogic help menu has some suggestions about turning on randomness & making sure results are repeatable.
  2. For many models, with enough replications, it should not matter that your simulation with different number of doctors had different arrival streams. You run enough reps to make sure that there is a true difference in scenarios, and not a difference due to random sampling.