1#ifndef UTOPIA_MODELS_COPYMEGRID_HH
2#define UTOPIA_MODELS_COPYMEGRID_HH
48 if (cfg[
"random_initial_trait"]) {
84 public Model<CopyMeGrid, ModelTypes>
154 template<
class ParentModel>
156 const std::string& name,
190 auto state =
cell->state();
194 state.is_a_vip_cell =
true;
204 this->
_log->debug(
"VIP cells set up.");
212 this->
_log->debug(
"{} model fully set up.", this->
_name);
227 sum +=
cell->state().some_state;
242 auto state =
cell->state();
245 state.some_state += 1;
251 state.some_trait +=
nb->state().some_trait;
269 auto state =
cell->state();
273 state.some_state = 0;
306 this->
_monitor.set_entry(
"some_value", 42);
319 [](
const auto&
cell) {
320 return cell->state().some_state;
325 [](
const auto&
cell) {
326 return cell->state().some_trait;
typename std::function< CellState(const std::shared_ptr< Cell > &)> RuleFunc
The type of a rule function acting on cells of this cell manager.
Definition cell_manager.hh:84
CellContainer< Cell > neighbors_of(const Cell &cell) const
Retrieve the given cell's neighbors.
Definition cell_manager.hh:458
const CellContainer< Cell > & cells() const
Return const reference to the managed CA cells.
Definition cell_manager.hh:219
Base class interface for Models using the CRT Pattern.
Definition model.hh:112
std::shared_ptr< DataSet > create_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.
Definition model.hh:849
Monitor _monitor
The monitor.
Definition model.hh:188
typename ModelTypes::DataSet DataSet
Data type that is used for storing data.
Definition model.hh:125
const Config _cfg
Config node belonging to this model instance.
Definition model.hh:158
const std::string _name
Name of the model instance.
Definition model.hh:149
typename ModelTypes::DataGroup DataGroup
Data type that is used for storing datasets.
Definition model.hh:122
const std::shared_ptr< spdlog::logger > _log
The (model) logger.
Definition model.hh:164
const std::shared_ptr< RNG > _rng
The RNG shared between models.
Definition model.hh:161
The CopyMeGrid Model; a good start for a CA-based model.
Definition CopyMeGrid.hh:85
typename CellManager::RuleFunc RuleFunc
Extract the type of the rule function from the CellManager.
Definition CopyMeGrid.hh:108
const RuleFunc _some_other_rule
Some other rule function.
Definition CopyMeGrid.hh:267
double _some_parameter
Some parameter.
Definition CopyMeGrid.hh:120
CellManager _cm
The cell manager.
Definition CopyMeGrid.hh:117
typename Base::DataGroup DataGroup
Data type of the group to write model data to, holding datasets.
Definition CopyMeGrid.hh:91
std::uniform_real_distribution< double > _prob_distr
A re-usable uniform real distribution to evaluate probabilities.
Definition CopyMeGrid.hh:126
void monitor()
Monitor model information.
Definition CopyMeGrid.hh:305
std::shared_ptr< DataSet > _dset_some_trait
A dataset for storing all cells' some_trait.
Definition CopyMeGrid.hh:139
std::shared_ptr< DataSet > _dset_some_state
A dataset for storing all cells' some_state.
Definition CopyMeGrid.hh:136
void write_data()
Write data.
Definition CopyMeGrid.hh:316
Model< CopyMeGrid, ModelTypes > Base
The type of the Model base class of this derived class.
Definition CopyMeGrid.hh:88
CopyMeGrid(const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={})
Construct the CopyMeGrid model.
Definition CopyMeGrid.hh:155
double calc_some_state_mean() const
Calculate the mean of all cells' some_state.
Definition CopyMeGrid.hh:224
void perform_step()
Iterate a single step.
Definition CopyMeGrid.hh:289
const RuleFunc _some_interaction
An interaction function of a single cell with its neighbors.
Definition CopyMeGrid.hh:240
typename Base::DataSet DataSet
Data type for a dataset.
Definition CopyMeGrid.hh:94
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:71
ReturnType get_as(const std::string &key, const DataIO::Config &node)
This function is a wrapper around the yaml-cpp YAML::Node::as function.
Definition cfg_utils.hh:158
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
void apply_rule(Rule &&rule, const ContTarget &cont_target, ContArgs &&... cont_args)
Sequential overload.
Definition apply.hh:133
Definition CopyMeGrid.hh:16
The entity traits struct gathers types to be used for specializing an entity.
Definition entity.hh:49
Wrapper struct for defining model class data types.
Definition model.hh:92
The type of a cell's state.
Definition CopyMeGrid.hh:21
int some_trait
Another useful documentation string, yeah.
Definition CopyMeGrid.hh:26
double some_state
A useful documentation string.
Definition CopyMeGrid.hh:23
CellState(const DataIO::Config &cfg, const std::shared_ptr< RNG > &rng)
Construct the cell state from a configuration and an RNG.
Definition CopyMeGrid.hh:41
CellState(const DataIO::Config &cfg)
Construct the cell state from a configuration.
Definition CopyMeGrid.hh:32
bool is_a_vip_cell
Whether this cell is very important.
Definition CopyMeGrid.hh:29