diff --git a/include/models/ActivityDrivenModel.hpp b/include/models/ActivityDrivenModel.hpp index 7b9a5b3..15a5706 100644 --- a/include/models/ActivityDrivenModel.hpp +++ b/include/models/ActivityDrivenModel.hpp @@ -103,9 +103,9 @@ class ActivityAgentModel : public Model> // bot @TODO: less hacky bool bot_present = false; size_t n_bots = 0; // The first n_bots agents are bots - std::vector bot_m = {}; - std::vector bot_activity = {}; - std::vector bot_opinion = {}; + std::vector bot_m = std::vector( 0 ); + std::vector bot_activity = std::vector( 0 ); + std::vector bot_opinion = std::vector( 0 ); ActivityAgentModel( int n_agents, Network & network, std::mt19937 & gen ); diff --git a/src/simulation.cpp b/src/simulation.cpp index 88de8c9..ef3aab0 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -5,6 +5,7 @@ #include "util/tomlplusplus.hpp" #include #include +#include #include #include #include @@ -126,22 +127,34 @@ Seldon::Simulation::Simulation( model_activityDriven->max_iterations = max_iterations; // bot - model_activityDriven->n_bots = tbl["ActivityDriven"]["n_bots"].value_or( 0 ); model_activityDriven->bot_present = tbl["ActivityDriven"]["bot_present"].value_or( 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( 0.0 ) ); - model_activityDriven->bot_m.push_back( bot_m[i].value_or( 0 ) ); - model_activityDriven->bot_activity.push_back( bot_activity[i].value_or( 0.0 ) ); + model_activityDriven->n_bots = tbl["ActivityDriven"]["n_bots"].value_or( 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( 0.0 ) ); + model_activityDriven->bot_m.push_back( bot_m[i].value_or( 0 ) ); + model_activityDriven->bot_activity.push_back( bot_activity[i].value_or( 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() )