Skip to content

Commit

Permalink
Add lazy ininialization for local adaptivity
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiskelm committed Sep 2, 2024
1 parent c958bf5 commit 32d2259
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions micro_manager/adaptivity/local_adaptivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np

from .adaptivity import AdaptivityCalculator
from ..micro_simulation import create_simulation_class


class LocalAdaptivityCalculator(AdaptivityCalculator):
Expand Down Expand Up @@ -130,6 +131,16 @@ def _update_inactive_sims(
if not _is_sim_active[i]: # if id is inactive
if self._check_for_activation(i, similarity_dists, _is_sim_active):
associated_active_local_id = _sim_is_associated_to[i]
if micro_sims[i] == None:
self._logger.info(f"{i} to be solved, lazy initialization")
micro_problem = getattr(
importlib.import_module(
self._micro_file_name, "MicroSimulation"
),
"MicroSimulation",
)
micro_sims[i] = create_simulation_class(micro_problem)(i)
self._logger.info(f"lazy initalization of {i} successful")
micro_sims[i].set_state(
micro_sims[associated_active_local_id].get_state()
)
Expand Down

0 comments on commit 32d2259

Please sign in to comment.