sbmlsim.fit.runner
¶
Module for running parameter optimizations.
The optimization can run either run serial or in a parallel version.
The parallel optimization uses multiprocessing, i.e. the parallel runner starts processes on the n_cores which run optimization problems.
How multiprocessing works, in a nutshell:
Process() spawns (fork or similar on Unix-like systems) a copy of the original program. The copy communicates with the original to figure out that
it’s a copy and
it should go off and invoke the target= function (see below).
At this point, the original and copy are now different and independent, and can run simultaneously.
Since these are independent processes, they now have independent Global Interpreter Locks (in CPython) so both can use up to 100% of a CPU on a multi-cpu box, as long as they dont contend for other lower-level (OS) resources. That’s the “multiprocessing” part.
Module Contents¶
Functions¶
|
Run optimization in parallel. |
|
Worker for running optimization problem. |
|
Run the given optimization problem in a serial fashion. |
Attributes¶
- sbmlsim.fit.runner.run_optimization(problem, size=5, algorithm=OptimizationAlgorithmType.LEAST_SQUARE, residual=ResidualType.ABSOLUTE, loss_function=LossFunctionType.LINEAR, weighting_curves=None, weighting_points=WeightingPointsType.NO_WEIGHTING, seed=None, variable_step_size=True, relative_tolerance=1e-06, absolute_tolerance=1e-06, n_cores=1, serial=False, **kwargs)[source]¶
Run optimization in parallel.
The runner executes the given OptimizationProblem and returns the OptimizationResults. The size defines the repeated optimizations of the problem. Every repeat uses different initial values.
To get access to the optimization problem this has to be initialized with the arguments of the runner.
- Parameters:
problem (sbmlsim.fit.optimization.OptimizationProblem) – uninitialized problem to optimize (pickable)
size (int) – integer number of optimizations
algorithm (sbmlsim.fit.options.OptimizationAlgorithmType) – optimization algorithm to use
residual (sbmlsim.fit.options.ResidualType) – handling of residuals
loss_function (sbmlsim.fit.options.LossFunctionType) – loss function for handling outliers/residual transformation
weighting_curves (List[sbmlsim.fit.options.WeightingCurvesType]) – list of options for weighting curves (fit mappings)
weighting_points (sbmlsim.fit.options.WeightingPointsType) – weighting of points
seed (Optional[int]) – integer random seed (for sampling of parameters)
absolute_tolerance (float) – absolute tolerance of simulator
relative_tolerance (float) – relative tolerance of simulator
variable_step_size (bool) – use variable step size in solver
n_cores (Optional[int]) – number of workers
serial (bool) – boolean flag to execute optimization in serial fashion (debugging)
kwargs – additional arguments for optimizer, e.g. xtol
- Returns:
OptimizationResult
- Return type:
- sbmlsim.fit.runner._run_optimization_serial(problem, size=5, algorithm=OptimizationAlgorithmType.LEAST_SQUARE, residual=ResidualType.ABSOLUTE, loss_function=LossFunctionType.LINEAR, weighting_curves=None, weighting_points=WeightingPointsType.NO_WEIGHTING, seed=None, variable_step_size=True, relative_tolerance=1e-06, absolute_tolerance=1e-06, **kwargs)[source]¶
Run the given optimization problem in a serial fashion.
This function should not be called directly, but the ‘run_optimization’ should be used for executing simulations. See run_optimization for more detailed documentation.
- Parameters:
problem (sbmlsim.fit.optimization.OptimizationProblem) – uninitialized problem to optimize (pickable)
size (int) – integer number of optimizations
algorithm (sbmlsim.fit.options.OptimizationAlgorithmType) – optimization algorithm to use
residual (sbmlsim.fit.options.ResidualType) – handling of residuals
loss_function (sbmlsim.fit.options.LossFunctionType) – loss function for handling outliers/residual transformation
weighting_curves (List[sbmlsim.fit.options.WeightingCurvesType]) – list of options for weighting curves (fit mappings)
weighting_points (sbmlsim.fit.options.WeightingPointsType) – weighting of points
seed (Optional[int]) – integer random seed (for sampling of parameters)
absolute_tolerance (float) – absolute tolerance of simulator
relative_tolerance (float) – relative tolerance of simulator
variable_step_size (bool) – use variable step size in solver
kwargs – additional arguments for optimizer, e.g. xtol
- Returns:
OptimizationResult
- Return type: