2

Trying to figure out how to generate a dataframe containing the full time-series results of a stocks-and-flow model, and then export it to Excel – to capture the value of each stock for each time unit across the course of the model’s life. Is this possible? If so, how can it be be done?

I tried following the instructions for AnyLogic's online guides on 'Exporting data to MS Excel workbook', but I believe I am missing one or more steps for first generating a database of values based on my model's various stocks over time.

Alex
  • 33
  • 4

1 Answers1

1

Create a cyclic event that regularly writes your data to the database.

In the event, you can use the Insert query like:

insertInto(eu)
  .columns(eu.country, eu.capital)
  .values("Croatia", "Zagreb")
  .execute();

Here, eu is a dbase table, country is a column in that table and "Croatia" is a value you add to a new row

At the end of the model, follow the advice you already know on how to export the database to an xls file.

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Thanks, Benjamin. I initially had a couple challenges setting up the database table and properly adapting the code you provided to my model. But after a few tweaks it worked perfectly. Thanks! – Alex Jul 06 '23 at 02:22