Search code examples
anylogic

Exporting to excel when using ParametersVariation in Anylogic


I've a question, in my main agent I've some variables which I want to export to a excel row based on a parameter value (in this case AGVs) after the simulation duration. Now I want to vary this parameter by using the parameter variation experiment, but somehow it does not work and only updates the excel sheet for the last run. So in the figure below you see the exportdata function which is the function which puts the data in the excel sheet columns.

enter image description here

Now I want to vary a parameter in this example I choose the number of AGVs, so I created an parameters variation experiment and set this number of AGVs in a specified range see figure below:

enter image description here

Now I want for every parameter the ExportData function to run, and put it in new rows for every AGV value:

AGV=13 ExcelRow=1 ExportData()
AGV=14 ExcelRow=2 ExportData()
....

So I tried to do this by putting the variable NrOfExperiment in the ParametersVariation agent and let it do +1 after every run see the next figure: enter image description here

But somehow he only export the data for the last run instead of all the runs? How can I fix this problem? I already tried to put it in after iteration by java actions but this would not work.

Thanks!


Solution

  • Easiest option is to just write all model results into a dbase table at the end, with an extra iteration and replication column (fill with getExperiment().getCurrentIteration/Replication()).

    Write to that at the end of each model (on destroy of Main).

    At the end of the experiment, simply setup the dbase to export to an Excel file.