I am building an agent-based-model in AnyLogic to show the progression of learners from one grade to the next throughout highschool. My states (Grade 8 up until Grade 12) have been drawn in my agent 'page' as shown below.
I have defined the transition rules for all states based on different agent variables. In order to see if my basic model is working, I have added getMain().dropout_count++
to the 'Entry action' of my 'Dropout' state. I also have a variable called dropout_count
in my Main simulation page that should show the how many learners have dropped out.
However, I can't get passed this point. I keep getting the error that
The method
getMain()
is undefined for the typeLearner
What am I doing wrong or what am I missing? It seems like the most trivial error yet I have no I idea how to fix it.
Not sure why getMain()
is not incrementing the dropout_count
.
Either use main
or get_Main()
(note the difference to your getMain()
!!). Both work if your Learner
is embedded into Main
as an agent population.
If not, you can always brute-force using ((Main)getRootAgent)
instead.
In any case: start using code-complete as it tells you what you can and cannot code in any place: https://anylogic.help/anylogic/ui/using-intelli-sense.html
Last, understand your model hierarchy: https://anylogic.help/advanced/code/access.html#where-am-i-and-how-do-i-get-to