JHK
JHK

Reputation: 51

Best Practice to Store Simulation Results

Dear Anylogic Community,

I am struggling with finding the right approach for storing my simulation results. I have datasets created that keep track of every value I am interested in. They live in Main (see below)

Overview of Datasets

My aim is to do a parameter variation experiment. In every run, I change the value for p_nDrones (see below)

Experiment setup

After the experiment, I would like to store all the datasets in one excel sheet.

However, when I do the parameter variation experiment and afterwards check the log of the dataset (datasets_log), the changed values do not even show up (2 is the value I did set up in the normal simulation).

Dataset Log

Now my question. Do I need to create another type of dataset if I want to track the values that are produced in the experiments? Why are they not stored after executing the experiment?

I really would appreciate if someone could share the best way to set up this export of experiment results. I would like to store the whole time series for every dataset.

Thank you!

Upvotes: 1

Views: 398

Answers (1)

Jaco-Ben Vosloo
Jaco-Ben Vosloo

Reputation: 3930

Best option would be to write the outputs to some external file at the end of each model run.

If you want to use Excel, which I personally would not advise, even though it has a nice excelFile.writeDataSet() function, you can.

I would rather write the data to a text file as you will have much for control over the writing, the file itself, it is thread-safe, and useable in many many more platforms than Microsoft Excel.

See my example below:

  1. Setup parameters in your model that you will write the data to at the end of the model of type TextFile. Here I used the model on destroy code to write out the data from the data sets.

enter image description here

Here you can immediately see the benefit of using the text file! You can add the number of drones we are simulating (or scenario name or any other parameter) in a column, whereas with Excel this would be a pain...

  1. Now you can pass your specific text file to the model to use by adding it to the parameter variation page, providing it to the model through the parameters.

enter image description here

You will see that I also set up some headers for the text file in the Initial Experiment setup part, and then at the very end of the experiment, I close the text files in the After experiment section so that the text files can be used.

  1. Here is the result if you simply right-click on the text files and open them in Excel. (Excel will always have a purpose, even if it is just to open text files ;-) )

enter image description here

Upvotes: 1

Related Questions