0
votes

I am currently working on an Anylogic project related to the health care sector. In order to get meaningful results, I've set up an experiment for parameter variation with 500 replications. After each replication, my main-method should output certain data into an excel sheet. Now, in order to have a data set with 500 filled columns (1 for each replication), I'd need a public variable that represents the column number. It should be accessed by the experiment, increased after each replication by 1 and also accessed by the main method in order to transfer the next column number for the excel output. So far, I haven't found the command for accessing a variable from the simulation in the main-method or the other way around.

I hope you can give me a helpful hint for that issue.

Thank you very much.

Greg

2

2 Answers

1
votes

To access the replication and/or iteration (parameterset) number in the main object (or any other Agent) you could try it like this:

Experiment exp = getExperiment();
if( exp instanceof ExperimentParamVariation )
{
    int curRep = ((ExperimentParamVariation)exp).getCurrentReplication();
    int curIter = ((ExperimentParamVariation)exp).getCurrentIteration();
}
else 
{
    //whatever you want to do in case another experiment type is running
}

For accessing a variable or method of the main object from the experiment you have to click on the experiment, go to the properties window and to the "Java actions" area. There you can specify before and after simulation code where you have access to the root variable that contains the current main-object. So if you have a certain result variable (for example numberOfPatients) in the main object you could simply access it via: root.numberOfPatients

0
votes

well i don't know if it is possible to access the run number. Maybe you can find something in the experiment object (use getExperiment()).

when I use parameter variation I usually store the information in a csv-file or sql-db with the system time and the paramter setup. Eg. dateTime, variableparamA, variableparamB, variableparamC, dataValueORresult. This way you can import the data directly into Excel (import data function) and use a pivot table to filter your result. Later when you rerun you experiment you can just right click the excel table and hit update, and you get the newest results.