PulseOptimizer

Struct PulseOptimizer 

Source
pub struct PulseOptimizer { /* private fields */ }
Expand description

Pulse optimization

Implementations§

Source§

impl PulseOptimizer

Source

pub fn new() -> Self

Create a new optimizer

Examples found in repository?
examples/pulse_demo.rs (line 274)
270fn demo_pulse_optimization() -> quantrs2_core::error::QuantRS2Result<()> {
271    println!("--- Pulse Optimization ---");
272
273    let sample_rate = 1.0;
274    let optimizer = PulseOptimizer::new();
275
276    // Create initial pulse
277    let mut pulse = Waveform::gaussian(0.5, 15.0, 60.0, sample_rate);
278    println!("Initial pulse:");
279    println!("  Type: Gaussian");
280    println!("  Duration: {} ns", pulse.duration);
281    println!("  Max amplitude: {:.4}", pulse.max_amplitude());
282
283    // Apply DRAG correction
284    optimizer.apply_drag_correction(&mut pulse, 0.1)?;
285    println!("\nAfter DRAG correction:");
286    println!(
287        "  Has imaginary component: {}",
288        pulse.samples.iter().any(|s| s.im.abs() > 1e-10)
289    );
290
291    // Create a pulse schedule to optimize
292    let mut schedule = PulseSchedule::new();
293
294    // Add multiple pulses
295    for i in 0..3 {
296        let waveform = Waveform::gaussian(0.4, 12.0, 48.0, sample_rate);
297        schedule.add_instruction(
298            i as f64 * 60.0,
299            PulseInstruction::Play {
300                waveform,
301                channel: Channel::Drive(i),
302                phase: 0.0,
303            },
304        );
305    }
306
307    println!("\nSchedule optimization:");
308    println!("  Original duration: {} ns", schedule.duration);
309
310    // Optimize (placeholder - would do actual optimization)
311    optimizer.optimize(&mut schedule)?;
312
313    println!(
314        "  Optimized duration: {} ns (placeholder)",
315        schedule.duration
316    );
317    println!("  Target fidelity: 0.999"); // Placeholder since field is private
318
319    // Demonstrate pulse shaping techniques
320    println!("\nPulse shaping techniques:");
321    println!("  - Gaussian: Smooth envelope, reduced frequency spread");
322    println!("  - DRAG: Reduces leakage to higher levels");
323    println!("  - Cosine: Smooth turn-on/off");
324    println!("  - GRAPE: Optimal control for specific unitaries");
325
326    println!();
327    Ok(())
328}
Source

pub fn optimize(&self, schedule: &mut PulseSchedule) -> QuantRS2Result<()>

Optimize a pulse schedule

Examples found in repository?
examples/pulse_demo.rs (line 311)
270fn demo_pulse_optimization() -> quantrs2_core::error::QuantRS2Result<()> {
271    println!("--- Pulse Optimization ---");
272
273    let sample_rate = 1.0;
274    let optimizer = PulseOptimizer::new();
275
276    // Create initial pulse
277    let mut pulse = Waveform::gaussian(0.5, 15.0, 60.0, sample_rate);
278    println!("Initial pulse:");
279    println!("  Type: Gaussian");
280    println!("  Duration: {} ns", pulse.duration);
281    println!("  Max amplitude: {:.4}", pulse.max_amplitude());
282
283    // Apply DRAG correction
284    optimizer.apply_drag_correction(&mut pulse, 0.1)?;
285    println!("\nAfter DRAG correction:");
286    println!(
287        "  Has imaginary component: {}",
288        pulse.samples.iter().any(|s| s.im.abs() > 1e-10)
289    );
290
291    // Create a pulse schedule to optimize
292    let mut schedule = PulseSchedule::new();
293
294    // Add multiple pulses
295    for i in 0..3 {
296        let waveform = Waveform::gaussian(0.4, 12.0, 48.0, sample_rate);
297        schedule.add_instruction(
298            i as f64 * 60.0,
299            PulseInstruction::Play {
300                waveform,
301                channel: Channel::Drive(i),
302                phase: 0.0,
303            },
304        );
305    }
306
307    println!("\nSchedule optimization:");
308    println!("  Original duration: {} ns", schedule.duration);
309
310    // Optimize (placeholder - would do actual optimization)
311    optimizer.optimize(&mut schedule)?;
312
313    println!(
314        "  Optimized duration: {} ns (placeholder)",
315        schedule.duration
316    );
317    println!("  Target fidelity: 0.999"); // Placeholder since field is private
318
319    // Demonstrate pulse shaping techniques
320    println!("\nPulse shaping techniques:");
321    println!("  - Gaussian: Smooth envelope, reduced frequency spread");
322    println!("  - DRAG: Reduces leakage to higher levels");
323    println!("  - Cosine: Smooth turn-on/off");
324    println!("  - GRAPE: Optimal control for specific unitaries");
325
326    println!();
327    Ok(())
328}
Source

pub fn apply_drag_correction( &self, waveform: &mut Waveform, beta: f64, ) -> QuantRS2Result<()>

Apply DRAG correction

Examples found in repository?
examples/pulse_demo.rs (line 284)
270fn demo_pulse_optimization() -> quantrs2_core::error::QuantRS2Result<()> {
271    println!("--- Pulse Optimization ---");
272
273    let sample_rate = 1.0;
274    let optimizer = PulseOptimizer::new();
275
276    // Create initial pulse
277    let mut pulse = Waveform::gaussian(0.5, 15.0, 60.0, sample_rate);
278    println!("Initial pulse:");
279    println!("  Type: Gaussian");
280    println!("  Duration: {} ns", pulse.duration);
281    println!("  Max amplitude: {:.4}", pulse.max_amplitude());
282
283    // Apply DRAG correction
284    optimizer.apply_drag_correction(&mut pulse, 0.1)?;
285    println!("\nAfter DRAG correction:");
286    println!(
287        "  Has imaginary component: {}",
288        pulse.samples.iter().any(|s| s.im.abs() > 1e-10)
289    );
290
291    // Create a pulse schedule to optimize
292    let mut schedule = PulseSchedule::new();
293
294    // Add multiple pulses
295    for i in 0..3 {
296        let waveform = Waveform::gaussian(0.4, 12.0, 48.0, sample_rate);
297        schedule.add_instruction(
298            i as f64 * 60.0,
299            PulseInstruction::Play {
300                waveform,
301                channel: Channel::Drive(i),
302                phase: 0.0,
303            },
304        );
305    }
306
307    println!("\nSchedule optimization:");
308    println!("  Original duration: {} ns", schedule.duration);
309
310    // Optimize (placeholder - would do actual optimization)
311    optimizer.optimize(&mut schedule)?;
312
313    println!(
314        "  Optimized duration: {} ns (placeholder)",
315        schedule.duration
316    );
317    println!("  Target fidelity: 0.999"); // Placeholder since field is private
318
319    // Demonstrate pulse shaping techniques
320    println!("\nPulse shaping techniques:");
321    println!("  - Gaussian: Smooth envelope, reduced frequency spread");
322    println!("  - DRAG: Reduces leakage to higher levels");
323    println!("  - Cosine: Smooth turn-on/off");
324    println!("  - GRAPE: Optimal control for specific unitaries");
325
326    println!();
327    Ok(())
328}

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Ungil for T
where T: Send,