Reputation: 1
I am modelling an Agent based model in AnyLogic. I am trying to count the number of agents in a statechart with similer fill color as the agents will be assigned different fill colors as they enter different states using the setFillColor()
command. I have tried the command item.statechart.equals(Color.red)
but its not bringing up any value
Upvotes: 0
Views: 196
Reputation: 3975
I would suggest making use of a variable, even if it is a variable of type Color and rather count agents with the variable set to a specific color. It will be easier to count e.g
agents.stream().filter(e -> colorVariable.equals(blue)).count()
but you can also do this with the rectangle
agents.stream().filter(e -> e.rectangle.getFillColor().equals(blue)).count()
Upvotes: 1
Reputation: 12605
It depends on what element you fill the color with. If you have a rectangle in an and call rectangle.setFillColor(blue)
, then you can count all agents using item.rectangle.getFillColor().equals(blue)
Note that you cannot count by the color of statechart states. For that, you can (and should) check if an agent is in a given state using item.statechart.isStateActive(someState)
Upvotes: 0