qrunch.tools.minimizers.parameter_sorting_strategy.random_sorting_strategy

Parameter sorting strategy that returns parameters in a random order.

The strategy collects the circuit’s symbolic (free) parameters in circuit order and then returns a random permutation of both the parameter values (taken from the provided initial_guess) and their corresponding indices.

Classes

RandomSortingStrategy

Randomly permute the circuit parameters.

class RandomSortingStrategy

Bases: ParameterSortingStrategy

Randomly permute the circuit parameters.

Parameters:

seed – Optional seed for reproducibility. If None the global numpy RNG is used (non-deterministic across runs). If provided a dedicated Generator is instantiated.

__init__(seed: int | None = None) None
Parameters:

seed (int | None)

Return type:

None

seed: int | None
sort_parameters(initial_guess: ndarray[Any, dtype[float64]], circuit: Circuit, operator: HermitianPauliSum | None) ParameterSortingStrategyResult

Sort the selected (tail) symbolic parameters randomly.

Parameters:
  • initial_guess (ndarray[Any, dtype[float64]]) – The initial guess array of length \(L\).

  • circuit (Circuit) – The parameterized quantum circuit corresponding to \(|\psi(\theta)\rangle\).

  • operator (HermitianPauliSum | None) – The Hermitian operator \(O\) used to compute expectation values: \(\langle \psi(\theta) | O | \psi(\theta) \rangle\).

Return type:

ParameterSortingStrategyResult