use std::collections::{HashMap, HashSet};
use std::time::{Duration, SystemTime};
use scirs2_core::ndarray::Array2;
use serde::{Deserialize, Serialize};
use super::config::ComplianceStandard;
use super::types::{
AuthenticationMethod, AuthorizationModel, ConnectivityGraph, ImpactLevel, MaintenanceFrequency,
MeasurementType, QuantumFramework, SupportChannel,
};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProviderCapabilities {
pub basic: BasicCapabilities,
pub hardware: HardwareCapabilities,
pub software: SoftwareCapabilities,
pub performance: PerformanceCapabilities,
pub cost: CostCapabilities,
pub security: SecurityCapabilities,
pub support: SupportCapabilities,
pub advanced_features: AdvancedFeatures,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BasicCapabilities {
pub qubit_count: usize,
pub gate_set: HashSet<String>,
pub connectivity: ConnectivityGraph,
pub measurement_types: Vec<MeasurementType>,
pub classical_register_size: usize,
pub max_circuit_depth: Option<usize>,
pub max_shots: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HardwareCapabilities {
pub quantum_volume: Option<u32>,
pub error_rates: ErrorRates,
pub coherence_times: CoherenceTimes,
pub gate_times: HashMap<String, Duration>,
pub crosstalk: CrosstalkCharacteristics,
pub calibration: CalibrationInfo,
pub temperature: Option<f64>,
pub noise_characteristics: NoiseCharacteristics,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ErrorRates {
pub single_qubit_gates: HashMap<String, f64>,
pub two_qubit_gates: HashMap<String, f64>,
pub readout_errors: HashMap<usize, f64>,
pub average_error_rate: f64,
pub error_rate_variance: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CoherenceTimes {
pub t1_times: HashMap<usize, Duration>,
pub t2_times: HashMap<usize, Duration>,
pub average_t1: Duration,
pub average_t2: Duration,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CrosstalkCharacteristics {
pub crosstalk_matrix: Array2<f64>,
pub spectral_crosstalk: HashMap<String, f64>,
pub temporal_crosstalk: HashMap<String, f64>,
pub mitigation_strategies: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CalibrationInfo {
pub last_calibration: SystemTime,
pub calibration_frequency: Duration,
pub quality_score: f64,
pub drift_rate: f64,
pub calibration_method: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NoiseCharacteristics {
pub noise_model_type: String,
pub noise_parameters: HashMap<String, f64>,
pub noise_correlations: Array2<f64>,
pub environmental_factors: HashMap<String, f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SoftwareCapabilities {
pub supported_frameworks: Vec<QuantumFramework>,
pub programming_languages: Vec<String>,
pub compilation_features: CompilationFeatures,
pub optimization_features: OptimizationFeatures,
pub simulation_capabilities: SimulationCapabilities,
pub integration_capabilities: IntegrationCapabilities,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompilationFeatures {
pub circuit_optimization: bool,
pub gate_synthesis: bool,
pub routing_algorithms: Vec<String>,
pub transpilation_passes: Vec<String>,
pub custom_compilation: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OptimizationFeatures {
pub parameter_optimization: bool,
pub depth_optimization: bool,
pub gate_count_optimization: bool,
pub noise_aware_optimization: bool,
pub variational_algorithms: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimulationCapabilities {
pub classical_simulation: bool,
pub noise_simulation: bool,
pub error_simulation: bool,
pub max_simulated_qubits: Option<usize>,
pub simulation_backends: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IntegrationCapabilities {
pub rest_api: bool,
pub graphql_api: bool,
pub websocket_support: bool,
pub sdk_languages: Vec<String>,
pub third_party_integrations: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PerformanceCapabilities {
pub throughput: ThroughputMetrics,
pub latency: LatencyMetrics,
pub availability: AvailabilityMetrics,
pub scalability: ScalabilityCharacteristics,
pub resource_utilization: ResourceUtilizationMetrics,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThroughputMetrics {
pub circuits_per_hour: f64,
pub shots_per_second: f64,
pub jobs_per_day: f64,
pub peak_throughput: f64,
pub sustained_throughput: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LatencyMetrics {
pub submission_latency: Duration,
pub queue_wait_time: Duration,
pub execution_time: Duration,
pub result_retrieval_time: Duration,
pub total_turnaround_time: Duration,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AvailabilityMetrics {
pub uptime_percentage: f64,
pub mtbf: Duration,
pub mttr: Duration,
pub maintenance_windows: Vec<MaintenanceWindow>,
pub sla: Option<ServiceLevelAgreement>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MaintenanceWindow {
pub start_time: SystemTime,
pub duration: Duration,
pub frequency: MaintenanceFrequency,
pub impact_level: ImpactLevel,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServiceLevelAgreement {
pub guaranteed_uptime: f64,
pub max_response_time: Duration,
pub support_response_time: Duration,
pub resolution_time: Duration,
pub penalty_clauses: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScalabilityCharacteristics {
pub horizontal_scalability: bool,
pub vertical_scalability: bool,
pub auto_scaling: bool,
pub max_concurrent_jobs: Option<u32>,
pub load_balancing: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceUtilizationMetrics {
pub cpu_utilization: f64,
pub memory_utilization: f64,
pub network_utilization: f64,
pub storage_utilization: f64,
pub quantum_utilization: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostCapabilities {
pub cost_model: CostModel,
pub cost_optimization: CostOptimizationFeatures,
pub budget_management: BudgetManagementFeatures,
pub cost_transparency: CostTransparencyFeatures,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostModel {
pub pricing_structure: PricingStructure,
pub cost_factors: Vec<CostFactor>,
pub volume_discounts: Vec<VolumeDiscount>,
pub regional_pricing: HashMap<String, f64>,
pub supported_currencies: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PricingStructure {
Fixed,
Variable,
Tiered,
Usage,
Hybrid,
Negotiated,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostFactor {
pub name: String,
pub factor_type: CostFactorType,
pub unit_cost: f64,
pub minimum_charge: Option<f64>,
pub maximum_charge: Option<f64>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum CostFactorType {
PerShot,
PerCircuit,
PerMinute,
PerHour,
PerQubit,
PerGate,
PerJob,
Fixed,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VolumeDiscount {
pub min_volume: u64,
pub discount_percentage: f64,
pub discount_type: DiscountType,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum DiscountType {
Percentage,
Fixed,
Tiered,
Progressive,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostOptimizationFeatures {
pub cost_estimation: bool,
pub cost_tracking: bool,
pub budget_alerts: bool,
pub optimization_recommendations: bool,
pub spot_pricing: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BudgetManagementFeatures {
pub budget_setting: bool,
pub budget_monitoring: bool,
pub spending_limits: bool,
pub cost_allocation: bool,
pub invoice_management: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CostTransparencyFeatures {
pub realtime_cost_display: bool,
pub detailed_breakdown: bool,
pub historical_analysis: bool,
pub comparison_tools: bool,
pub cost_reporting: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecurityCapabilities {
pub authentication: Vec<AuthenticationMethod>,
pub authorization: Vec<AuthorizationModel>,
pub encryption: EncryptionCapabilities,
pub compliance: Vec<ComplianceStandard>,
pub security_monitoring: SecurityMonitoringCapabilities,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EncryptionCapabilities {
pub data_at_rest: bool,
pub data_in_transit: bool,
pub end_to_end: bool,
pub algorithms: Vec<String>,
pub key_management: KeyManagementCapabilities,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KeyManagementCapabilities {
pub customer_managed_keys: bool,
pub hsm_support: bool,
pub key_rotation: bool,
pub key_escrow: bool,
pub mpc_support: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecurityMonitoringCapabilities {
pub audit_logging: bool,
pub intrusion_detection: bool,
pub anomaly_detection: bool,
pub security_alerts: bool,
pub threat_intelligence: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SupportCapabilities {
pub support_channels: Vec<SupportChannel>,
pub support_hours: SupportHours,
pub response_times: ResponseTimeGuarantees,
pub documentation_quality: DocumentationQuality,
pub training_education: TrainingEducationCapabilities,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SupportHours {
pub business_hours: bool,
pub twenty_four_seven: bool,
pub weekend_support: bool,
pub holiday_support: bool,
pub timezone_coverage: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResponseTimeGuarantees {
pub critical_response_time: Duration,
pub high_priority_response_time: Duration,
pub medium_priority_response_time: Duration,
pub low_priority_response_time: Duration,
pub first_response_time: Duration,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocumentationQuality {
pub completeness_score: f64,
pub accuracy_score: f64,
pub clarity_score: f64,
pub up_to_date_score: f64,
pub example_quality: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TrainingEducationCapabilities {
pub online_courses: bool,
pub workshops: bool,
pub certification_programs: bool,
pub consulting_services: bool,
pub community_forums: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AdvancedFeatures {
pub ml_integration: MLIntegrationFeatures,
pub hybrid_computing: HybridComputingFeatures,
pub quantum_networking: QuantumNetworkingFeatures,
pub research_capabilities: ResearchCapabilities,
pub experimental_features: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MLIntegrationFeatures {
pub quantum_ml: bool,
pub classical_ml_integration: bool,
pub automl_support: bool,
pub ml_frameworks: Vec<String>,
pub gpu_acceleration: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HybridComputingFeatures {
pub classical_quantum_integration: bool,
pub realtime_feedback: bool,
pub iterative_algorithms: bool,
pub hpc_integration: bool,
pub edge_computing: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuantumNetworkingFeatures {
pub quantum_internet: bool,
pub qkd_support: bool,
pub distributed_computing: bool,
pub quantum_teleportation: bool,
pub network_protocols: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResearchCapabilities {
pub research_partnerships: bool,
pub academic_pricing: bool,
pub research_tools: bool,
pub data_sharing: bool,
pub publication_support: bool,
}