// Define how to get the simulation time values for the TimeSeries
auto get_time = [](Simulation *sim) {
return static_cast<double>(sim->GetScheduler()->GetSimulatedTime());
};
// How to define a counter
auto count_a_given_criteria = [](Agent *a) { // receives pointer to agent
// Assuming you have a specific agent that inherits from Agent
auto *my_agent = dynamic_cast<MyAgent *>(a);
if (my_agent) {
// Check if the agent meets a certain criteria
return (my_agent->GetSomeAttribute() < some_value);
} else {
// If the agent is not of the type MyAgent, return false
return false;
}
};
ts->AddCollector("MyCounter", new Counter<double>(my_agent), get_time);
}