Skip to content

Commit

Permalink
started work on a parameter scanning method
Browse files Browse the repository at this point in the history
  • Loading branch information
prismofeverything committed Apr 19, 2022
1 parent 0f50513 commit b3bda4b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
37 changes: 37 additions & 0 deletions vivarium_models/library/scan.py
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


56 changes: 49 additions & 7 deletions vivarium_models/processes/readdy_actin_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from vivarium.core.process import Process
from vivarium.core.engine import Engine, pf
from vivarium.core.composition import simulate_process
from vivarium.core.control import run_library_cli

from tqdm import tqdm
from simularium_models_util.actin import ActinSimulation, ActinUtil, ActinTestData
from simularium_models_util import ReaddyUtil
from vivarium_models.util import create_monomer_update

from vivarium_models.library.scan import Scan

NAME = "ReaDDy_actin"

Expand Down Expand Up @@ -238,23 +239,26 @@ def run_readdy_actin_process():
return output


def test_readdy_actin_process():
def get_monomer_data():
monomer_data = ActinTestData.linear_actin_monomers()
monomer_data["box_center"] = np.array([3000.0, 1000.0, 1000.0])
monomer_data["box_size"] = 500.0
return {'monomers': monomer_data}


def test_readdy_actin_process():
monomer_data = get_monomer_data()
readdy_actin_process = ReaddyActinProcess()

engine = Engine(
{
**{
"processes": {"readdy_actin_process": readdy_actin_process},
"topology": {
"readdy_actin_process": {
"monomers": ("monomers",),
},
},
"initial_state": {
"monomers": monomer_data,
},
"initial_state": monomer_data,
}
)

Expand All @@ -264,5 +268,43 @@ def test_readdy_actin_process():
print(pf(output))


def test_scan_readdy():
monomer_data = get_monomer_data()

parameters = {
'1': {
'parameters': {
'actin_concentration': 100.0,
'arp23_concentration': 5.0},
'states': monomer_data},
'2': {
'parameters': {
'actin_concentration': 200.0,
'arp23_concentration': 10.0},
'states': monomer_data},
'3': {
'parameters': {
'actin_concentration': 300.0,
'arp23_concentration': 20.0},
'states': monomer_data}}

metrics = []

scan = Scan(
parameters,
ReaddyActinProcess,
0.0000001,
metrics=metrics)

results = scan.run_scan()

import ipdb; ipdb.set_trace()


library = {
'0': test_readdy_actin_process,
'1': test_scan_readdy}


if __name__ == "__main__":
test_readdy_actin_process()
run_library_cli(library)

0 comments on commit b3bda4b

Please sign in to comment.