#include <scheduler.h>
|
using | Clock = std::chrono::high_resolution_clock |
|
Definition at line 45 of file scheduler.h.
◆ Clock
◆ Scheduler()
bdm::Scheduler::Scheduler |
( |
| ) |
|
◆ ~Scheduler()
bdm::Scheduler::~Scheduler |
( |
| ) |
|
|
virtual |
◆ Backup()
void bdm::Scheduler::Backup |
( |
| ) |
|
|
private |
◆ Execute()
void bdm::Scheduler::Execute |
( |
| ) |
|
|
protectedvirtual |
Executes one step. This design makes testing more convenient
Definition at line 354 of file scheduler.cc.
◆ FinalizeInitialization()
void bdm::Scheduler::FinalizeInitialization |
( |
| ) |
const |
Finalize simulation initialization or manual changes between Simulate
calls.
All Simulate
calls do this automatically, but sometimes it is useful to do it manually (e.g.for tutorials).
Definition at line 153 of file scheduler.cc.
◆ ForEachOperation()
template<typename Lambda >
void bdm::Scheduler::ForEachOperation |
( |
Lambda |
lambda | ) |
|
|
inlineprivate |
Runs a lambda for each operation that is executed in the Execute() call.
Definition at line 194 of file scheduler.h.
◆ ForEachOperationInList()
template<typename Lambda >
void bdm::Scheduler::ForEachOperationInList |
( |
const std::vector< Operation * > & |
operations, |
|
|
Lambda |
lambda |
|
) |
| const |
|
inlineprivate |
Runs a lambda for each operation in the specified list of operations.
Definition at line 178 of file scheduler.h.
◆ ForEachScheduledOperation()
template<typename Lambda >
void bdm::Scheduler::ForEachScheduledOperation |
( |
Lambda |
lambda | ) |
|
|
inlineprivate |
Runs a lambda for each scheduled operation.
Definition at line 187 of file scheduler.h.
◆ GetAgentFilters()
const std::vector< Functor< bool, Agent * > * > & bdm::Scheduler::GetAgentFilters |
( |
| ) |
const |
◆ GetListOfScheduledAgentOps()
std::vector< std::string > bdm::Scheduler::GetListOfScheduledAgentOps |
( |
| ) |
const |
|
private |
Return a list of AgentOperations that are scheduled.
Definition at line 202 of file scheduler.cc.
◆ GetListOfScheduledStandaloneOps()
std::vector< std::string > bdm::Scheduler::GetListOfScheduledStandaloneOps |
( |
| ) |
const |
|
private |
Return a list of StandAloneOperations that are scheduled.
Definition at line 210 of file scheduler.cc.
◆ GetOps()
std::vector< Operation * > bdm::Scheduler::GetOps |
( |
const std::string & |
name | ) |
|
Returns a vector of operations with the given name. If the name is in the list of proected ops, this function returns an empty vector.
Definition at line 218 of file scheduler.cc.
◆ GetOpTimes()
◆ GetRootVisualization()
◆ GetSimulatedSteps()
uint64_t bdm::Scheduler::GetSimulatedSteps |
( |
| ) |
const |
This function returns the number of simulated steps (=iterations).
Definition at line 158 of file scheduler.cc.
◆ GetSimulatedTime()
real_t bdm::Scheduler::GetSimulatedTime |
( |
| ) |
const |
This function returns the time that has been simulated until this point of the simulation.
Definition at line 160 of file scheduler.cc.
◆ Initialize()
void bdm::Scheduler::Initialize |
( |
uint64_t |
steps = 0 | ) |
|
|
private |
◆ PrintInfo()
void bdm::Scheduler::PrintInfo |
( |
std::ostream & |
out | ) |
const |
Prints an overview of all pre-scheduled, agent, standalone, and post-scheduled operations. For each iteration, the scheduler executes these operations in the order that they appear in the output. Additionally, the output shows a column "frequency" with values indicating that a certain operation is only executed every -th time.
Definition at line 371 of file scheduler.cc.
◆ Restore()
bool bdm::Scheduler::Restore |
( |
uint64_t * |
steps | ) |
|
|
private |
Restore the simulation if requested at the right time
- Parameters
-
steps | number of simulation steps for a Simulate call |
- Returns
- if
Simulate
should return early
Definition at line 435 of file scheduler.cc.
◆ RunAgentOps()
void bdm::Scheduler::RunAgentOps |
( |
Functor< bool, Agent * > * |
filter | ) |
const |
|
private |
◆ RunPostScheduledOps()
void bdm::Scheduler::RunPostScheduledOps |
( |
| ) |
const |
|
private |
◆ RunPreScheduledOps()
void bdm::Scheduler::RunPreScheduledOps |
( |
| ) |
const |
|
private |
◆ RunScheduledOps()
void bdm::Scheduler::RunScheduledOps |
( |
| ) |
|
|
private |
◆ ScheduleOp()
void bdm::Scheduler::ScheduleOp |
( |
Operation * |
op, |
|
|
OpType |
op_type = OpType::kSchedule |
|
) |
| |
Adds the given operation to the list of to be scheduled operations. Scheduler takes over ownership of the object op
. NB: Don't pass stack objects to this function.
Definition at line 164 of file scheduler.cc.
◆ ScheduleOps()
void bdm::Scheduler::ScheduleOps |
( |
| ) |
|
|
private |
◆ SetAgentFilters()
void bdm::Scheduler::SetAgentFilters |
( |
const std::vector< Functor< bool, Agent * > * > & |
filters | ) |
|
Agent operations are executed for each filter in agent_filters_.
By default no filter is specified which means that all agent operations will be executed for each agents in the simulation.
Definition at line 239 of file scheduler.cc.
◆ SetUpOps()
void bdm::Scheduler::SetUpOps |
( |
| ) |
|
|
private |
◆ Simulate()
void bdm::Scheduler::Simulate |
( |
uint64_t |
steps | ) |
|
Simulate steps
number of iterations.
Definition at line 130 of file scheduler.cc.
◆ SimulateUntil()
void bdm::Scheduler::SimulateUntil |
( |
const std::function< bool()> & |
exit_condition | ) |
|
Simulate until exit_condition
evaluates to true.
The condition will be tested at the beginning of an iteration.
e.g. simulate until there are 1000 agents in the simulation
scheduler->SimulateUntil([](){
auto* rm = Simulation::GetActive()->GetResourceManager();
return rm->GetNumAgents() >= 1000;
});
NB: Automated backups and restores are not yet supported if the simulation uses this simulate function. TODO(lukas)
Definition at line 144 of file scheduler.cc.
◆ TearDownOps()
void bdm::Scheduler::TearDownOps |
( |
| ) |
|
|
private |
◆ UnscheduleOp()
void bdm::Scheduler::UnscheduleOp |
( |
Operation * |
op | ) |
|
◆ UpdateSimulatedTime()
void bdm::Scheduler::UpdateSimulatedTime |
( |
| ) |
|
|
private |
◆ RunAgentsTest
◆ agent_filters_
std::vector<Functor<bool, Agent*>*> bdm::Scheduler::agent_filters_ |
|
private |
Agent operations are executed for each filter in agent_filters_.
By default no filter is specified which means that all agent operations will be executed for each agents in the simulation.
Definition at line 159 of file scheduler.h.
◆ all_ops_
std::vector<Operation*> bdm::Scheduler::all_ops_ |
|
private |
◆ backup_
◆ last_backup_
std::chrono::time_point<Clock> bdm::Scheduler::last_backup_ = Clock::now() |
|
private |
◆ op_times_
Tracks operations' execution times.
Definition at line 154 of file scheduler.h.
◆ post_scheduled_ops_
std::vector<Operation*> bdm::Scheduler::post_scheduled_ops_ |
|
private |
◆ pre_scheduled_ops_
std::vector<Operation*> bdm::Scheduler::pre_scheduled_ops_ |
|
private |
◆ progress_bar_
◆ protected_op_names_
std::vector<std::string> bdm::Scheduler::protected_op_names_ |
|
private |
List of operations that cannot be affected by the user.
Definition at line 146 of file scheduler.h.
◆ restore_point_
uint64_t bdm::Scheduler::restore_point_ |
|
private |
◆ root_visualization_
RootAdaptor* bdm::Scheduler::root_visualization_ = nullptr |
|
private |
◆ schedule_ops_
List of operations that are to be added in the upcoming timestep.
Definition at line 138 of file scheduler.h.
◆ scheduled_agent_ops_
std::vector<Operation*> bdm::Scheduler::scheduled_agent_ops_ |
|
private |
List of operations will be executed on all agents.
Definition at line 144 of file scheduler.h.
◆ scheduled_standalone_ops_
std::vector<Operation*> bdm::Scheduler::scheduled_standalone_ops_ |
|
private |
List of operations will be executed as a stand-alone operation.
Definition at line 142 of file scheduler.h.
◆ SchedulerTest
friend bdm::Scheduler::SchedulerTest |
|
private |
◆ simulated_time_
real_t bdm::Scheduler::simulated_time_ = 0.0 |
|
protected |
◆ total_steps_
uint64_t bdm::Scheduler::total_steps_ = 0 |
|
protected |
◆ unschedule_ops_
std::vector<Operation*> bdm::Scheduler::unschedule_ops_ |
|
private |
List of operations that are to be removed in the upcoming timestep.
Definition at line 140 of file scheduler.h.
The documentation for this class was generated from the following files: