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::Opinionet::Opinionet< NWType > Class Template Reference

The Opinionet model class. More...

#include <Opinionet.hh>

Inheritance diagram for Utopia::Models::Opinionet::Opinionet< NWType >:
Inheritance graph
[legend]
Collaboration diagram for Utopia::Models::Opinionet::Opinionet< NWType >:
Collaboration graph
[legend]

Public Types

using Base = Model< Opinionet, OpinionetTypes >
 The base model type. More...
 
using Config = typename Base::Config
 Data type that holds the configuration. More...
 
using DataGroup = typename Base::DataGroup
 Data type of the group to write model data to, holding datasets. More...
 
using DataSet = typename Base::DataSet
 Data type for a dataset. More...
 
using RNG = typename Base::RNG
 Data type of the shared RNG. More...
 
- Public Types inherited from Utopia::Model< Opinionet< NetworkUndirected >, OpinionetTypes >
using Config = typename ModelTypes::Config
 Data type that holds the configuration. More...
 
using DataManager = DataIO::Default::DefaultDataManager< Opinionet< NetworkUndirected > >
 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 >
 Opinionet (const std::string name, ParentModel &parent)
 Construct the Opinionet model. More...
 
void perform_step ()
 Iterate a single step @detail Each step consists of an opinion update and edge rewiring. Opinion update: Apply the interaction function to a randomly chosen vertex. Rewiring (if enabled): Rewire a random edge based on selective exposure. More...
 
void monitor ()
 Monitor model information. More...
 
void write_data ()
 Write data. More...
 
- Public Member Functions inherited from Utopia::Model< Opinionet< NetworkUndirected >, OpinionetTypes >
 Model (const std::string &name, const ParentModel &parent_model, const Config &custom_cfg={}, std::tuple< WriterArgs... > w_args={}, const DataIO::Default::DefaultDecidermap< Opinionet< NetworkUndirected > > &w_deciders=DataIO::Default::default_deciders< Opinionet< NetworkUndirected > >, const DataIO::Default::DefaultTriggermap< Opinionet< NetworkUndirected > > &w_triggers=DataIO::Default::default_triggers< Opinionet< NetworkUndirected > >)
 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

Interaction_type initialize_interaction ()
 
Opinion_space_type initialize_opinion_space ()
 
Rewiring initialize_rewiring ()
 
void initialize_properties ()
 
NWType initialize_nw () const
 
std::shared_ptr< DataSetcreate_edge_weight_dset ()
 

Private Attributes

const Interaction_type _interaction
 Modes. More...
 
const Opinion_space_type _opinion_space
 
const Rewiring _rewire
 
NWType _nw
 Network and model dynamics parameters. More...
 
const double _tolerance
 
const double _susceptibility
 
const double _weighting
 
std::uniform_real_distribution< double > _uniform_prob_distr
 A uniform probability distribution. More...
 
const std::shared_ptr< DataGroup_dgrp_nw
 
const std::shared_ptr< DataSet_dset_opinion
 
const std::shared_ptr< DataSet_dset_edge_weights
 

Additional Inherited Members

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

Detailed Description

template<typename NWType = NetworkUndirected>
class Utopia::Models::Opinionet::Opinionet< NWType >

The Opinionet model class.

This is a 1d opinion dynamics model with interactions based on bounded confidence.

Member Typedef Documentation

◆ Base

template<typename NWType = NetworkUndirected>
using Utopia::Models::Opinionet::Opinionet< NWType >::Base = Model<Opinionet, OpinionetTypes>

The base model type.

◆ Config

template<typename NWType = NetworkUndirected>
using Utopia::Models::Opinionet::Opinionet< NWType >::Config = typename Base::Config

Data type that holds the configuration.

◆ DataGroup

template<typename NWType = NetworkUndirected>
using Utopia::Models::Opinionet::Opinionet< NWType >::DataGroup = typename Base::DataGroup

Data type of the group to write model data to, holding datasets.

◆ DataSet

template<typename NWType = NetworkUndirected>
using Utopia::Models::Opinionet::Opinionet< NWType >::DataSet = typename Base::DataSet

Data type for a dataset.

◆ RNG

template<typename NWType = NetworkUndirected>
using Utopia::Models::Opinionet::Opinionet< NWType >::RNG = typename Base::RNG

Data type of the shared RNG.

Constructor & Destructor Documentation

◆ Opinionet()

template<typename NWType = NetworkUndirected>
template<class ParentModel >
Utopia::Models::Opinionet::Opinionet< NWType >::Opinionet ( const std::string  name,
ParentModel &  parent 
)
inline

Construct the Opinionet model.

Parameters
nameName of this model instance
parentThe parent model this model instance resides in

Member Function Documentation

◆ create_edge_weight_dset()

template<typename NWType = NetworkUndirected>
std::shared_ptr<DataSet> Utopia::Models::Opinionet::Opinionet< NWType >::create_edge_weight_dset ( )
inlineprivate

◆ initialize_interaction()

template<typename NWType = NetworkUndirected>
Interaction_type Utopia::Models::Opinionet::Opinionet< NWType >::initialize_interaction ( )
inlineprivate

◆ initialize_nw()

template<typename NWType = NetworkUndirected>
NWType Utopia::Models::Opinionet::Opinionet< NWType >::initialize_nw ( ) const
inlineprivate

◆ initialize_opinion_space()

template<typename NWType = NetworkUndirected>
Opinion_space_type Utopia::Models::Opinionet::Opinionet< NWType >::initialize_opinion_space ( )
inlineprivate

◆ initialize_properties()

template<typename NWType = NetworkUndirected>
void Utopia::Models::Opinionet::Opinionet< NWType >::initialize_properties ( )
inlineprivate

◆ initialize_rewiring()

template<typename NWType = NetworkUndirected>
Rewiring Utopia::Models::Opinionet::Opinionet< NWType >::initialize_rewiring ( )
inlineprivate

◆ monitor()

template<typename NWType = NetworkUndirected>
void Utopia::Models::Opinionet::Opinionet< NWType >::monitor ( )
inline

Monitor model information.

@detail Here, functions and values can be supplied to the monitor that are then available to the frontend. The monitor() function is only called if a certain emit interval has passed; thus, the performance hit is small.

◆ perform_step()

template<typename NWType = NetworkUndirected>
void Utopia::Models::Opinionet::Opinionet< NWType >::perform_step ( )
inline

Iterate a single step @detail Each step consists of an opinion update and edge rewiring. Opinion update: Apply the interaction function to a randomly chosen vertex. Rewiring (if enabled): Rewire a random edge based on selective exposure.

◆ write_data()

template<typename NWType = NetworkUndirected>
void Utopia::Models::Opinionet::Opinionet< NWType >::write_data ( )
inline

Write data.

Member Data Documentation

◆ _dgrp_nw

template<typename NWType = NetworkUndirected>
const std::shared_ptr<DataGroup> Utopia::Models::Opinionet::Opinionet< NWType >::_dgrp_nw
private

◆ _dset_edge_weights

template<typename NWType = NetworkUndirected>
const std::shared_ptr<DataSet> Utopia::Models::Opinionet::Opinionet< NWType >::_dset_edge_weights
private

◆ _dset_opinion

template<typename NWType = NetworkUndirected>
const std::shared_ptr<DataSet> Utopia::Models::Opinionet::Opinionet< NWType >::_dset_opinion
private

◆ _interaction

template<typename NWType = NetworkUndirected>
const Interaction_type Utopia::Models::Opinionet::Opinionet< NWType >::_interaction
private

◆ _nw

template<typename NWType = NetworkUndirected>
NWType Utopia::Models::Opinionet::Opinionet< NWType >::_nw
private

Network and model dynamics parameters.

◆ _opinion_space

template<typename NWType = NetworkUndirected>
const Opinion_space_type Utopia::Models::Opinionet::Opinionet< NWType >::_opinion_space
private

◆ _rewire

template<typename NWType = NetworkUndirected>
const Rewiring Utopia::Models::Opinionet::Opinionet< NWType >::_rewire
private

◆ _susceptibility

template<typename NWType = NetworkUndirected>
const double Utopia::Models::Opinionet::Opinionet< NWType >::_susceptibility
private

◆ _tolerance

template<typename NWType = NetworkUndirected>
const double Utopia::Models::Opinionet::Opinionet< NWType >::_tolerance
private

◆ _uniform_prob_distr

template<typename NWType = NetworkUndirected>
std::uniform_real_distribution<double> Utopia::Models::Opinionet::Opinionet< NWType >::_uniform_prob_distr
private

A uniform probability distribution.

◆ _weighting

template<typename NWType = NetworkUndirected>
const double Utopia::Models::Opinionet::Opinionet< NWType >::_weighting
private

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