I have the following simple model of a hospital HospitalModel. I am trying to generate an Output statistic for my model at the simulation end time, e.g., the porcentage of patients seen by a nurse. I first tried using an Output "On simulation end" stat with the value nurseService.count()/patientArrival.count() as I am trying to calculate the value without generating new variables but I realized this expression gives 0 at simulation end time. Then I tried generating a variable porcentageNurse and updating it with an event every hour with the expression nurseService.count()/patientArrival.count(), but once again, I realized the calculation was never computed.
- Why doesn't Anylogic compute this operation?
Afterwards I realized a way to make it work is to compute first nurseService.count() and save its value into a variable 'a' and then use the expression: a/patientArrival.count(). This works if you update a variable with an event, but in the Output stat case, local variables can't be defined in the value field so again it can't be done directly.
- There is any way to output such an statistic as the percentage of patients without creating adittional variables?
Finally, I realized other than with the Output stat, I couldn't find a way to run code at simulation end time (or generate statistics at simulation end time). There is an "After simulation run" section in the java actions of the simulation experiment, but it seems this section is not connected with main.
How can you connect this section to main? Or which would be the proper way to run code at simulation end time? Is there a way to generate statistics at simulation end time without the Output stat?
Is there an expression to call the simulation end time?
Thanks for your help.