I am trying to develop an Agent Based model where patient gets to hospital based on the nearest hospital distance. I have two agent population on Main,
This is my network. See Image
And here is the transition condition,
distanceTo(getNearestAgent(main.hospitals(0))) < distanceTo(getNearestAgent(main.hospitals(1)))
This is returning the error, "The method getNearestAgent(Iterable) in the type Agent is not applicable for the arguments (Hospital)".
The function getNearestAgent()
is used for finding the nearest agent in a population and you got the error because you're calling it on a single agent. Since you only have two hospitals that you need to calculate the distance from, you can either use
distanceTo(main.hospitals(0)) < distanceTo(main.hospitals(1))
(is hospital(0) closer than hospital(1)?)
or
getNearestAgent(main.hospitals).equals(main.hospitals(0))
(is hospital(0) the nearest one?)
(But if you need to extend your model to include more than two hospitals, you will need a slightly different approach)