Utopia  2
Framework for studying models of complex & adaptive systems.
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Utopia::Models::ForestFire::ForestFire Class Reference

The ForestFire model. More...

#include <ForestFire.hh>

Inheritance diagram for Utopia::Models::ForestFire::ForestFire:
Inheritance graph
[legend]
Collaboration diagram for Utopia::Models::ForestFire::ForestFire:
Collaboration graph
[legend]

Public Types

using Base = Model< ForestFire, ModelTypes >
 The base model type. More...
 
using DataSet = typename Base::DataSet
 Data type for a dataset. More...
 
using CellManager = Utopia::CellManager< CellTraits, ForestFire >
 The type of the cell manager. More...
 
using Cell = typename CellManager::Cell
 The type of a cell. More...
 
using RuleFunc = typename CellManager::RuleFunc
 Rule function type, extracted from CellManager. More...
 
- Public Types inherited from Utopia::Model< ForestFire, ModelTypes >
using Config = typename ModelTypes::Config
 Data type that holds the configuration. More...
 
using DataManager = DataIO::Default::DefaultDataManager< ForestFire >
 The data manager to use, specialized with the derived model. More...
 
using DataGroup = typename ModelTypes::DataGroup
 Data type that is used for storing datasets. More...
 
using DataSet = typename ModelTypes::DataSet
 Data type that is used for storing data. More...
 
using RNG = typename ModelTypes::RNG
 Data type of the shared RNG. More...
 
using Space = typename ModelTypes::Space
 Data type of the space this model resides in. More...
 
using Time = typename ModelTypes::Time
 Data type for the model time. More...
 
using Monitor = typename ModelTypes::Monitor
 Data type for the monitor. More...
 
using MonitorManager = typename ModelTypes::MonitorManager
 Data type for the monitor manager. More...
 
using Level = typename ModelTypes::Level
 Data type for the hierarchical level. More...
 

Public Member Functions

template<class ParentModel >
 ForestFire (const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={})
 Construct the ForestFire model. More...
 
void perform_step ()
 Perform step. More...
 
void monitor ()
 Provide monitoring information to the frontend: tree_density More...
 
void write_data ()
 Write data. More...
 
- Public Member Functions inherited from Utopia::Model< ForestFire, ModelTypes >
 Model (const std::string &name, const ParentModel &parent_model, const Config &custom_cfg={}, std::tuple< WriterArgs... > w_args={}, const DataIO::Default::DefaultDecidermap< ForestFire > &w_deciders=DataIO::Default::default_deciders< ForestFire >, const DataIO::Default::DefaultTriggermap< ForestFire > &w_triggers=DataIO::Default::default_triggers< ForestFire >)
 Constructs a Model instance. More...
 
const std::shared_ptr< Space > & get_space () const
 Return the space this model resides in. More...
 
Time get_time () const
 Return the current time of this model. More...
 
Time get_time_max () const
 Return the maximum time possible for this model. More...
 
Config get_cfg () const
 Return the config node of this model. More...
 
std::string get_name () const
 Return the name of this model instance. More...
 
std::string get_full_name () const
 Return the full name of this model within the model hierarchy. More...
 
std::shared_ptr< DataGroupget_hdfgrp () const
 Return a pointer to the HDF group this model stores data in. More...
 
Time get_write_start () const
 Return the parameter that controls when write_data is called first. More...
 
Time get_write_every () const
 Return the parameter that controls how often write_data is called. More...
 
DataManager get_datamanager () const
 return the datamanager More...
 
hsize_t get_remaining_num_writes () const
 Return the number of remaining write_data calls this model will make. More...
 
std::shared_ptr< RNGget_rng () const
 Return a pointer to the shared RNG. More...
 
std::shared_ptr< spdlog::logger > get_logger () const
 Return a pointer to the logger of this model. More...
 
Monitor get_monitor () const
 Return the monitor of this model. More...
 
std::shared_ptr< MonitorManagerget_monitor_manager () const
 Get the monitor manager of the root model. More...
 
Level get_level () const
 Return the hierarchical level within the model hierarchy. More...
 
virtual void prolog ()
 A function that is called before starting model iteration. More...
 
virtual void epilog ()
 A function that is called after the last iteration of a model. More...
 
void iterate ()
 Iterate one (time) step of this model. More...
 
void run ()
 Run the model from the current time to the maximum time. More...
 
std::shared_ptr< DataSetcreate_dset (const std::string name, const std::shared_ptr< DataGroup > &hdfgrp, std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a new dataset within the given group. More...
 
std::shared_ptr< DataSetcreate_dset (const std::string name, const std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a new dataset within the model's base data group. More...
 
std::shared_ptr< DataSetcreate_cm_dset (const std::string name, const CellManager &cm, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a dataset storing data from a CellManager. More...
 
std::shared_ptr< DataSetcreate_am_dset (const std::string name, const AgentManager &am, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={})
 Create a dataset storing data from a AgentManager. More...
 

Private Member Functions

double calculate_tree_density () const
 Calculate and return the density of tree cells. More...
 
unsigned int identify_clusters ()
 Identifies clusters in the cells and labels them with corresponding IDs. More...
 

Private Attributes

CellManager _cm
 The cell manager for the forest fire model. More...
 
const Param _param
 Model parameters. More...
 
std::uniform_real_distribution< double > _prob_distr
 A [0,1]-range uniform distribution used for evaluating probabilities. More...
 
unsigned int _cluster_id_cnt
 The incremental cluster tag caching variable. More...
 
std::vector< std::shared_ptr< CellManager::Cell > > _cluster_members
 A temporary container for use in cluster identification. More...
 
const bool _write_only_tree_density
 Whether to only write the tree density. More...
 
const std::shared_ptr< DataSet_dset_kind
 The dataset that stores the kind for each cell, e.g. Kind::tree. More...
 
const std::shared_ptr< DataSet_dset_age
 2D dataset (tree age and time) of cells More...
 
const std::shared_ptr< DataSet_dset_cluster_id
 The dataset that stores the cluster id. More...
 
const std::shared_ptr< DataSet_dset_tree_density
 The dataset that stores the mean density. More...
 
RuleFunc _update
 Update rule, called every step. More...
 
RuleFunc _burn_cluster
 Rule to burn a cluster of trees around the given cell. More...
 
RuleFunc _identify_cluster
 Get the identity of each cluster of trees. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Utopia::Model< ForestFire, ModelTypes >
void __perform_step ()
 Perform the computation of a step. More...
 
void __monitor ()
 Monitor information in the terminal. More...
 
void __write_data ()
 Write data; calls the implementation's write_data method. More...
 
void __write_initial_state ()
 Write the initial state. More...
 
void increment_time (const Time dt=1)
 Increment time. More...
 
void __prolog ()
 The default prolog of a model. More...
 
void __epilog ()
 The default epilog of a model. More...
 
ForestFire & impl ()
 cast to the derived class More...
 
const ForestFire & impl () const
 const cast to the derived interface More...
 
- Protected Attributes inherited from Utopia::Model< ForestFire, ModelTypes >
const std::string _name
 Name of the model instance. More...
 
const std::string _full_name
 The full name within the model hierarchy. More...
 
const Level _level
 The level within the model hierarchy. More...
 
const Config _cfg
 Config node belonging to this model instance. More...
 
const std::shared_ptr< RNG_rng
 The RNG shared between models. More...
 
const std::shared_ptr< spdlog::logger > _log
 The (model) logger. More...
 
std::shared_ptr< Space_space
 The space this model resides in. More...
 
Time _time
 Model-internal current time stamp. More...
 
const Time _time_max
 Model-internal maximum time stamp. More...
 
const std::shared_ptr< DataGroup_hdfgrp
 The HDF group this model instance should write its data to. More...
 
const Time _write_start
 First time at which write_data is called. More...
 
const Time _write_every
 How often to call write_data from iterate. More...
 
Monitor _monitor
 The monitor. More...
 
DataManager _datamanager
 Manager object for handling data output; see DataManager. More...
 
- Static Protected Attributes inherited from Utopia::Model< ForestFire, ModelTypes >
static constexpr WriteMode _write_mode
 Which data-writing mode the base model should use. More...
 

Detailed Description

The ForestFire model.

The ForestFire model simulates the development of a forest under influence of fires. Trees grow randomly and lightning strikes lead to a whole cluster instantaneously burning down. This is the so-called two state model.

Member Typedef Documentation

◆ Base

The base model type.

◆ Cell

The type of a cell.

◆ CellManager

The type of the cell manager.

◆ DataSet

Data type for a dataset.

◆ RuleFunc

Rule function type, extracted from CellManager.

Constructor & Destructor Documentation

◆ ForestFire()

template<class ParentModel >
Utopia::Models::ForestFire::ForestFire::ForestFire ( const std::string &  name,
ParentModel &  parent_model,
const DataIO::Config custom_cfg = {} 
)
inline

Construct the ForestFire model.

Parameters
nameName of this model instance; is used to extract the configuration from the parent model and set up a HDFGroup for this instance
parent_modelThe parent model this model instance resides in
custom_cfgA custom configuration to use instead of the one extracted from the parent model using the instance name

Member Function Documentation

◆ calculate_tree_density()

double Utopia::Models::ForestFire::ForestFire::calculate_tree_density ( ) const
inlineprivate

Calculate and return the density of tree cells.

◆ identify_clusters()

unsigned int Utopia::Models::ForestFire::ForestFire::identify_clusters ( )
inlineprivate

Identifies clusters in the cells and labels them with corresponding IDs.

This function updates the cluster ID of each cell. This only applies to cells that are trees; all others keep ID 0.

Returns
Number of clusters identified

◆ monitor()

void Utopia::Models::ForestFire::ForestFire::monitor ( )
inline

Provide monitoring information to the frontend: tree_density

◆ perform_step()

void Utopia::Models::ForestFire::ForestFire::perform_step ( )
inline

Perform step.

◆ write_data()

void Utopia::Models::ForestFire::ForestFire::write_data ( )
inline

Write data.

Member Data Documentation

◆ _burn_cluster

RuleFunc Utopia::Models::ForestFire::ForestFire::_burn_cluster
private

Rule to burn a cluster of trees around the given cell.

Note
This function is never actually called via apply_rule, but only from the update method. It relies on an asynchronous cell update.

◆ _cluster_id_cnt

unsigned int Utopia::Models::ForestFire::ForestFire::_cluster_id_cnt
private

The incremental cluster tag caching variable.

◆ _cluster_members

std::vector<std::shared_ptr<CellManager::Cell> > Utopia::Models::ForestFire::ForestFire::_cluster_members
private

A temporary container for use in cluster identification.

◆ _cm

CellManager Utopia::Models::ForestFire::ForestFire::_cm
private

The cell manager for the forest fire model.

◆ _dset_age

const std::shared_ptr<DataSet> Utopia::Models::ForestFire::ForestFire::_dset_age
private

2D dataset (tree age and time) of cells

◆ _dset_cluster_id

const std::shared_ptr<DataSet> Utopia::Models::ForestFire::ForestFire::_dset_cluster_id
private

The dataset that stores the cluster id.

◆ _dset_kind

const std::shared_ptr<DataSet> Utopia::Models::ForestFire::ForestFire::_dset_kind
private

The dataset that stores the kind for each cell, e.g. Kind::tree.

◆ _dset_tree_density

const std::shared_ptr<DataSet> Utopia::Models::ForestFire::ForestFire::_dset_tree_density
private

The dataset that stores the mean density.

◆ _identify_cluster

RuleFunc Utopia::Models::ForestFire::ForestFire::_identify_cluster
private

Get the identity of each cluster of trees.

◆ _param

const Param Utopia::Models::ForestFire::ForestFire::_param
private

Model parameters.

◆ _prob_distr

std::uniform_real_distribution<double> Utopia::Models::ForestFire::ForestFire::_prob_distr
private

A [0,1]-range uniform distribution used for evaluating probabilities.

◆ _update

RuleFunc Utopia::Models::ForestFire::ForestFire::_update
private

Update rule, called every step.

The possible transitions are the following:

- empty -> tree (with p_growth)
- tree -> burning (with p_lightning)

A burning tree directly invokes the burning of the whole cluster of connected trees ("two-state FFM"). After that, all burned cells are in the empty state again.

Additionally, some trees are constantly ignited and will always lead to the burning of the adjacent cluster. Other cells ("stones") do not take part in interactions at all.

Note
This rule relies on an asynchronous cell update.

◆ _write_only_tree_density

const bool Utopia::Models::ForestFire::ForestFire::_write_only_tree_density
private

Whether to only write the tree density.


The documentation for this class was generated from the following file: