Skip to content

Commit

Permalink
ActivityDrivenModel: Use the copula
Browse files Browse the repository at this point in the history
Use the copula to generate correlated activities and reluctances.

Co-authored-by: Amrita Goswami <[email protected]>
  • Loading branch information
MSallermann and amritagos committed Mar 25, 2024
1 parent 376bb90 commit ade8ee9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion include/connectivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TarjanConnectivityAlgo
{
lowest[v] = std::min( lowest[v], num[u] );
} // u not processed
} // u has been visited
} // u has been visited
}

// Now v has been processed
Expand Down
20 changes: 10 additions & 10 deletions include/models/ActivityDrivenModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ActivityDrivenModelAbstract : public Model<AgentT_>
}
}

void iteration() override{};
void iteration() override {};

protected:
NetworkT & network;
Expand Down Expand Up @@ -113,6 +113,8 @@ class ActivityDrivenModelAbstract : public Model<AgentT_>
power_law_distribution<> dist_activity( eps, gamma );
truncated_normal_distribution<> dist_reluctance( reluctance_mean, reluctance_sigma, reluctance_eps );

bivariate_gaussian_copula copula( covariance_factor, dist_activity, dist_reluctance );

auto mean_activity = dist_activity.mean();

// Initial conditions for the opinions, initialize to [-1,1]
Expand All @@ -121,18 +123,16 @@ class ActivityDrivenModelAbstract : public Model<AgentT_>
{
network.agents[i].data.opinion = dis_opinion( gen ); // Draw the opinion value

if( !mean_activities )
{ // Draw from a power law distribution (1-gamma)/(1-eps^(1-gamma)) * a^(-gamma)
network.agents[i].data.activity = dist_activity( gen );
}
else
{
network.agents[i].data.activity = mean_activity;
}
auto res = copula( gen );
network.agents[i].data.activity = res[0];

if( use_reluctances )
{
network.agents[i].data.reluctance = dist_reluctance( gen );
network.agents[i].data.reluctance = res[1];
}
if( mean_activities )
{
network.agents[i].data.activity = mean_activity;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/config_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ void validate_settings( const SimulationOptions & options )
{
const std::string basic_deff_msg
= "The basic Deffuant model has not been implemented with multiple dimensions";
check(
name_and_var( model_settings.dim ), []( auto x ) { return x == 1; }, basic_deff_msg );
check( name_and_var( model_settings.dim ), []( auto x ) { return x == 1; }, basic_deff_msg );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TEST_CASE( "Testing the network class" )
auto weight = buffer_w[i_neighbour];
std::tuple<size_t, size_t, Network::WeightT> edge{
neighbour, i_agent, weight
}; // Note that i_agent and neighbour are flipped compared to before
}; // Note that i_agent and neighbour are flipped compared to before
REQUIRE( old_edges.contains( edge ) ); // can we find the transposed edge?
old_edges.extract( edge ); // extract the edge afterwards
}
Expand Down

0 comments on commit ade8ee9

Please sign in to comment.