15 #ifndef CORE_SCHEDULER_H_
16 #define CORE_SCHEDULER_H_
22 #include <unordered_map>
36 class SimulationBackup;
37 class VisualizationAdaptor;
40 class MechanicalForcesOp;
47 using Clock = std::chrono::high_resolution_clock;
67 void SimulateUntil(
const std::function<
bool()>& exit_condition);
93 std::vector<Operation*>
GetOps(
const std::string& name);
177 template <
typename Lambda>
179 Lambda lambda)
const {
180 for (
auto* op : operations) {
186 template <
typename Lambda>
193 template <
typename Lambda>
This class implements a progress bar that can be used to track the progress of a simulation.
The class that bridges the simulation code with ROOT Visualization.
std::chrono::time_point< Clock > last_backup_
real_t GetSimulatedTime() const
RootAdaptor * root_visualization_
std::vector< Operation * > scheduled_standalone_ops_
List of operations will be executed as a stand-alone operation.
std::vector< Operation * > post_scheduled_ops_
ProgressBar * progress_bar_
void UnscheduleOp(Operation *op)
RootAdaptor * GetRootVisualization()
void ForEachOperationInList(const std::vector< Operation * > &operations, Lambda lambda) const
Runs a lambda for each operation in the specified list of operations.
std::vector< Operation * > scheduled_agent_ops_
List of operations will be executed on all agents.
std::chrono::high_resolution_clock Clock
std::vector< std::string > protected_op_names_
List of operations that cannot be affected by the user.
void Simulate(uint64_t steps)
Simulate steps number of iterations.
SimulationBackup * backup_
void ForEachScheduledOperation(Lambda lambda)
Runs a lambda for each scheduled operation.
TimingAggregator op_times_
Tracks operations' execution times.
void PrintInfo(std::ostream &out) const
std::vector< Operation * > pre_scheduled_ops_
void RunPostScheduledOps() const
void SimulateUntil(const std::function< bool()> &exit_condition)
void RunPreScheduledOps() const
void UpdateSimulatedTime()
void Backup()
Backup the simulation. Backup interval based on Param::backup_interval
void ForEachOperation(Lambda lambda)
Runs a lambda for each operation that is executed in the Execute() call.
TimingAggregator * GetOpTimes()
std::vector< Functor< bool, Agent * > * > agent_filters_
void Initialize(uint64_t steps=0)
bool Restore(uint64_t *steps)
void RunAgentOps(Functor< bool, Agent * > *filter) const
std::vector< std::pair< OpType, Operation * > > schedule_ops_
List of operations that are to be added in the upcoming timestep.
std::vector< Operation * > unschedule_ops_
List of operations that are to be removed in the upcoming timestep.
uint64_t GetSimulatedSteps() const
This function returns the number of simulated steps (=iterations).
void FinalizeInitialization() const
void SetAgentFilters(const std::vector< Functor< bool, Agent * > * > &filters)
friend void RunAgentsTest(Param::MappedDataArrayMode, uint64_t, bool, bool)
std::vector< std::string > GetListOfScheduledStandaloneOps() const
Return a list of StandAloneOperations that are scheduled.
std::vector< Operation * > GetOps(const std::string &name)
std::vector< Operation * > all_ops_
std::vector< std::string > GetListOfScheduledAgentOps() const
Return a list of AgentOperations that are scheduled.
void ScheduleOp(Operation *op, OpType op_type=OpType::kSchedule)
const std::vector< Functor< bool, Agent * > * > & GetAgentFilters() const