VQE

Struct VQE 

Source
pub struct VQE<A: Ansatz> { /* private fields */ }
Expand description

Variational Quantum Eigensolver for ground state energy estimation.

§Example

use logosq_algorithms::{VQE, Hamiltonian, HardwareEfficientAnsatz};

let hamiltonian = Hamiltonian::new(4);
let ansatz = HardwareEfficientAnsatz::new(4, 2);
let vqe = VQE::new(hamiltonian, ansatz);
println!("VQE has {} parameters", vqe.num_parameters());

Implementations§

Source§

impl<A: Ansatz> VQE<A>

Source

pub fn new(hamiltonian: Hamiltonian, ansatz: A) -> Self

Create a new VQE instance.

Source

pub fn with_shots(self, shots: u32) -> Self

Set the number of measurement shots.

Source

pub fn with_max_iterations(self, max_iterations: usize) -> Self

Set the maximum iterations.

Source

pub fn with_convergence_threshold(self, threshold: f64) -> Self

Set the convergence threshold.

Source

pub fn with_optimizer(self, optimizer: &str) -> Self

Set the optimizer.

Source

pub fn num_parameters(&self) -> usize

Get the number of variational parameters.

Source

pub fn evaluate(&self, parameters: &[f64]) -> Result<f64, AlgorithmError>

Evaluate energy for given parameters.

Source

pub fn evaluate_with_gradients( &self, parameters: &[f64], ) -> Result<(f64, Vec<f64>), AlgorithmError>

Evaluate energy and gradients using parameter-shift rule.

Source

pub fn run(&self) -> Result<VQEResult, AlgorithmError>

Run the VQE optimization.

Auto Trait Implementations§

§

impl<A> Freeze for VQE<A>
where A: Freeze,

§

impl<A> RefUnwindSafe for VQE<A>
where A: RefUnwindSafe,

§

impl<A> Send for VQE<A>

§

impl<A> Sync for VQE<A>

§

impl<A> Unpin for VQE<A>
where A: Unpin,

§

impl<A> UnwindSafe for VQE<A>
where A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.