diff --git a/tests/perf_results/wc_sim_performance_log.txt b/tests/perf_results/wc_sim_performance_log.txt index d10fc32e..7fb27e93 100644 --- a/tests/perf_results/wc_sim_performance_log.txt +++ b/tests/perf_results/wc_sim_performance_log.txt @@ -346,3 +346,15 @@ Performance summary for Next Reaction Method on 2020-12-02: 8 2681 7.780 344.611 32 10538 33.464 314.910 +Performance summary for Stochastic Simulation Algorithm on 2021-01-03: +# SSA submodels # events run time (s) reactions/s +2 641 1.482 432.595 +8 2722 6.109 445.578 +32 10930 26.547 411.725 + +Performance summary for Next Reaction Method on 2021-01-03: +# NRM submodels # events run time (s) reactions/s +2 744 1.336 556.855 +8 2918 4.775 611.161 +32 10501 19.984 525.481 + diff --git a/tests/test_multialgorithm_simulation.py b/tests/test_multialgorithm_simulation.py index 6e15e2b4..6ba45b12 100644 --- a/tests/test_multialgorithm_simulation.py +++ b/tests/test_multialgorithm_simulation.py @@ -395,8 +395,8 @@ class TestRunSSASimulation(unittest.TestCase): def setUp(self): self.results_dir = tempfile.mkdtemp() - de_simulation_config = SimulationConfig(max_time=10, output_dir=self.results_dir) - self.wc_sim_config = WCSimulationConfig(de_simulation_config, dfba_time_step=1, checkpoint_period=10) + self.de_simulation_config = SimulationConfig(max_time=10, output_dir=self.results_dir) + self.wc_sim_config = WCSimulationConfig(self.de_simulation_config, dfba_time_step=1, checkpoint_period=10) self.out_dir = tempfile.mkdtemp() def tearDown(self): @@ -405,17 +405,20 @@ def tearDown(self): def make_model_and_simulation(self, model_type, num_submodels, species_copy_numbers=None, species_stds=None, init_vols=None, - submodel_framework='WC:stochastic_simulation_algorithm'): + submodel_framework='WC:stochastic_simulation_algorithm', + wc_sim_config=None): # make simple model if init_vols is not None: if not isinstance(init_vols, list): init_vols = [init_vols]*num_submodels + if wc_sim_config is None: + wc_sim_config = self.wc_sim_config model = MakeModel.make_test_model(model_type, num_submodels=num_submodels, species_copy_numbers=species_copy_numbers, species_stds=species_stds, init_vols=init_vols, submodel_framework=submodel_framework) - multialgorithm_simulation = MultialgorithmSimulation(model, self.wc_sim_config) + multialgorithm_simulation = MultialgorithmSimulation(model, wc_sim_config) simulator, _ = multialgorithm_simulation.build_simulation() return (model, multialgorithm_simulation, simulator) @@ -540,16 +543,18 @@ def test_run_multiple_ssa_submodels(self): init_vols=1E-22) def prep_simulation(self, num_ssa_submodels, submodel_framework='WC:stochastic_simulation_algorithm'): + wc_sim_config = WCSimulationConfig(self.de_simulation_config, dfba_time_step=1, checkpoint_period=10, + merge_like_submodels=False) model, multialgorithm_simulation, simulator = self.make_model_and_simulation( '2 species, a pair of symmetrical reactions, and rates given by reactant population', num_ssa_submodels, init_vols=1E-18, - submodel_framework=submodel_framework) + submodel_framework=submodel_framework, + wc_sim_config=wc_sim_config) local_species_pop = multialgorithm_simulation.local_species_population simulator.initialize() return simulator - # @unittest.skip("performance scaling test; runs slowly") def test_performance(self): end_sim_time = 100 min_num_ssa_submodels = 2 diff --git a/wc_sim/multialgorithm_simulation.py b/wc_sim/multialgorithm_simulation.py index d6157893..313d46b5 100644 --- a/wc_sim/multialgorithm_simulation.py +++ b/wc_sim/multialgorithm_simulation.py @@ -176,7 +176,8 @@ def prepare(self): # execute PrepForWcSimTransform on the model only once if not hasattr(self.model, '_transformed') or not self.model._transformed: PrepForWcSimTransform().run(self.model) - MergeAlgorithmicallyLikeSubmodelsTransform().run(self.model) + if self.wc_sim_config.merge_like_submodels: + MergeAlgorithmicallyLikeSubmodelsTransform().run(self.model) self.model._transformed = True errors = Validator().run(self.model) if errors: diff --git a/wc_sim/sim_config.py b/wc_sim/sim_config.py index 1df5b7d2..88b41147 100644 --- a/wc_sim/sim_config.py +++ b/wc_sim/sim_config.py @@ -36,6 +36,7 @@ class WCSimulationConfig(EnhancedDataClass): - Checkpoint period - Submodels to skip - Whether to produce verbose output + - Whether to merge algorithmically-like submodels into individual submodels - Model changes: Instructions to change parameter values and add or remove model components. These instructions are executed before the initial conditions are calculated @@ -52,6 +53,8 @@ class WCSimulationConfig(EnhancedDataClass): submodels_to_skip (:obj:`list` of :obj:`str`, optional): submodels that should not be run, identified by their ids verbose (:obj:`bool`, optional): whether to produce verbose output + merge_like_submodels (:obj:`bool`, optional): whether to merge algorithmically-like submodels + into individual submodels changes (:obj:`list`, optional): list of desired model changes (e.g. modified parameter values, additional species/reactions, removed species/reactions) perturbations (:obj:`list`, optional): list of desired simulated perturbations (e.g. set state @@ -65,6 +68,7 @@ class WCSimulationConfig(EnhancedDataClass): checkpoint_period: float = None submodels_to_skip: list = None verbose: bool = False + merge_like_submodels: bool = True changes: list = None perturbations: list = None @@ -199,7 +203,8 @@ def semantically_equal(self, other): self.ode_time_step == other.ode_time_step and \ self.dfba_time_step == other.dfba_time_step and \ self.checkpoint_period == other.checkpoint_period and \ - self.submodels_to_skip == other.submodels_to_skip + self.submodels_to_skip == other.submodels_to_skip and \ + self.merge_like_submodels == other.merge_like_submodels Change = wc_lang.transform.ChangeValueTransform