Skip to content

Commit

Permalink
wip3
Browse files Browse the repository at this point in the history
  • Loading branch information
MSallermann committed Mar 6, 2024
1 parent 37975ab commit d3dd8d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
6 changes: 3 additions & 3 deletions include/models/ActivityDrivenModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class ActivityAgentModel : public Model<Agent<ActivityAgentData>>
// bot @TODO: less hacky
bool bot_present = false;
size_t n_bots = 0; // The first n_bots agents are bots
std::vector<int> bot_m = {};
std::vector<double> bot_activity = {};
std::vector<double> bot_opinion = {};
std::vector<int> bot_m = std::vector<int>( 0 );
std::vector<double> bot_activity = std::vector<double>( 0 );
std::vector<double> bot_opinion = std::vector<double>( 0 );

ActivityAgentModel( int n_agents, Network & network, std::mt19937 & gen );

Expand Down
31 changes: 22 additions & 9 deletions src/simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "util/tomlplusplus.hpp"
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h>
#include <cstddef>
#include <iostream>
#include <optional>
Expand Down Expand Up @@ -126,22 +127,34 @@ Seldon::Simulation::Simulation(
model_activityDriven->max_iterations = max_iterations;

// bot
model_activityDriven->n_bots = tbl["ActivityDriven"]["n_bots"].value_or<size_t>( 0 );
model_activityDriven->bot_present = tbl["ActivityDriven"]["bot_present"].value_or<bool>( false );

auto * bot_opinion = tbl["bot_opinion"].as_array();
auto * bot_m = tbl["bot_m"].as_array();
auto * bot_activity = tbl["bot_activity"].as_array();

for( size_t i = 0; i < model_activityDriven->n_bots; i++ )
if( model_activityDriven->bot_present )
{
model_activityDriven->bot_opinion.push_back( bot_opinion[i].value_or<double>( 0.0 ) );
model_activityDriven->bot_m.push_back( bot_m[i].value_or<size_t>( 0 ) );
model_activityDriven->bot_activity.push_back( bot_activity[i].value_or<double>( 0.0 ) );
model_activityDriven->n_bots = tbl["ActivityDriven"]["n_bots"].value_or<size_t>( 0 );

fmt::print( "Using {} bots\n", model_activityDriven->n_bots );

auto bot_opinion = tbl["ActivityDriven"]["bot_opinion"];
auto bot_m = tbl["ActivityDriven"]["bot_m"];
auto bot_activity = tbl["ActivityDriven"]["bot_activity"];

for( size_t i = 0; i < model_activityDriven->n_bots; i++ )
{
model_activityDriven->bot_opinion.push_back( bot_opinion[i].value_or<double>( 0.0 ) );
model_activityDriven->bot_m.push_back( bot_m[i].value_or<size_t>( 0 ) );
model_activityDriven->bot_activity.push_back( bot_activity[i].value_or<double>( 0.0 ) );
}

fmt::print( "Bot opinions {}\n", model_activityDriven->bot_opinion );
fmt::print( "Bot m {}\n", model_activityDriven->bot_m );
fmt::print( "Bot activities {}\n", model_activityDriven->bot_activity );
}

model_activityDriven->get_agents_from_power_law();
model = std::move( model_activityDriven );

fmt::print( "Finished model setup\n" );
}

if( cli_agent_file.has_value() )
Expand Down

0 comments on commit d3dd8d0

Please sign in to comment.