How to save max value of a reporter during simulation in NetLogo?
Question
I'm running a simulation in NetLogo based on Rebellion model, in which some agents become active, but can be deactivated by other agents.
My question is, how to keep the highest value of active agents? The simulation ends, when all agents are deactivated. I count the number of active agents during simulation with:
count agents with [active?],
but I can't figure it out, how to save the highest value of this number. I know, I can measure runs at every step, but because of number of repetitions, I'd prefer just to save this max number.
Regards, Maciek.
La solution
You can keep the maximum value encountered so far in a global variable, and update it whenever you hit a new maximum:
globals [
max-active-agents
]
to setup
set max-active-agents 0
end
to go
let nb-active-agents agents with [ active? ]
if nb-active-agents > max-active-agents [
set max-active-agents nb-active-agents
]
end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow