Search code examples
anylogic

Exporting or storing Array data - AnyLogic


I'm working with AnyLogic to calculate distances between two types of agents on a GIS map. The calculated distances are stored in a 2D array named double[][] distances. Currently, I can display these results in the console, but I need a more efficient way to export or store them for further analysis. (After having these data, I will add them to the model and start using them to avoid recalculation of distances each time I run the model.) This array is huge based on my data: 50 rows x 500 columns.

The primary challenge I'm facing is the complexity involved in writing these values on an Excel sheet. Due to the structure of Excel, it requires a loop to determine the cell names (which follow an alphanumeric format like A2, E3, etc.).

Any guidance or recommendations on best practices for managing large array data outputs in AnyLogic would be greatly appreciated.


Solution

  • Better to write to a csv file programmatically. It is much faster and you have full control over formatting, etc.

    See the help and example models there: https://anylogic.help/anylogic/connectivity/text-file.html#text-file