Skip to content

Commit

Permalink
Changes test Set_Gillespie_Random_Seed to fail less.
Browse files Browse the repository at this point in the history
The previous version of this test checked to see if two random walks through integers ended on different numbers, which was true every so often.  In this version, we check if a single random draw of a double is the same with two seeds, which is *much* less likely to happen.
  • Loading branch information
luciansmith committed May 22, 2024
1 parent fbff04a commit 1b72306
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/model_analysis/model_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1738,11 +1738,15 @@ TEST_F(ModelAnalysisTests, Set_Gillespie_Random_Seed) {
RoadRunner rr1((modelAnalysisModelsDir / "gillespie_random_seed.xml").string());
RoadRunner rr2((modelAnalysisModelsDir / "gillespie_random_seed.xml").string());
rr1.setIntegrator("gillespie");
rr1.getIntegrator()->setValue("variable_step_size", true);
rr1.setSeed(-1, false);
rr1.simulate(0, 10, 2);
const ls::DoubleMatrix* rr1_results = rr1.simulate(0, 10, 2);
rr2.setIntegrator("gillespie");
rr1.getIntegrator()->setValue("variable_step_size", true);
rr2.setSeed(-1, false);
rr2.simulate(0, 10, 2);
EXPECT_NE(rr1.getValue("S2"), rr2.getValue("S2"));
const ls::DoubleMatrix* rr2_results = rr2.simulate(0, 10, 2);
// With a variable step size, every time step is a random draw, which should be different.
EXPECT_NE(rr1_results->Element(1, 0), rr2_results->Element(1, 0));
//std::cout << rr1_results->Element(1, 0) << ", " << rr2_results->Element(1, 0) << std::endl;
}

0 comments on commit 1b72306

Please sign in to comment.