qrunch.tools.minimizers.cycler_minimizer

Optimizer that cycles through parameters optimizing each of them independently.

Classes

CyclerMinimizer

Minimizer that converts a single variable minimizer or a fixed number of variables minimizer to a multivariable minimizer by cycling through variables.

CyclerMinimizerOptions

Options controlling CyclerMinimizer.

class CyclerMinimizer

Bases: Minimizer

Minimizer that converts a single variable minimizer or a fixed number of variables minimizer to a multivariable minimizer by cycling through variables.

__init__(minimizer: Minimizer | None = None, options: CyclerMinimizerOptions | None = None, parameter_sorting_strategy: Literal['DescendingAbsoluteValueSortingStrategy', 'OperatorCommutativitySortingStrategy', 'RandomSortingStrategy', 'IdentitySortingStrategy'] | None = None) None

Initialize a CyclerMinimizer.

Parameters:
  • minimizer (Minimizer | None) – Minimizer to use in cycle.

  • options (CyclerMinimizerOptions | None) – Options for the minimizer.

  • parameter_sorting_strategy (Literal['DescendingAbsoluteValueSortingStrategy', 'OperatorCommutativitySortingStrategy', 'RandomSortingStrategy', 'IdentitySortingStrategy'] | None) – Strategy to use when sorting parameters prior to cycling.

Return type:

None

minimize(function: Callable[[list[ndarray[Any, dtype[float64]]]], list[float]], initial_guess: ndarray[Any, dtype[float64]], iteration: int | None, bounds: tuple[float, float] | list[tuple[float, float]] | None = None, circuit: Circuit | None = None, operator: HermitianPauliSum | None = None) MinimizerResult

Minimize the given function using CycleMinimizer.

Parameters:
  • function (Callable[[list[ndarray[Any, dtype[float64]]]], list[float]]) – The function to minimize. Takes a numpy float as input and outputs a scalar value.

  • initial_guess (ndarray[Any, dtype[float64]]) – The initial guess for the values of the parameters.

  • iteration (int | None) – If applicable, the current adaptive iteration. If not applicable, set to None. This can be used by some minimizers.

  • bounds (tuple[float, float] | list[tuple[float, float]] | None) – The bounds for the parameters.

  • circuit (Circuit | None) – The circuit being optimized.

  • operator (HermitianPauliSum | None) – The operator used for expectation value computation.

Return type:

MinimizerResult

class CyclerMinimizerOptions

Bases: DataclassPublicAPI

Options controlling CyclerMinimizer.

All fields are immutable (frozen=True) so an instance can be safely reused across minimizations.

Parameters:
  • max_cycler_iterations – int, default=5 Maximum number of full passes (“cycles”) over the parameter set. Each cycle attempts to optimize every still-active block of parameters once.

  • improvement_threshold – float, default=1e-9 Absolute objective improvement below which a parameter index (or an entire block) is considered converged and is pruned from subsequent cycles. Set smaller to be more aggressive about continued refinement.

  • num_optimization_variables – int, default=1 Number of variables optimized jointly in each block. 1 recovers a classic coordinate descent; larger values allow small joint updates (e.g. pairwise) using the wrapped single / fixed-k minimizer.

__init__(*, max_cycler_iterations: int = 5, improvement_threshold: float = 1e-09, num_optimization_variables: int = 1) None
Parameters:
  • max_cycler_iterations (int)

  • improvement_threshold (float)

  • num_optimization_variables (int)

Return type:

None

static __new__(cls, *args: Any, **kwargs: Any) Any
Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

improvement_threshold: float = 1e-09
max_cycler_iterations: int = 5
num_optimization_variables: int = 1