|
| BOOST_FIXTURE_TEST_CASE (test_get_rand, Infrastructure) |
|
| BOOST_AUTO_TEST_CASE (test_is_directed) |
|
| BOOST_FIXTURE_TEST_CASE (test_get_rand_neighbor, TestNetworkU) |
|
| BOOST_FIXTURE_TEST_CASE (test_set_and_normalize_weights, TestNetworkD, *boost::unit_test::tolerance(1e-12)) |
|
| BOOST_FIXTURE_TEST_CASE (test_select_neighbour, TestNetworkD_small, *boost::unit_test::tolerance(1.0)) |
|
template<typename RT , typename T , typename RNGType > |
RT | get_rand (std::pair< T, T > range, RNGType &rng) |
| Generate a random number within the given range. More...
|
|
template<typename NWType > |
constexpr bool | is_directed () |
| Check whether the network type allows for directed edges. More...
|
|
template<typename NWType , typename VertexDescType , typename RNGType > |
auto | get_rand_neighbor (const VertexDescType v, NWType &nw, RNGType &rng) |
|
template<typename NWType , typename RNGType , typename VertexDescType > |
VertexDescType | select_neighbor (const VertexDescType v, NWType &nw, std::uniform_real_distribution< double > &prob_distr, RNGType &rng) |
|
template<typename NWType , typename VertexDescType > |
double | opinion_difference (VertexDescType v, VertexDescType w, NWType &nw) |
| Calculate the absolute opinion difference of two vertices. More...
|
|
template<typename NWType , typename VertexDescType > |
void | set_and_normalize_weights (const VertexDescType v, NWType &nw, const double weighting) |
| Set and normalize weights according to opinion difference. More...
|
|
template<typename NWType , typename VertexDescType >
void Utopia::Models::Opinionet::Utils::set_and_normalize_weights |
( |
const VertexDescType |
v, |
|
|
NWType & |
nw, |
|
|
const double |
weighting |
|
) |
| |
Set and normalize weights according to opinion difference.
Iterates over a vertex' out-edges and sets the weights to exp(- weighting * abs(opinion difference)), then normalizes them (softmax).
- Warning
- This assumes that the vertex has at least one out-edge. Make sure to check this in the calling scope, otherwise this will lead to a zero division error during normalisation.