sbmlsim.fit.optimization

Optimization of parameter fitting problem.

Module Contents

Classes

RuntimeErrorOptimizeResult

Error in opimization.

OptimizationProblem

Parameter optimization problem.

Attributes

logger

sbmlsim.fit.optimization.logger[source]
class sbmlsim.fit.optimization.RuntimeErrorOptimizeResult[source]

Error in opimization.

status: str = '-1'[source]
success: bool = False[source]
duration: float[source]
cost: float[source]
optimality: float[source]
class sbmlsim.fit.optimization.OptimizationProblem(opid, fit_experiments, fit_parameters, base_path=None, data_path=None)[source]

Bases: sbmlsim.serialization.ObjectJSONEncoder

Parameter optimization problem.

Parameters:
__repr__()[source]

Get representation.

Return type:

str

__str__()[source]

Get string representation.

This can be run before initialization.

Return type:

str

to_dict()[source]

Convert to dictionary.

Return type:

Dict[str, Any]

to_json(path=None)[source]

Store OptimizationResult as json.

Uses the to_dict method.

Parameters:

path (Optional[pathlib.Path]) –

Return type:

Union[str, pathlib.Path]

report(path=None, print_output=True)[source]

Print and write report.

Can only be called after initialization.

Parameters:
  • path (pathlib.Path) –

  • print_output (bool) –

Return type:

str

initialize(residual, loss_function, weighting_curves, weighting_points, variable_step_size=True, relative_tolerance=1e-06, absolute_tolerance=1e-06)[source]

Initialize Optimization problem.

Performs precalculations, resolving data, calculating weights. Creates and attaches simulator for the given problem.

Parameters:
Return type:

None

set_simulator(simulator)[source]

Set the simulator on the runner and the experiments.

Parameters:

simulator

Returns:

optimize(size=5, algorithm=OptimizationAlgorithmType.LEAST_SQUARE, sampling=SamplingType.UNIFORM, seed=None, **kwargs)[source]

Run parameter optimization.

To change the weighting or handling of residuals reinitialize the optimization algorithm.

Parameters:
Return type:

Tuple[List[scipy.optimize.OptimizeResult], List]

_optimize_single(x0=None, algorithm=OptimizationAlgorithmType.LEAST_SQUARE, **kwargs)[source]

Run single optimization with x0 start values.

Parameters:
  • x0 (numpy.ndarray) – parameter start vector (important for deterministic optimizers)

  • algorithm – optimization algorithm and method

  • kwargs

Returns:

Return type:

Tuple[scipy.optimize.OptimizeResult, List]

cost_least_square(xlog)[source]

Get least square costs for parameters.

Parameters:

xlog (numpy.ndarray) –

Return type:

float

residuals(xlog, complete_data=False)[source]

Calculate residuals for given parameter vector.

Optimization is performed in logarithmic parameter space to account for xtol in largely varying parameters. see https://github.com/scipy/scipy/issues/7632

Parameters:
  • xlog (numpy.ndarray) – logarithmic parameter vector

  • complete_data – boolean flag to return additional information

Returns:

vector of weighted residuals