1#ifndef UTOPIA_MODELS_OPINIONET_REVISION
2#define UTOPIA_MODELS_OPINIONET_REVISION
19template<
typename NWType,
typename VertexDescType>
32 if constexpr (Utils::is_directed<NWType>()) {
45 expectation *=
static_cast<double>(boost::out_degree(
v, nw)) /
56 auto nb = boost::target(
e, nw);
77 nw[
v].opinion =
round(nw[
v].opinion);
82template<
typename NWType,
typename RNGType,
typename VertexDescType>
89 std::uniform_real_distribution<double>&
prob_distr,
100 nw[
v].opinion = nw[
nb].opinion;
117template<
typename NWType,
typename RNGType>
121 const double weighting,
124 using namespace boost;
128 const auto s = source(
e, nw);
138 if constexpr (Utils::is_directed<NWType>()) {
148template<
typename NWType,
typename RNGType>
153 const double weighting,
157 std::uniform_real_distribution<double>&
prob_distr,
161 const auto v = boost::random_vertex(nw,
rng);
163 if (boost::out_degree(
v, nw) != 0) {
165 if (
interaction == Interaction_type::HegselmannKrause) {
171 else if (
interaction == Interaction_type::Deffuant) {
178 if constexpr (Utils::is_directed<NWType>()) {
183 if (
rewire == Rewiring::RewiringOn) {
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
Opinion_space_type
Definition modes.hh:13
Interaction_type
Definition modes.hh:8
Rewiring
Definition modes.hh:18
Definition revision.hh:10
std::uniform_real_distribution< double > prob_distr
Definition test_revision.cc:18
void rewire_random_edge(NWType &nw, const double tolerance, const double weighting, RNGType &rng)
Definition revision.hh:118
void update_opinion_HK(const VertexDescType v, NWType &nw, const double susceptibility, const double tolerance, const Opinion_space_type opinion_space)
Hegselmann-Krause opinion update function.
Definition revision.hh:20
void revision(NWType &nw, const double susceptibility, const double tolerance, const double weighting, const Interaction_type interaction, const Opinion_space_type opinion_space, const Rewiring rewire, std::uniform_real_distribution< double > &prob_distr, RNGType &rng)
Performs an opinion update and edge rewiring (if enabled).
Definition revision.hh:149
void update_opinion_Deffuant(const VertexDescType v, NWType &nw, const double susceptibility, const double tolerance, const Opinion_space_type opinion_space, std::uniform_real_distribution< double > &prob_distr, RNGType &rng)
Deffuant opinion update function.
Definition revision.hh:83
std::mt19937 rng
– Type definitions ----------------------------------------------------—
Definition test_revision.cc:17
double opinion_difference(VertexDescType v, VertexDescType w, NWType &nw)
Calculate the absolute opinion difference of two vertices.
Definition utils.hh:87
VertexDescType select_neighbor(const VertexDescType v, NWType &nw, std::uniform_real_distribution< double > &prob_distr, RNGType &rng)
Definition utils.hh:57
void set_and_normalize_weights(const VertexDescType v, NWType &nw, const double weighting)
Set and normalize weights according to opinion difference.
Definition utils.hh:102