execution.SequentialExecution

execution.SequentialExecution(model, statespace, collect=True, *args, **kwargs)

Sequential execution of models across parameter spaces with progress tracking.

SequentialExecution provides a straightforward approach to executing a model function across all parameter combinations in a given state space. Unlike ParallelExecution, it processes parameter combinations one at a time, making it ideal for debugging, memory-constrained environments, or when parallel execution is not feasible or desired.

Parameters

Name Type Description Default
model callable Model function to execute. Should accept a state parameter and return simulation results. Signature: model(state, *args, **kwargs). required
statespace AbstractSpace Parameter space (DataSpace, UniformSpace, or GridSpace) defining the parameter combinations to execute across. required
*args tuple Positional arguments passed directly to the model function. ()
**kwargs dict Keyword arguments passed directly to the model function. {}

Examples

>>> import jax.numpy as jnp
>>> from tvboptim.types.spaces import GridSpace
>>> from tvboptim.types.parameter import Parameter
>>> 
>>> # Define a simple model
>>> def simulate(state, noise_level=0.0):
...     result = state['param1'] * state['param2'] + noise_level
...     return {'output': result, 'inputs': state}
>>> 
>>> # Create parameter space
>>> state = {
...     'param1': Parameter("param1", 0.0, low=0.0, high=1.0, free=True),
...     'param2': Parameter("param2", 0.0, low=-1.0, high=1.0, free=True)
... }
>>> space = GridSpace(state, n=5)  # 25 parameter combinations
>>> 
>>> # Set up sequential execution
>>> executor = SequentialExecution(
...     model=simulate,
...     statespace=space,
...     noise_level=0.1  # Keyword argument passed to model
... )
>>> 
>>> # Execute across all parameter combinations
>>> results = executor.run()  # Shows progress bar
>>> 
>>> # Access results
>>> first_result = results[0]
>>> all_results = list(results)  # Convert to list
>>> total_count = len(results)

Methods

Name Description
run Execute the model across all parameter combinations in parallel.

run

execution.SequentialExecution.run()

Execute the model across all parameter combinations in parallel.