Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
added param scan instance
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent f2b711c commit c885459
Showing 1 changed file with 67 additions and 18 deletions.
85 changes: 67 additions & 18 deletions biosimulator_processes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ def play_composition(instance: dict, duration: int):
return results


def generate_emitter_schema(
emitter_address: str = "local",
emitter_type: str = "ram-emitter",
**emit_values_schema
) -> Dict:
return {
'_type': 'step',
'address': 'local:ram-emitter',
'config': {
'emit': {**emit_values_schema},
},
'inputs': { # TODO: make this generalized
'floating_species': ['floating_species_store'],
'time': ['time_store'],
}
}


def generate_copasi_process_emitter_schema():
return generate_emitter_schema(
emitter_address='local',
Expand Down Expand Up @@ -95,4 +77,71 @@ def generate_composite_copasi_process_instance(instance_name: str, config: Dict,
return instance


def generate_single_process_instance(
instance_name: str,
instance_config: dict,
inputs_config: dict,
outputs_config: dict,
instance_type: str = 'step',
instance_address: str = 'local:copasi',
) -> dict:
return {
instance_name: {
'_type': instance_type,
'address': instance_address,
'config': instance_config,
'inputs': inputs_config,
'outputs': outputs_config
}
}


def generate_emitter_schema(
emitter_address: str = "local",
emitter_type: str = "ram-emitter",
**emit_values_schema
) -> Dict:
return {
'_type': 'step',
'address': 'local:ram-emitter',
'config': {
'emit': {**emit_values_schema},
},
'inputs': { # TODO: make this generalized
'floating_species': ['floating_species_store'],
'time': ['time_store'],
}
}


def generate_parameter_scan_instance(
num_iterations: int,
entry_config: Dict,
modeler: str,
add_emitter: bool = True,
*parameters,
**io_config
) -> Dict:
"""Generate a parameter scan instance configuration for a given process."""
instance = {}
for n in range(num_iterations):
iteration_name = f'{modeler}_{n}'
iteration_instance = generate_single_process_instance(
instance_name=iteration_name,
instance_config=entry_config,
inputs_config=io_config['inputs'],
outputs_config=io_config['outputs'])

for instance_name, instance_schema in iteration_instance:
instance[instance_name] = iteration_instance

if add_emitter:
instance['emitter'] = generate_emitter_schema(
floating_species='tree[float]',
time='float')

return instance


def perturb_parameter(param: str, degree: float):
pass

0 comments on commit c885459

Please sign in to comment.