Anylogic: reading excel cells value for dynamic parameters definition

129 Views Asked by At

Cheers Everyone, here is my problem. I'm creating an Anylogic model trying to make it as flexible as possible. This means that I'm feeding some time values directly from an Excel spreadsheet. In order to create a delay loop that changes its value every time by going row by row, I created a parameter and a variable that work like this:

row_index (variable) with initial value 4 parameter with default value - excel_spreadsheet.getCellNumericValue("Sp_A", row_index, 6)

But as soon as I run my simulation this happens: The row #0 (1-based) does not exist

My goal is to update the row_index every time that my delay is over and so on. I tried to update the parameter value (starting from zero) after starting the simulation (for example on the on enter of a queue) but I got another error.

How can I solve this issue?

Thank you all in advance, Ale

1

There are 1 best solutions below

1
On BEST ANSWER

I found two solutions

  1. Instead of writing the code directly to the 'Default value' of your parameter, set it to an arbitrary number and set the value somewhere else. For example write myParameter = excel_spreadsheet.getCellNumericValue(1, row_index, 6); in the 'On startup:' action of the agent.
  2. Use a Variable instead of a Parameter (if you don't need the special capabilities of parameters).

EDIT: This only solves the error on startup. You need to manually update the parameter/variable value too when the row_index is changed