qrunch.chemistry.orbital_optimizers.newton_orbital_optimizer
Module containing an orbital optimizer implementation using Newton’s method.
Module Attributes
The default options for the Newton Orbital Optimizer Scipy minimizer. |
Classes
The default options for SciPy minimizer. |
|
Implement a solver to find and apply Newton's method for orbital optimization. |
|
Builder for the orbital optimizer algorithm using Newton's method. |
- DEFAULT_OPTIONS
The default options for the Newton Orbital Optimizer Scipy minimizer.
- class NewtonMinimizerOptions
Bases:
DataclassPublicAPIThe default options for SciPy minimizer.
Options controlling
NewtonOrbitalOptimizer. All fields are immutable (frozen=True) so an instance can be safely reused.- Parameters:
relative_error_tolerance – Convergence tolerance (default=1.0e-5)
max_iterations_per_parameter – Maximum number of iterations per parameter. (default=10000)
jacobian_step_size – Jacobian step size (default=1e-6)
- __init__(*, relative_error_tolerance: float = 1e-05, max_iterations_per_parameter: int = 10000, jacobian_step_size: float = 1e-06) None
- Parameters:
relative_error_tolerance (float)
max_iterations_per_parameter (int)
jacobian_step_size (float)
- Return type:
None
- static __new__(cls, *args: Any, **kwargs: Any) Any
- Parameters:
args (Any)
kwargs (Any)
- Return type:
Any
- jacobian_step_size: float = 1e-06
- max_iterations_per_parameter: int = 10000
- relative_error_tolerance: float = 1e-05
- class NewtonOrbitalOptimizer
Bases:
OrbitalOptimizerAlgorithmImplement a solver to find and apply Newton’s method for orbital optimization.
- __init__(gradient_calculator: GradientCalculator, shots: int | None = None, options: NewtonMinimizerOptions = NewtonMinimizerOptions(relative_error_tolerance=1e-05, max_iterations_per_parameter=10000, jacobian_step_size=1e-06)) None
Initialize builder for the orbital optimizer.
- Parameters:
gradient_calculator (GradientCalculator) – The object that can calculate gradients and Hessians.
shots (int | None) – Number of shots to use.
options (NewtonMinimizerOptions) – Options to pass to the minimizer
- Return type:
None
- clear_cache() None
Clear the cache of the underlying estimator.
- Return type:
None
- run(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol, circuit: Circuit) OrbitalOptimizerResult
Compute kappa analytically at zero kappa using Newton’s method.
The method uses the gradient and Hessian in from the gradient calculator.
- Parameters:
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) – The operator to rotate.
circuit (Circuit) – The circuit used to evaluate the operator.
- Return type:
- class NewtonOrbitalOptimizerOrbitalOptimizerCreator
Bases:
objectBuilder for the orbital optimizer algorithm using Newton’s method.
- __init__() None
Initialize builder for the orbital optimizer.
- Return type:
None
- choose_gradient_calculator() GradientCalculatorSubCreator[Self]
Choose gradient calculator to use for the orbital optimizer.
- Return type:
- create() NewtonOrbitalOptimizer
Create an instance of
NewtonOrbitalOptimizer.- Return type:
- with_options(options: NewtonMinimizerOptions) Self
Set the options to use for the orbital optimizer.
- Parameters:
options (NewtonMinimizerOptions) – Options to pass to the minimizer
- Return type:
Self
- with_shots(shots: int | None) Self
Set the number of shots to use when calling the gradient_calculator to compute the energy, gradient, etc.
- 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:
Self