Class Simulation

Nested Relationships

Nested Types

Inheritance Relationships

Derived Type

Class Documentation

class Simulation

Abstract representation of a ModelDescription that can be executed

See also

CUDASimulation The CUDA implementation of a Simulation

Subclassed by flamegpu::CUDASimulation

Public Functions

virtual ~Simulation() = default
explicit Simulation(const std::shared_ptr<const ModelData> &model)

This constructor takes a clone of the ModelData hierarchy

void initialise(int argc, const char **argv)
virtual void initFunctions() = 0
virtual bool step() = 0
virtual void exitFunctions() = 0
virtual void simulate() = 0
void reset()

Returns the simulation to a clean state This clears all agents and message lists, resets environment properties and reseeds random generation. Also calls resetStepCounter();

Note

If triggered on a submodel, agent states and environment properties mapped to a parent agent, and random generation are not affected.

Note

If random was manually seeded, it will return to it’s original state. If random was seeded from time, it will return to a new random state.

virtual unsigned int getStepCounter() = 0
virtual void resetStepCounter() = 0
const ModelData &getModelDescription() const
void exportData(const std::string &path, bool prettyPrint = true)

Export model state to file Export includes config structures, environment and agent data

Note

XML export does not currently includes config structures, only the same data present in FLAMEGPU1

Parameters:
  • path – The file to output (must end ‘.json’ or ‘.xml’)

  • prettyPrint – Whether to include indentation and line breaks to aide human reading

void exportLog(const std::string &path, bool steps, bool exit, bool stepTime, bool exitTime, bool prettyPrint = true)

Export the data logged by the last call to simulate() (and/or step) to the given path

Note

The config (possibly just random seed) is always output

Parameters:
  • path – The file to output (must end ‘.json’ or ‘.xml’)

  • steps – Whether the step log should be included in the log file

  • exit – Whether the exit log should be included in the log file

  • stepTime – Whether the step time should be included in the log file (always treated as false if steps=false)

  • exitTime – Whether the simulation time should be included in the log file (always treated as false if exit=false)

  • prettyPrint – Whether the log file should be minified or not

virtual void setPopulationData(AgentVector &population, const std::string &state_name = ModelData::DEFAULT_STATE) = 0
virtual void getPopulationData(AgentVector &population, const std::string &state_name = ModelData::DEFAULT_STATE) = 0
virtual const RunLog &getRunLog() const = 0
Config &SimulationConfig()
const Config &getSimulationConfig() const
void applyConfig()

Protected Functions

explicit Simulation(const std::shared_ptr<SubModelData> &sub_model, CUDASimulation *master_model)

This constructor is for use with submodels, it does not call clone Additionally sets the submodel ptr

virtual void reset(bool submodelReset) = 0

Returns the model to a clean state This clears all agents and message lists, resets environment properties and reseeds random generation. Also calls resetStepCounter();

Note

If triggered on a submodel, agent states and environment properties mapped to a parent agent, and random generation are not affected.

Note

If random was manually seeded, it will return to it’s original state. If random was seeded from time, it will return to a new random state.

Parameters:

submodelReset – This should only be set to true when called automatically when a submodel reaches it’s exit condition during execution. This performs a subset of the regular reset procedure.

virtual void applyConfig_derived() = 0
virtual bool checkArgs_derived(int argc, const char **argv, int &i) = 0
virtual void printHelp_derived() = 0
inline unsigned int getInstanceID() const

Returns the unique instance id of this CUDASimulation instance

virtual std::shared_ptr<detail::EnvironmentManager> getEnvironment() const = 0

Returns the environment manager

virtual std::shared_ptr<const detail::CUDAMacroEnvironment> getMacroEnvironment() const = 0
inline unsigned int getMaximumLayerWidth() const

returns the width of the widest layer in model.

Returns:

the width of the widest layer.

Protected Attributes

const std::shared_ptr<const ModelData> model
const std::shared_ptr<const SubModelData> submodel

This is only used when model is a submodel, otherwise it is empty If it is set, it causes simulate() to additionally reset/cull unmapped populations

CUDASimulation const *mastermodel

Only used by submodels, only required to fetch the name of master model when initialising environment (as this occurs after constructor)

Config config
std::string loaded_input_file

If this matches config.input_file, apply_config() will not load the input file

const unsigned int instance_id

Unique index of Simulation instance

std::unordered_map<std::string, detail::Any> env_init

Initial environment items if they have been loaded from file, prior to device selection

std::unordered_map<std::string, std::vector<char>> macro_env_init

Initial macro environment items if they have been loaded from file, prior to device selection

unsigned int maxLayerWidth

the width of the widest layer in the concrete version of the model (calculated once)

struct Config

General simulation runner specific config

Public Functions

Config()
inline void operator=(const Config &other)

Public Members

std::string input_file
std::string step_log_file
std::string exit_log_file
std::string common_log_file
bool truncate_log_files = false
uint64_t random_seed
unsigned int steps = 1
flamegpu::Verbosity verbosity = Verbosity::Default
bool timing = false
bool silence_unknown_args = false
bool telemetry = false
bool console_mode = false