Skip to content

Commit

Permalink
organize todos for optimize dfba caching
Browse files Browse the repository at this point in the history
  • Loading branch information
artgoldberg committed Dec 3, 2020
1 parent ab1a0e6 commit dd98c58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions wc_sim/dynamic_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ class DynamicModel(object):
that get repeated
rxn_expression_dependencies (:obj:`dict`): map from reactions to lists of expressions
whose values depend on species with non-zero stoichiometry in the reaction
# TODO: OPTIMIZE DFBA CACHING: describe dFBA caching optimization
# TODO (APG): OPTIMIZE DFBA CACHING: describe dFBA caching optimization
continuous_rxn_dependencies (:obj:`dict`): map from ids of continuous submodels to sets
identifying expressions whose values depend on species with non-zero stoichiometry in
reaction(s) modeled by the submodel
Expand Down Expand Up @@ -999,13 +999,14 @@ def obtain_dependencies(self, model):
model.
If a simulation fails with the error "killed" and no other information, then it is probably
running on a system or in a container which does not have sufficient memory to complete
this function. Try running on a system with more memory or simulating a smaller model.
this function. Try running on a system with more memory, simulating a smaller model, or
disabling caching in `wc_sim.cfg`.
Args:
model (:obj:`Model`): the description of the whole-cell model in `wc_lang`
Returns:
:obj:`dict` of :obj:`list`: the dependencies of expressions on reactions, as a map from
:obj:`dict` of :obj:`list`: the dependencies of expressions on reactions, which maps each
reaction to a list of expressions
"""
used_model_types = set((wc_lang.Function,
Expand Down Expand Up @@ -1111,7 +1112,7 @@ def continuous_reaction_dependencies(self):
continuous_rxn_dependencies = {}
for submodel_id, sm_reactions in rxns_modeled_by_continuous_submodels.items():
continuous_rxn_dependencies[submodel_id] = set()
# TODO: OPTIMIZE DFBA CACHING: only include exchange and objective (biomass) reactions in dFBA submodels
# TODO (APG): OPTIMIZE DFBA CACHING: only include exchange and objective (biomass) reactions in dFBA submodels
for reaction, dependencies in self.rxn_expression_dependencies.items():
if reaction in sm_reactions:
continuous_rxn_dependencies[submodel_id].update(dependencies)
Expand Down Expand Up @@ -1173,11 +1174,6 @@ def continuous_submodel_flush_after_populations_change(self, dynamic_submodel_id
Args:
dynamic_submodel_id (:obj:`str`): the id of the continuous submodel that's running
"""
'''
print('continuous_submodel_flush_after_populations_change')
print('dynamic_submodel_id', dynamic_submodel_id)
print('self.continuous_rxn_dependencies[dynamic_submodel_id]', self.continuous_rxn_dependencies[dynamic_submodel_id])
'''
self.cache_manager.invalidate(expressions=self.continuous_rxn_dependencies[dynamic_submodel_id])
self.flush_compartment_masses()

Expand Down
2 changes: 1 addition & 1 deletion wc_sim/submodels/dfba.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ def determine_bounds(self):
to `self._reaction_bounds`.
"""
flux_comp_id = self.dfba_solver_options['flux_bounds_volumetric_compartment_id']
# TODO (APG): since volumes are used, cached volumes must be invalidated before running dFBA
if flux_comp_id == self.FLUX_BOUNDS_VOLUMETRIC_COMPARTMENT_ID:
flux_comp_volume = self.dynamic_model.cell_volume()
else:
Expand Down Expand Up @@ -688,6 +687,7 @@ def run_fba_solver(self):
time_step=self.time_step)

# flush expressions that depend on species and reactions modeled by this dFBA submodel from cache
# TODO (APG): OPTIMIZE DFBA CACHING: minimize flushing by implementing OPTIMIZE DFBA CACHING todos elsewhere
self.dynamic_model.continuous_submodel_flush_after_populations_change(self.id)

### handle DES events ###
Expand Down

0 comments on commit dd98c58

Please sign in to comment.