generated from vivarium-collective/vivarium-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57a4dfa
commit 4d1997a
Showing
2 changed files
with
42 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,28 @@ | ||
from vivarium.core.engine import Engine, pf | ||
|
||
class Scan(): | ||
def __init__( | ||
self, | ||
parameter_sets, | ||
simulator_class, | ||
total_time, | ||
metrics=()): | ||
|
||
class Scan: | ||
def __init__(self, parameter_sets, simulator_class, total_time, metrics=()): | ||
|
||
self.parameter_sets = parameter_sets | ||
self.simulator_class = simulator_class | ||
self.total_time = total_time | ||
self.metrics = metrics | ||
|
||
def run_simulation(self, parameters): | ||
simulator = self.simulator_class(parameters['parameters']).generate() | ||
simulator = self.simulator_class(parameters["parameters"]).generate() | ||
engine = Engine( | ||
processes=simulator['processes'], | ||
topology=simulator['topology'], | ||
initial_state=parameters['states']) | ||
processes=simulator["processes"], | ||
topology=simulator["topology"], | ||
initial_state=parameters["states"], | ||
) | ||
engine.update(self.total_time) | ||
return engine.emitter.get_data() | ||
|
||
def run_scan(self): | ||
results = {} | ||
for id, parameter_set in self.parameter_sets.items(): | ||
data = self.run_simulation(parameter_set) | ||
metrics = { | ||
name: metric(data) | ||
for name, metric in self.metrics.items()} | ||
results[id] = { | ||
'data': data, | ||
'metrics': metrics} | ||
metrics = {name: metric(data) for name, metric in self.metrics.items()} | ||
results[id] = {"data": data, "metrics": metrics} | ||
return results | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters