quantrs2_anneal/quantum_error_correction/
config.rs

1//! Quantum Error Correction Configuration Types
2
3use crate::ising::IsingError;
4use thiserror::Error;
5
6/// Errors that can occur in quantum error correction
7#[derive(Error, Debug)]
8pub enum QuantumErrorCorrectionError {
9    /// Ising model error
10    #[error("Ising error: {0}")]
11    IsingError(#[from] IsingError),
12
13    /// Error correction code error
14    #[error("Error correction code error: {0}")]
15    CodeError(String),
16
17    /// Syndrome detection error
18    #[error("Syndrome detection error: {0}")]
19    SyndromeError(String),
20
21    /// Logical operation error
22    #[error("Logical operation error: {0}")]
23    LogicalOperationError(String),
24
25    /// Decoding error
26    #[error("Decoding error: {0}")]
27    DecodingError(String),
28
29    /// Threshold error
30    #[error("Threshold error: {0}")]
31    ThresholdError(String),
32
33    /// Resource estimation error
34    #[error("Resource estimation error: {0}")]
35    ResourceEstimationError(String),
36}
37
38/// Result type for quantum error correction operations
39pub type QECResult<T> = Result<T, QuantumErrorCorrectionError>;
40
41/// Configuration for quantum error correction
42#[derive(Debug, Clone)]
43pub struct QECConfig {
44    /// Error correction code type
45    pub code_type: ErrorCorrectionCode,
46    /// Code parameters
47    pub code_parameters: CodeParameters,
48    /// Error threshold
49    pub error_threshold: f64,
50    /// Correction frequency
51    pub correction_frequency: f64,
52    /// Logical operations
53    pub logical_operations: Vec<LogicalOperation>,
54    /// Fault tolerance level
55    pub fault_tolerance_level: usize,
56    /// Resource constraints
57    pub resource_constraints: ResourceConstraints,
58    /// Annealing integration
59    pub annealing_integration: AnnealingIntegration,
60}
61
62// Forward declarations for types that will be defined in other modules
63use super::{
64    annealing_integration::AnnealingIntegration, codes::CodeParameters, codes::ErrorCorrectionCode,
65    logical_operations::LogicalOperation, resource_constraints::ResourceConstraints,
66};
67
68impl Default for QECConfig {
69    fn default() -> Self {
70        Self {
71            code_type: ErrorCorrectionCode::RepetitionCode,
72            code_parameters: CodeParameters::default(),
73            error_threshold: 0.01,
74            correction_frequency: 1000.0,
75            logical_operations: Vec::new(),
76            fault_tolerance_level: 1,
77            resource_constraints: ResourceConstraints::default(),
78            annealing_integration: AnnealingIntegration::default(),
79        }
80    }
81}