sbmlsim.fit.optimization
¶
Optimization of parameter fitting problem.
Module Contents¶
Classes¶
Error in opimization. |
|
Parameter optimization problem. |
Attributes¶
- 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:
opid (str) –
fit_experiments (List[sbmlsim.fit.objects.FitExperiment]) –
fit_parameters (List[sbmlsim.fit.objects.FitParameter]) –
base_path (pathlib.Path) –
data_path (pathlib.Path) –
- __str__()[source]¶
Get string representation.
This can be run before initialization.
- Return type:
str
- 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:
residual (Optional[sbmlsim.fit.options.ResidualType]) – handling of residuals
loss_function (sbmlsim.fit.options.LossFunctionType) – loss function for residual transformation
weighting_curves (List[sbmlsim.fit.options.WeightingCurvesType]) – list of options for weighting curves (fit mappings)
weighting_points (Optional[sbmlsim.fit.options.WeightingPointsType]) – weighting of points
absolute_tolerance (float) – absolute tolerance of simulator
relative_tolerance (float) – relative tolerance of simulator
variable_step_size (bool) – use variable step size in solver
- 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:
size (Optional[int]) –
algorithm (sbmlsim.fit.options.OptimizationAlgorithmType) –
sampling (sbmlsim.fit.sampling.SamplingType) –
seed (Optional[int]) –
- 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