Simon
Simon

Reputation: 11

Exporting the results of an Anylogic experiment

I have built my model and run the experiment. I cannot seem to find where the data is stored.

I now need to conduct several runs and compare the results, I am using normally distributed repair times so the results should vary between runs without modifying parameters.

How can I keep the results of each run and then present them all in the same data set?

Upvotes: 1

Views: 1413

Answers (1)

Jaco-Ben Vosloo
Jaco-Ben Vosloo

Reputation: 3930

There are two main options for getting data out of your simulation

  1. Using the internal AnyLogic database
  2. Using external files like Excel or txt

Step 1: Setup your objects

  1. Internal Database

Create an empty table with the columns you require

enter image description here

  1. External object

Setup either an Excel or text file using the objects provided by AnyLogic in the Connectivity palette

enter image description here

Step 2: Saving your data

For both cases you need to write your data to the object of your choosing, either as the data gets generated or at the end of the simulation model

  1. using Internal DB

The best option is to write data using the following command

insertInto(table_name)
    .columns(column_name)
    .values(value);

This will just insert a new line into a database table that you created, you can save multiple values to multiple columns by adding comma-separated entries into the parameters for columns and values.

e.g

insertInto(temeprature_output_table)
    .columns(scenario_name, time, temperature)
    .values("sceanrio1", 10,5, 102);
  1. External files

2.1) Using Excel

filename.setCellValue(value, sheetName, row, column);

or even better you can write out an entire dataset

excelFile.writeDataSet(dataset, sheetName, row, column);

2.2) Using a text file

fileName.println("value" + "\t" + " value 2");

You can use whatever separator you want "\t" for tab separated or "," for comma and so on

Step 3: Finish and export data

  1. Internal Database At the end of a simulation run, you can simply export the data enter image description here

See help here https://anylogic.help/anylogic/connectivity/export-excel.html#exporting-data-to-ms-excel-workbook

P.S. It is possible to automate this with some effort

  1. External file

On Excel you need to call .writeFile() to finish. On both objects, you need to call .close() for them to be closed and saved to memory.

FYI Excel has the option to save on termination.

enter image description here

Read more on using Excel here - https://anylogic.help/anylogic/connectivity/excel-file.html#writing-to-excel-file

And on text file here https://anylogic.help/anylogic/connectivity/text-file.html#replicated

There is also an example model

enter image description here

Upvotes: 3

Related Questions