#[repr(C)]pub struct SpsaOptimizer {}Expand description
SPSA optimizer for quantum hardware noise resilience
Fields§
§parameters: [f64; 20]Current parameters
perturbation: [f64; 20]Perturbation vector
gradient: [f64; 20]Gradient estimates
cost_plus: f64Cost evaluations
cost_minus: f64§ck: f64Perturbation parameters
ak: f64§a: f64§c: f64§alpha: f64§gamma: f64§num_params: u8Number of parameters
config: SolverConfigSolver configuration
solver_state: SolverStateSolver state
Implementations§
Source§impl SpsaOptimizer
impl SpsaOptimizer
Sourcepub fn new(num_params: u8, config: SolverConfig) -> Self
pub fn new(num_params: u8, config: SolverConfig) -> Self
Create new SPSA optimizer
Sourcepub fn optimize<F>(
&mut self,
f: &F,
initial_params: &[f64; 20],
) -> SolverResult<QuantumOptimizerState>where
F: SpsaCostFunction,
pub fn optimize<F>(
&mut self,
f: &F,
initial_params: &[f64; 20],
) -> SolverResult<QuantumOptimizerState>where
F: SpsaCostFunction,
Optimize parameters using SPSA algorithm
Sourcepub fn get_parameters(&self) -> [f64; 20]
pub fn get_parameters(&self) -> [f64; 20]
Get optimized parameters
Sourcepub fn get_gradient(&self) -> SpsaGradient
pub fn get_gradient(&self) -> SpsaGradient
Get gradient information
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpsaOptimizer
impl RefUnwindSafe for SpsaOptimizer
impl Send for SpsaOptimizer
impl Sync for SpsaOptimizer
impl Unpin for SpsaOptimizer
impl UnsafeUnpin for SpsaOptimizer
impl UnwindSafe for SpsaOptimizer
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Aggregate shares in an MPC protocol.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.