qrunch.quantum.algorithms.second_quantization.orbital_optimizers.simple_orbital_optimizer

Module containing the simple orbital optimizer.

Classes

SimpleOrbitalOptimizer

An orbital optimizer using a simple cost function and any Minimizer to perform the optimization.

SimpleOrbitalOptimizerCreator

Creator for the orbital optimizer algorithm.

class SimpleOrbitalOptimizer

Bases: OrbitalOptimizerAlgorithm

An orbital optimizer using a simple cost function and any Minimizer to perform the optimization.

__init__(estimator: Estimator, minimizer: Minimizer, mapper: Mapper | None = None, shots: int | None = None) None

Initialize orbital optimizer.

Parameters:
  • estimator (Estimator) – The estimator to use in the cost function.

  • minimizer (Minimizer) – The minimizer to use in the orbital optimization algorithm.

  • mapper (Mapper | None) – Mapper to use for creating qubit operators.

  • shots (int | None) – Number of shots to use for the estimator.

Return type:

None

clear_cache() None

Clear the cache of the underlying estimator.

Return type:

None

property mapper: Mapper

Return the mapper.

run(operator: T, circuit: Circuit) OrbitalOptimizerResult[T]

Run the orbital optimization and find the eigenvalue.

The orbital optimizer rotates the observable so that the expectation value is minimized.

Parameters:
  • operator (T) – The operator whose expectation value should be minimized.

  • circuit (Circuit) – The parametrized circuit to find optimal parameters for. Should contain unspecified parameters.

  • callback – An optional callback function that is called at each minimizer iteration.

Return type:

OrbitalOptimizerResult[T]

class SimpleOrbitalOptimizerCreator

Bases: object

Creator for the orbital optimizer algorithm.

__init__() None

Initialize builder for the orbital optimizer.

Return type:

None

choose_minimizer() MinimizerSubCreator[Self]

Choose minimizer to use for the orbital optimizer.

Return type:

MinimizerSubCreator[Self]

create() SimpleOrbitalOptimizer

Create an instance of SimpleOrbitalOptimizer.

Return type:

SimpleOrbitalOptimizer

with_estimator(estimator: Estimator) SimpleOrbitalOptimizerCreator

Set the estimator to use for the orbital optimizer.

Parameters:

estimator (Estimator) – Estimator to use. Can be created using the estimator_creator() builder.

Return type:

SimpleOrbitalOptimizerCreator

with_shots(shots: int | None) SimpleOrbitalOptimizerCreator

Set the number of shots to use when calling the estimator.

Parameters:

shots (int | None) – Number of shots to use in the estimator. If None is given, the estimator is assumed to be exact (e.g. the excitation gate simulator).

Return type:

SimpleOrbitalOptimizerCreator