Home > other >  Anylogic - Automate multiple runs of a simulation model in Anylogic
Anylogic - Automate multiple runs of a simulation model in Anylogic

Time:01-09

I have a simulation model written in Anylogic. The output of the simulation is automatically exported to an excel file. I need to run the simulation about 20 times for each of the 10 scenarios and it each run takes about 30 minutes for each run. How can I automate this process? Also, I want to be able to pass a few arguments to the model for each run.

Would appreciate any suggestions!

CodePudding user response:

Use the Parameters Variation experiment.

You can access any run number on Main startup with the code int a=getEngine().getRunCount();. You can prepare the inputs beforehand in an Excel and pass the parameters based on the count number. enter image description here

You can write the outputs separately for each run. Use the following code as an inspiration where I write myVariable at the end of each run to csv files called output0.csv, ouput1.csv, etc. (This happens in Main -> On Destroy.

int a=getEngine().getRunCount();

String filename="output" a ".csv";

try
{
 FileOutputStream fos = new FileOutputStream(filename);
 PrintStream p = new PrintStream(fos);
 
 for (int i=0; i<100;i  ){
    for(int j=0;j<10;j  ){
        p.println(myVariable.output[i][j]);}} // outputs tab delimited values
}
catch (Exception e)
{
 traceln("Could not write to file.");
}

  •  Tags:  
  • Related