The SimulationExecutive class defined in C++ is the ultimate one stop shop for running the simulation. It includes specified implementations of the scheduler, a frame tree and associated search functions, and functions for logging and integration setup. This guide provides an overview of how to interact with the SimulationExecutive class.

The SimulationExecutive Class

Description and Naming

The SimulationExecutive class manages the execution of simulations, integrating various components like scheduling, logging, and visual management. The class is responsible for parsing arguments, setting simulation parameters, and controlling the simulation flow.

For a complete guide on interacting with the SimulationExecutive class, refer to the Doxygen documentation: SimulationExecutive Doxygen

Creating a SimulationExecutive

Description C++ Example Python Example

Constructor - Creates a SimulationExecutive object.

SimulationExecutive exc;
exc = SimulationExecutive()

Parsing Arguments

Description C++ Example Python Example

Parsing Command Line Arguments - Parses command line arguments which are provided from script start in C++ and Python.

exc.parseArgs(argc, argv);
# This parsing method used only for C++

Parsing Arguments from Vector - Parses arguments from a vector of strings.

exc.parseArgs(sys.argv)

Setting Simulation Parameters

Description C++ Example Python Example

Setting Integrator - Sets the integrator type. Current valid options are 1 or FORWARD_EULER for forward euler and 4 or RK4 for RK4

exc.integrator(1);
exc.integrator(1)

Getting Integrator - Gets the integrator type.

exc.integrator();
exc.integrator()

Setting Simulation Rate (Hz) - Sets the simulation run rate in Hz.

exc.setRateHz(100);
exc.setRateHz(100)

Setting Simulation Rate (Seconds) - Sets the simulation run rate in seconds.

Time rateSec(1);
exc.setRateSec(rateSec);
rateSec = Time(1)
exc.setRateSec(rateSec)

Setting Simulation End Time - Sets the simulation end time. Note: better to set this from the command line with --end=<endtime>

double endTime = 100.0;
exc.end(endTime);
endTime = 100.0
exc.end(endTime)

Getting Simulation End Time - Gets the simulation end time.

Time endTime = exc.end();
endTime = exc.end()

Running the Simulation

Description C++ Example Python Example

Starting the Simulation - Initializes the simulation executive and its components.

int result = exc.startup();
result = exc.startup()

Stepping the Simulation - Steps the scheduler by a single step.

result = exc.step();
result = exc.step()

Stepping the Simulation with Step Size - Steps the scheduler by a specified step size.

Time stepSize(1);
result = exc.step(stepSize);
stepSize = Time(1);
result = exc.step(stepSize)

Searching

Description C++ Example Python Example

Searching the Simulation Tree - Searches the simulation tree for a match.

std::vector<std::string> results = exc.search("query");
results = exc.search("query")

Searching the Frame Tree - Searches only the frame tree for a match.

std::vector<std::string> results = exc.searchFrameTree("query");
results = exc.searchFrameTree("query")

Searching the Simulation Architecture Tree - Searches the simulation architecture tree for a match.

std::vector<std::string> results = exc.searchSimTree("query");
results = exc.searchSimTree("query")

Logging and Visuals

Description C++ Example Python Example

Adding a Logger with Rate - Registers and sets up a logger with a specified rate in Hz.

CsvLogger logger(...);
exc.addLog(logger, 50);
logger = CsvLogger(...);
exc.addLog(logger, 50)

Enabling Visuals - Enables visuals for the simulation.

exc.enableVisuals();
exc.enableVisuals()

Disabling Visuals - Disables visuals for the simulation.

exc.disableVisuals();
exc.disableVisuals()

Additional Operations

Description C++ Example Python Example

Checking Termination Status - Returns the termination flag of the simulation.

bool terminated = exc.isTerminated();
terminated = exc.isTerminated()

Getting Run Number - Gets the run number for the simulation.

unsigned int runNumber = exc.runNumber();
runNumber = exc.runNumber()

Accessing Arguments - Accesses the arguments of the simulation.

ArgParser* args = exc.args();
args = exc.args()

Accessing Dispersions - Accesses the dispersions of the simulation.

DispersionEngine* dispersions = exc.dispersions();
dispersions = exc.dispersions()