|
|
|
@ -119,12 +119,9 @@ class Simulation:
|
|
|
|
|
self.logger = logger.getChild(self.name)
|
|
|
|
|
self.logger.setLevel(self.level)
|
|
|
|
|
|
|
|
|
|
if self.source_file:
|
|
|
|
|
source_file = self.source_file
|
|
|
|
|
if not os.path.isabs(source_file):
|
|
|
|
|
source_file = os.path.abspath(os.path.join(self.dir_path, source_file))
|
|
|
|
|
serialization.add_source_file(source_file)
|
|
|
|
|
self.source_file = source_file
|
|
|
|
|
if self.source_file and (not os.path.isabs(self.source_file)):
|
|
|
|
|
self.source_file = os.path.abspath(os.path.join(self.dir_path, self.source_file))
|
|
|
|
|
with serialization.with_source(self.source_file):
|
|
|
|
|
|
|
|
|
|
if isinstance(self.model, str):
|
|
|
|
|
self.model = serialization.deserialize(self.model)
|
|
|
|
@ -138,8 +135,6 @@ class Simulation:
|
|
|
|
|
self.agent_reporters = deserialize_reporters(self.agent_reporters)
|
|
|
|
|
self.model_reporters = deserialize_reporters(self.model_reporters)
|
|
|
|
|
self.tables = deserialize_reporters(self.tables)
|
|
|
|
|
if self.source_file:
|
|
|
|
|
serialization.remove_source_file(self.source_file)
|
|
|
|
|
self.id = f"{self.name}_{current_time()}"
|
|
|
|
|
|
|
|
|
|
def run(self, **kwargs):
|
|
|
|
@ -217,10 +212,7 @@ class Simulation:
|
|
|
|
|
):
|
|
|
|
|
"""Run the simulation and yield the resulting environments."""
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if self.source_file:
|
|
|
|
|
serialization.add_source_file(self.source_file)
|
|
|
|
|
|
|
|
|
|
with serialization.with_source(self.source_file):
|
|
|
|
|
with utils.timer(f"running for config {params}"):
|
|
|
|
|
if self.dry_run:
|
|
|
|
|
def func(*args, **kwargs):
|
|
|
|
@ -237,9 +229,6 @@ class Simulation:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
yield env
|
|
|
|
|
finally:
|
|
|
|
|
if self.source_file:
|
|
|
|
|
serialization.remove_source_file(self.source_file)
|
|
|
|
|
|
|
|
|
|
def _get_env(self, iteration_id, params):
|
|
|
|
|
"""Create an environment for a iteration of the simulation"""
|
|
|
|
|