diff --git a/micro_manager/adaptivity/local_adaptivity.py b/micro_manager/adaptivity/local_adaptivity.py index a2defb8..1c253ae 100644 --- a/micro_manager/adaptivity/local_adaptivity.py +++ b/micro_manager/adaptivity/local_adaptivity.py @@ -6,6 +6,7 @@ import numpy as np from .adaptivity import AdaptivityCalculator +from ..micro_simulation import create_simulation_class class LocalAdaptivityCalculator(AdaptivityCalculator): @@ -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() )