Optimizer

class glotaran.optimization.optimizer.Optimizer(scheme: Scheme, verbose: bool = True, raise_exception: bool = False)[source]

Bases: object

A class to optimize a scheme.

Initialize an optimization group for a dataset group.

Parameters:
  • scheme (Scheme) – The optimization scheme.

  • verbose (bool) – Deactivate printing of logs if False.

  • raise_exception (bool) – Raise exceptions during optimizations instead of gracefully exiting if True.

Raises:
  • MissingDatasetsError – Raised if datasets are missing.

  • ParameterNotInitializedError – Raised if the scheme parameters are None.

  • UnsupportedMethodError – Raised if the optimization method is unsupported.

Methods Summary

calculate_covariance_matrix_and_standard_errors

Calculate the covariance matrix and standard errors of the optimization.

calculate_penalty

Calculate the penalty of the scheme.

create_result

Create the result of the optimization.

get_current_optimization_iteration

Extract current iteration from optimize_stdout.

objective_function

Calculate the objective for the optimization.

optimize

Perform the optimization.

Methods Documentation

calculate_covariance_matrix_and_standard_errors(jacobian: ArrayLike, root_mean_square_error: float) ArrayLike[source]

Calculate the covariance matrix and standard errors of the optimization.

Parameters:
  • jacobian (ArrayLike) – The jacobian matrix.

  • root_mean_square_error (float) – The root mean square error.

Returns:

The covariance matrix.

Return type:

ArrayLike

calculate_penalty() ArrayLike[source]

Calculate the penalty of the scheme.

Returns:

The penalty.

Return type:

ArrayLike

create_result() Result[source]

Create the result of the optimization.

Returns:

The result of the optimization.

Return type:

Result

Raises:

InitialParameterError – Raised if the initial parameters could not be evaluated.

static get_current_optimization_iteration(optimize_stdout: str) int[source]

Extract current iteration from optimize_stdout.

Parameters:

optimize_stdout (str) – SciPy optimization stdout string, read out via TeeContext.read().

Returns:

Current iteration (0 if pattern did not match).

Return type:

int

objective_function(parameters: ArrayLike) ArrayLike[source]

Calculate the objective for the optimization.

Parameters:

parameters (ArrayLike) – the parameters provided by the optimizer.

Returns:

The objective for the optimizer.

Return type:

ArrayLike

optimize()[source]

Perform the optimization.

Raises:

Exception – Raised if an exception occurs during optimization and raise_exception is True.