quara.minimization_algorithm.minimization_algorithm module

class MinimizationAlgorithm[source]

Bases: object

Constructor.

Subclasses have a responsibility to set the following variables.

  • _is_gradient_required: whether or not to require gradient.

  • _is_hessian_required: whether or not to require Hessian.

property is_gradient_required: bool

returns whether or not to require gradient.

Returns

whether or not to require gradient.

Return type

bool

property is_hessian_required: bool

returns whether or not to require Hessian.

Returns

whether or not to require Hessian.

Return type

bool

is_loss_and_option_sufficient()[source]

returns whether the loss and the option are sufficient.

In the default implementation, this function returns True. Override with subclasses as needed.

Returns

whether the loss and the option are sufficient.

Return type

bool

is_loss_sufficient()[source]

returns whether the loss is sufficient.

In the default implementation, this function returns True. Override with subclasses as needed.

Returns

whether the loss is sufficient.

Return type

bool

is_option_sufficient()[source]

returns whether the option is sufficient.

In the default implementation, this function returns True. Override with subclasses as needed.

Returns

whether the option is sufficient.

Return type

bool

property loss: quara.loss_function.loss_function.LossFunction

returns loss function.

Returns

loss function.

Return type

LossFunction

abstract optimize(loss_function, loss_function_option, algorithm_option, on_iteration_history=False)[source]

optimizes using specified parameters.

Parameters
  • loss_function (LossFunction) – Loss Function

  • loss_function_option (LossFunctionOption) – Loss Function Option

  • algorithm_option (MinimizationAlgorithmOption) – Minimization Algorithm Option

  • on_iteration_history (bool, optional) – whether to return iteration history, by default False

Returns

the result of the optimization.

Return type

MinimizationResult

Raises

NotImplementedError – this function does not be implemented in the subclass.

property option: quara.minimization_algorithm.minimization_algorithm.MinimizationAlgorithmOption

returns algorithm option.

Returns

algorithm option.

Return type

LossFunctionOption

abstract set_constraint_from_standard_qt_and_option(qt, option)[source]

sets constraint from StandardQTomography and Algorithm Option.

Parameters
Raises

NotImplementedError – this function does not be implemented in the subclass.

Return type

None

set_from_loss(loss)[source]

sets from LossFunction and calls is_loss_sufficient function.

Parameters

loss (MinimizationAlgorithmOption) – loss to set.

Return type

None

set_from_option(option)[source]

sets option from MinimizationAlgorithmOption and calls is_option_sufficient function.

Parameters

option (MinimizationAlgorithmOption) – option to set.

Return type

None

class MinimizationAlgorithmOption(on_algo_eq_constraint=True, on_algo_ineq_constraint=True, var_start=None, max_iteration_optimization=None)[source]

Bases: object

Constructor

Parameters
  • on_algo_eq_constraint (bool, optional) – whether this algorithm needs on algorithm equality constraint, by default True

  • on_algo_ineq_constraint (bool, optional) – whether this algorithm needs on algorithm inequality constraint, by default True

  • var_start (np.ndarray, optional) – initial variable for the algorithm, by default None.

  • max_iteration_optimization (int, optional) – maximun number of iterations of optimization, by default None.

property max_iteration_optimization: int

returns imaximun number of iterations of optimization.

Returns

maximun number of iterations of optimization.

Return type

int

property on_algo_eq_constraint: bool

returns whether this algorithm needs on algorithm equality constraint.

Returns

whether this algorithm needs on algorithm equality constraint.

Return type

bool

property on_algo_ineq_constraint: bool

returns whether this QOperation is on algorithm inequality constraint.

Returns

whether this QOperation is on algorithm inequality constraint.

Return type

bool

property var_start: numpy.ndarray

returns initial variable for the algorithm.

Returns

initial variable for the algorithm.

Return type

np.ndarray

class MinimizationResult(value, computation_time=None)[source]

Bases: object

Constructor

Parameters
  • value (np.ndarray) – the result of the minimization.

  • computation_time (float, optional) – computation time for the minimization, by default None

property computation_time: float

returns computation time for the estimate.

Returns

computation time for the estimate.

Return type

float

property value: numpy.ndarray

returns the result of the minimization.

Returns

the result of the minimization.

Return type

np.ndarray