pub struct CoherenceOptimization { /* private fields */ }
Expand description
Optimization pass that reduces circuit depth to minimize decoherence
Implementations§
Source§impl CoherenceOptimization
impl CoherenceOptimization
Sourcepub fn new(noise_model: NoiseModel) -> Self
pub fn new(noise_model: NoiseModel) -> Self
Create a new coherence optimization pass
Examples found in repository?
examples/noise_optimization_demo.rs (line 154)
145fn demo_noise_optimization_passes(
146 circuit: &Circuit<4>,
147) -> quantrs2_core::error::QuantRS2Result<()> {
148 println!("--- Individual Optimization Passes ---");
149
150 let noise_model = NoiseModel::ibm_like(4);
151 let coupling_map = CouplingMap::linear(4);
152
153 // Test coherence optimization
154 let coherence_opt = CoherenceOptimization::new(noise_model.clone());
155 let cost_model = NoiseAwareCostModel::new(noise_model.clone());
156
157 if coherence_opt.should_apply() {
158 let coherence_result = coherence_opt.apply(circuit, &cost_model)?;
159 println!("✓ Coherence optimization applied");
160 println!(" Original gates: {}", circuit.num_gates());
161 println!(" After coherence opt: {}", coherence_result.num_gates());
162 }
163
164 // Test noise-aware mapping
165 let mapping_opt = NoiseAwareMapping::new(noise_model.clone(), coupling_map.clone());
166 if mapping_opt.should_apply() {
167 let mapping_result = mapping_opt.apply(circuit, &cost_model)?;
168 println!("✓ Noise-aware mapping applied");
169 println!(" Original gates: {}", circuit.num_gates());
170 println!(" After mapping opt: {}", mapping_result.num_gates());
171 }
172
173 // Test dynamical decoupling
174 let dd_opt = DynamicalDecoupling::new(noise_model.clone());
175 if dd_opt.should_apply() {
176 let dd_result = dd_opt.apply(circuit, &cost_model)?;
177 println!("✓ Dynamical decoupling applied");
178 println!(" Original gates: {}", circuit.num_gates());
179 println!(" After DD insertion: {}", dd_result.num_gates());
180 }
181
182 println!();
183 Ok(())
184}
Trait Implementations§
Source§impl Clone for CoherenceOptimization
impl Clone for CoherenceOptimization
Source§fn clone(&self) -> CoherenceOptimization
fn clone(&self) -> CoherenceOptimization
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CoherenceOptimization
impl Debug for CoherenceOptimization
Source§impl OptimizationPass for CoherenceOptimization
impl OptimizationPass for CoherenceOptimization
Source§fn apply_to_gates(
&self,
gates: Vec<Box<dyn GateOp>>,
_cost_model: &dyn CostModel,
) -> QuantRS2Result<Vec<Box<dyn GateOp>>>
fn apply_to_gates( &self, gates: Vec<Box<dyn GateOp>>, _cost_model: &dyn CostModel, ) -> QuantRS2Result<Vec<Box<dyn GateOp>>>
Apply the optimization pass to a gate list
Source§fn should_apply(&self) -> bool
fn should_apply(&self) -> bool
Check if this pass should be applied
Auto Trait Implementations§
impl Freeze for CoherenceOptimization
impl RefUnwindSafe for CoherenceOptimization
impl Send for CoherenceOptimization
impl Sync for CoherenceOptimization
impl Unpin for CoherenceOptimization
impl UnwindSafe for CoherenceOptimization
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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, const N: usize> OptimizationPassExt<N> for Twhere
T: OptimizationPass + ?Sized,
impl<T, const N: usize> OptimizationPassExt<N> for Twhere
T: OptimizationPass + ?Sized,
Source§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.