Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Anylogic: I've assigned a statistic value to a variable, but it only return 0

I have assigned a statistics value to the variable waiting_units using jeepneys.Waiting_Units_MDJ(). jeepneys is the population, and Waiting_Units() is the statistics. When simulated, it only returns 0 and not the statistics value.

It only shows the right statistic value if I add an event with an action waiting_units = jeepneys.Waiting_Units_MDJ(); to assign the value.

Is there a right way so I can assign the statistics value to a variable without using an event? I need the variable to continuously have the current value of the statistic.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I appreciate any help you can provide.

>Solution :

The Waiting_Units() statistic is a function (hence the brackets). By design, it is never actually calculated unless you call it. This is to avoid accidentally slowing your model.

It is your responsibility to call the function/statistic when you need it.

If you want to avoid using an event, you can also replace the statistic function with an Output object computing the same thing whenever you want:
enter image description here

Note that the code in the "Value" field depends on the setup of your current statistic.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading