Skip to content

Commit

Permalink
Check for random_seed in user_pars before setting
Browse files Browse the repository at this point in the history
To allow users to make use of the new <options><randomseed> element wholly from within studio, and to allow parameters.ints("random_seed") to override this behavior, we must allow users to delete the random_seed user_par and then not have that throw an error when running create_cell_types() in the standard custom.cpp. If/when we insist on the random_seed being in its new home, then we can delete these SeedRandom calls entirely. We could add a warning if random_seed is found as a user_parameter that this old syntax is no longer supported. PhysiCell 2.0.0 thing.
  • Loading branch information
drbergman committed Jun 7, 2024
1 parent e4a8511 commit 9c49dea
Show file tree
Hide file tree
Showing 23 changed files with 90 additions and 23 deletions.
3 changes: 2 additions & 1 deletion modules/PhysiCell_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ void PhysiCell_Settings::read_from_pugixml( void )
}

pugi::xml_node random_seed_node = xml_find_node(node_options, "random_seed");
std::string random_seed = "";
std::string random_seed = ""; // default is system clock, even if this element is not present
if (random_seed_node)
{ random_seed = xml_get_my_string_value(random_seed_node); }

if (random_seed == "" || random_seed == "random" || random_seed == "system_clock")
{
std::cout << "Using system clock for random seed" << std::endl;
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/biorobots/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/cancer_biorobots/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/celltypes3/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/heterogeneity/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/interactions/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/mechano/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/physimess/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/pred_prey_farmer/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/rules_sample/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/template/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/virus_macrophage/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/worm/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ std::vector<bool> nodes;
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ extern "C" rrc::RRHandle createRRInstance();
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion unit_tests/custom_DCs_2substrates/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down
5 changes: 4 additions & 1 deletion unit_tests/custom_voxel_values/custom_modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
void create_cell_types( void )
{
// set the random seed
SeedRandom( parameters.ints("random_seed") );
if (parameters.ints.find_index("random_seed") != -1)
{
SeedRandom(parameters.ints("random_seed"));
}

/*
Put any modifications to default cell definition here if you
Expand Down

0 comments on commit 9c49dea

Please sign in to comment.