-
Notifications
You must be signed in to change notification settings - Fork 13
9. Running Simulations
Román Cárdenas edited this page Aug 2, 2022
·
6 revisions
Simulating DEVS (and Cell-DEVS) models is Cadmium is pretty straightforward.
We will illustrate it with the GPT model.
We will run the simulation
This is the simplest approach to simulate a DEVS model.
#include <cadmium/core/logger/csv.hpp> // To import a CSV logger (to store simulation results in CSV file)
#include <cadmium/core/simulation/root_coordinator.hpp> // To import the root coordinator
#include <limits>
#include "gpt.hpp"
int main() {
// model-related configuration parameters
int jobPeriod = 3;
int processingTime = 1;
double obsTime = 102.;
// We create the model and forward it to the root coordinator
// NOTE THAT WE NEED A POINTER TO THE MODEL!
auto model = std::make_shared<GPT>("gpt", jobPeriod, processingTime, obsTime);
auto rootCoordinator = cadmium::RootCoordinator(model);
// We can add a logger to the root coordinator
// In this example, we use a CSV logger that uses ; to separate columns.
// Simulation results will be stored in the log_gpt.csv file.
auto logger = std::make_shared<cadmium::CSVLogger>("log_gpt.csv", ";");
rootCoordinator.setLogger(logger);
// To start the simulation we 1) start, 2) simulate 3) stop.
rootCoordinator.start();
// in simulate method, we can select a maximum simulation time (in this case, infinity)
rootCoordinator.simulate(std::numeric_limits<double>::infinity());
rootCoordinator.stop();
return 0;
}To do.
To do.