pub struct MLCircuitOptimizer {
pub strategy: MLOptimizationStrategy,
pub max_passes: usize,
pub convergence_threshold: f64,
}Expand description
ML-driven circuit optimizer.
Uses a simple learned heuristic — prefer circuits with lower two-qubit gate count weighted by estimated depth — to select among candidate transformed circuits. The optimisation proceeds in passes; each pass tries commuting independent gates and removing adjacent inverse pairs.
§Strategy
MLOptimizationStrategy | Scoring function |
|---|---|
MinimizeGateCount | total gate count |
MinimizeDepth | circuit depth (critical path) |
BalancedOptimization | 10 * two_q + total + depth |
Fields§
§strategy: MLOptimizationStrategyOptimisation strategy
max_passes: usizeMaximum number of optimisation passes
convergence_threshold: f64Minimum score improvement to continue iterating (as a fraction)
Implementations§
Source§impl MLCircuitOptimizer
impl MLCircuitOptimizer
Sourcepub fn new(strategy: MLOptimizationStrategy) -> Self
pub fn new(strategy: MLOptimizationStrategy) -> Self
Create a new optimizer with the given strategy and default pass limit.
Sourcepub fn with_passes(self, passes: usize) -> Self
pub fn with_passes(self, passes: usize) -> Self
Create a balanced optimizer with a custom pass limit.
Sourcepub fn optimize<const N: usize>(
&self,
circuit: &Circuit<N>,
) -> QuantRS2Result<Circuit<N>>
pub fn optimize<const N: usize>( &self, circuit: &Circuit<N>, ) -> QuantRS2Result<Circuit<N>>
Optimise circuit and return the best circuit found together with its
score.
The method uses graph-based topology analysis (SciRS2GraphTranspiler)
to identify commuting gate pairs, then greedily reorders them to
minimise the composite score under the chosen strategy.
Sourcepub fn score<const N: usize>(&self, circuit: &Circuit<N>) -> CircuitScore
pub fn score<const N: usize>(&self, circuit: &Circuit<N>) -> CircuitScore
Return the current score for a circuit without modifying it.
Auto Trait Implementations§
impl Freeze for MLCircuitOptimizer
impl RefUnwindSafe for MLCircuitOptimizer
impl Send for MLCircuitOptimizer
impl Sync for MLCircuitOptimizer
impl Unpin for MLCircuitOptimizer
impl UnsafeUnpin for MLCircuitOptimizer
impl UnwindSafe for MLCircuitOptimizer
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.