Skip to content

Commit

Permalink
config: change type of rng_seed to int64_t
Browse files Browse the repository at this point in the history
The old type (a plain int with 32 bits) could overflow easily, which
might cause confusion.

Co-authored-by: Amrita Goswami <[email protected]>
  • Loading branch information
MSallermann and amritagos committed Jul 28, 2024
1 parent 554d76a commit d4378c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/config_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fmt/ostream.h>
#include <fmt/ranges.h>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <random>
#include <string_view>
Expand Down Expand Up @@ -102,7 +103,7 @@ struct SimulationOptions
= std::variant<DeGrootSettings, ActivityDrivenSettings, ActivityDrivenInertialSettings, DeffuantSettings>;
Model model;
std::string model_string;
int rng_seed = std::random_device()();
int64_t rng_seed = std::random_device()();
OutputSettings output_settings;
ModelVariantT model_settings;
InitialNetworkSettings network_settings;
Expand Down
2 changes: 1 addition & 1 deletion src/config_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ SimulationOptions parse_config_file( std::string_view config_file_path )
toml::table tbl;
tbl = toml::parse_file( config_file_path );

options.rng_seed = tbl["simulation"]["rng_seed"].value_or( int( options.rng_seed ) );
options.rng_seed = tbl["simulation"]["rng_seed"].value_or( int64_t( options.rng_seed ) );

// Parse output settings
options.output_settings.n_output_network = tbl["io"]["n_output_network"].value<size_t>();
Expand Down

0 comments on commit d4378c4

Please sign in to comment.