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

The SimpleFlocking Model. More...

#include <SimpleFlocking.hh>

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

Public Types

using Base = Model< SimpleFlocking, ModelTypes >
 The type of the Model base class of this derived class. More...
 
using AgentManager = Utopia::AgentManager< AgentTraits, SimpleFlocking >
 The type of the agent manager. More...
 
using Agent = AgentManager::Agent
 Agent type. More...
 
using AgentPtr = std::shared_ptr< Agent >
 Pointer to agent. More...
 
using Rule = typename AgentManager::RuleFunc
 Type of the update rules for agents. More...
 
using VoidRule = typename AgentManager::VoidRuleFunc
 Type of the update rules for agents where no state is to be returned. More...
 
using SpaceVec = typename AgentManager::SpaceVec
 Type of spatial vectors within the domain. More...
 
using DataSet = typename Base::DataSet
 Data type for a dataset. More...
 
- Public Types inherited from Utopia::Model< SimpleFlocking, ModelTypes >
using Config = typename ModelTypes::Config
 Data type that holds the configuration. More...
 
using DataManager = DataIO::Default::DefaultDataManager< SimpleFlocking >
 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 >
 SimpleFlocking (const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={})
 Construct the SimpleFlocking model instance. More...
 
void perform_step ()
 Iterate a single step: adjust agent orientation, then move all agents. More...
 
void monitor ()
 Monitor the model state. More...
 
void write_data ()
 Write data. More...
 
std::size_t num_agents () const
 The number of agents in the system (typically constant) More...
 
void set_agent_speed (const double new_speed)
 Sets the speed value of all agents. More...
 
double norm_group_velocity () const
 The normalized absolute group velocity. More...
 
template<class Adapter , class ValueType = std::invoke_result_t<Adapter, const AgentPtr&>>
std::vector< ValueType > get_from_agents (const Adapter &adapter) const
 Aggregate agent properties into a container. More...
 
- Public Member Functions inherited from Utopia::Model< SimpleFlocking, ModelTypes >
 Model (const std::string &name, const ParentModel &parent_model, const Config &custom_cfg={}, std::tuple< WriterArgs... > w_args={}, const DataIO::Default::DefaultDecidermap< SimpleFlocking > &w_deciders=DataIO::Default::default_deciders< SimpleFlocking >, const DataIO::Default::DefaultTriggermap< SimpleFlocking > &w_triggers=DataIO::Default::default_triggers< SimpleFlocking >)
 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...
 

Public Attributes

const Rule _adjust_orientation
 Rule that sets agent orientation to the mean orientation (in a radius) More...
 
const VoidRule _move
 Rule that applies the current displacement vector to the agent position. More...
 

Private Attributes

AgentManager _am
 The agent manager. More...
 
double _speed
 The global speed value, used as the uniform speed of all agents. More...
 
double _interaction_radius
 The radius within which agents interact with each other. More...
 
double _noise_level
 The amplitude of the noise applied to the orientation update. More...
 
std::uniform_real_distribution< double > _noise_distr
 The distribution used for determining the orientation noise. More...
 
bool _store_agent_data
 Whether to store agent-specific data. More...
 
std::shared_ptr< DataSet_dset_agent_x
 
std::shared_ptr< DataSet_dset_agent_y
 
std::shared_ptr< DataSet_dset_agent_orientation
 
std::shared_ptr< DataSet_dset_orientation_circmean
 
std::shared_ptr< DataSet_dset_orientation_circstd
 
std::shared_ptr< DataSet_dset_norm_group_velocity
 

Additional Inherited Members

- Protected Member Functions inherited from Utopia::Model< SimpleFlocking, 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...
 
SimpleFlocking & impl ()
 cast to the derived class More...
 
const SimpleFlocking & impl () const
 const cast to the derived interface More...
 
- Protected Attributes inherited from Utopia::Model< SimpleFlocking, 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< SimpleFlocking, ModelTypes >
static constexpr WriteMode _write_mode
 Which data-writing mode the base model should use. More...
 

Detailed Description

The SimpleFlocking Model.

An agent-based model of spatial collective dynamics, akin to those observed in bird flocks or fish schools.

These dynamics arise as a result of agents adjusting their orientation according to that of nearby agents.

Member Typedef Documentation

◆ Agent

Agent type.

◆ AgentManager

The type of the agent manager.

◆ AgentPtr

Pointer to agent.

◆ Base

The type of the Model base class of this derived class.

◆ DataSet

Data type for a dataset.

◆ Rule

Type of the update rules for agents.

◆ SpaceVec

Type of spatial vectors within the domain.

◆ VoidRule

Type of the update rules for agents where no state is to be returned.

Constructor & Destructor Documentation

◆ SimpleFlocking()

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

Construct the SimpleFlocking model instance.

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

◆ get_from_agents()

template<class Adapter , class ValueType = std::invoke_result_t<Adapter, const AgentPtr&>>
std::vector<ValueType> Utopia::Models::SimpleFlocking::SimpleFlocking::get_from_agents ( const Adapter &  adapter) const
inline

Aggregate agent properties into a container.

◆ monitor()

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

Monitor the model state.

This monitor provides information about the current orientation's (circular) mean and standard deviation. In addition, the normalized group velocity is monitored, which represents the system's order parameter.

◆ norm_group_velocity()

double Utopia::Models::SimpleFlocking::SimpleFlocking::norm_group_velocity ( ) const
inline

The normalized absolute group velocity.

Computed by dividing the absolute group velocity of all agents by the absolute speed. This represents the order parameter of the system.

Note
The computation assumes that all agents have the same speed (as indicated by the _speed member). If this is not the case, the result will be erroneous! For performance reasons, no check for uniform agent velocities is carried out.

◆ num_agents()

std::size_t Utopia::Models::SimpleFlocking::SimpleFlocking::num_agents ( ) const
inline

The number of agents in the system (typically constant)

◆ perform_step()

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

Iterate a single step: adjust agent orientation, then move all agents.

These rules are both applied synchronously to all agents.

◆ set_agent_speed()

void Utopia::Models::SimpleFlocking::SimpleFlocking::set_agent_speed ( const double  new_speed)
inline

Sets the speed value of all agents.

◆ write_data()

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

Write data.

Member Data Documentation

◆ _adjust_orientation

const Rule Utopia::Models::SimpleFlocking::SimpleFlocking::_adjust_orientation

Rule that sets agent orientation to the mean orientation (in a radius)

The orientation of the current agent is included into the calculation of the mean orientation.

Currently uses a

◆ _am

AgentManager Utopia::Models::SimpleFlocking::SimpleFlocking::_am
private

The agent manager.

◆ _dset_agent_orientation

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_agent_orientation
private

◆ _dset_agent_x

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_agent_x
private

◆ _dset_agent_y

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_agent_y
private

◆ _dset_norm_group_velocity

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_norm_group_velocity
private

◆ _dset_orientation_circmean

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_orientation_circmean
private

◆ _dset_orientation_circstd

std::shared_ptr<DataSet> Utopia::Models::SimpleFlocking::SimpleFlocking::_dset_orientation_circstd
private

◆ _interaction_radius

double Utopia::Models::SimpleFlocking::SimpleFlocking::_interaction_radius
private

The radius within which agents interact with each other.

◆ _move

const VoidRule Utopia::Models::SimpleFlocking::SimpleFlocking::_move
Initial value:
= [this](const auto& agent){
this->_am.move_by(agent, agent->state().get_displacement());
}
void move_by(const std::shared_ptr< Agent > &agent, const SpaceVec &move_vec) const
Move an agent relative to its current position.
Definition: agent_manager.hh:214
AgentManager _am
The agent manager.
Definition: SimpleFlocking.hh:72

Rule that applies the current displacement vector to the agent position.

◆ _noise_distr

std::uniform_real_distribution<double> Utopia::Models::SimpleFlocking::SimpleFlocking::_noise_distr
private

The distribution used for determining the orientation noise.

◆ _noise_level

double Utopia::Models::SimpleFlocking::SimpleFlocking::_noise_level
private

The amplitude of the noise applied to the orientation update.

◆ _speed

double Utopia::Models::SimpleFlocking::SimpleFlocking::_speed
private

The global speed value, used as the uniform speed of all agents.

◆ _store_agent_data

bool Utopia::Models::SimpleFlocking::SimpleFlocking::_store_agent_data
private

Whether to store agent-specific data.


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