Is there a way to make attractor choice both free & random at the same time?
The problem I have with either on it's own is:
Solution I found, but don't know how to implement correctly is in the following thread:
AnyLogic Attractor weird behavior
I tried to create an agent type (instead of a class) 'myAttractor' with a boolean variable inside (occupied or not occupied attractor), but I don't know how to assign that agent type to actual attractors within a node - if that is even possible?
Maybe there are other solutions to customise the attractor choice to achieve complete randomness with only one agent per attractor?
Many thanks in advance, Peter
That is a good question and often a problem on the animation side of things.
One option is to create a collection, simple ArrayList will do, of all the attractors
Then in the Process Modelling Block (PML) where you setup the attractor you have a function that returns an Attractor. I supply the agent here so that we can keep track of what agent is sent to which attractor so that we can put the attractor back into the available pile once the agent leaves the attractor location.
Here is the getAttractor function
It gets a random available attractor and then also saves the agent that is taking it to a map
Here is the setup for the map mapAgentPerAttractor
If you want to free the attractor you can simple call this at any point that the attractor is freed
attractorsAvailable.add(mapAgentPerAttractor.get(agent));
mapAgentPerAttractor.remove(agent);
Here is the final result as well as a comparison where we are replciating the problem you described
One can see in the bottom node there are only 8 dots available as some agents are on the same attractor...