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.
started work on a parameter scanning method
- Loading branch information
1 parent
0f50513
commit b3bda4b
Showing
2 changed files
with
86 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from vivarium.core.engine import Engine, pf | ||
|
||
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() | ||
engine = Engine( | ||
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 = [ | ||
metric(data) | ||
for metric in self.metrics] | ||
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