Skip to content

Commit

Permalink
First attempt at mean field theory for the activity driven model
Browse files Browse the repository at this point in the history
  • Loading branch information
amritagos committed Oct 29, 2023
1 parent b77f5ae commit 6f7cc3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/models/ActivityDrivenModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ class ActivityAgentModel : public Model<Agent<ActivityAgentData>>
{
// h is the timestep
auto neighbour_buffer = std::vector<size_t>();
auto weight_buffer = std::vector<Network::WeightT>();
size_t j_index = 0;

k_buffer.resize( network.n_agents() );

for( size_t idx_agent = 0; idx_agent < network.n_agents(); ++idx_agent )
{
network.get_neighbours( idx_agent, neighbour_buffer ); // Get the incoming neighbours
network.get_weights(idx_agent, weight_buffer); // Get incoming weights
k_buffer[idx_agent] = -opinion( idx_agent );
// Loop through neighbouring agents
for( size_t j = 0; j < neighbour_buffer.size(); j++ )
{
j_index = neighbour_buffer[j];
k_buffer[idx_agent] += K * std::tanh( alpha * opinion( j_index ) );
k_buffer[idx_agent] += K * weight_buffer[j] * std::tanh( alpha * opinion( j_index ) );
}
// Multiply by the timestep
k_buffer[idx_agent] *= dt;
Expand Down

0 comments on commit 6f7cc3e

Please sign in to comment.