pub struct PulseOptimizer { /* private fields */ }
Expand description
Pulse optimization
Implementations§
Source§impl PulseOptimizer
impl PulseOptimizer
Sourcepub fn new() -> Self
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}
Sourcepub fn optimize(&self, schedule: &mut PulseSchedule) -> QuantRS2Result<()>
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}
Sourcepub fn apply_drag_correction(
&self,
waveform: &mut Waveform,
beta: f64,
) -> QuantRS2Result<()>
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§
impl Freeze for PulseOptimizer
impl RefUnwindSafe for PulseOptimizer
impl Send for PulseOptimizer
impl Sync for PulseOptimizer
impl Unpin for PulseOptimizer
impl UnwindSafe for PulseOptimizer
Blanket Implementations§
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
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.