quantrs2_tytan/solution_debugger/
types.rs1use scirs2_core::ndarray::Array2;
4use serde::Serialize;
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Serialize)]
9pub struct ProblemInfo {
10 pub name: String,
12 pub problem_type: String,
14 pub num_variables: usize,
16 pub var_map: HashMap<String, usize>,
18 pub reverse_var_map: HashMap<usize, String>,
20 pub qubo: Array2<f64>,
22 pub constraints: Vec<ConstraintInfo>,
24 pub optimal_solution: Option<Solution>,
26 pub metadata: HashMap<String, String>,
28}
29
30#[derive(Debug, Clone, serde::Serialize)]
31pub struct Solution {
32 pub assignments: HashMap<String, bool>,
34 pub energy: f64,
36 pub quality_metrics: HashMap<String, f64>,
38 pub metadata: HashMap<String, String>,
40 pub sampling_stats: Option<SamplingStats>,
42}
43
44#[derive(Debug, Clone, Serialize)]
45pub struct SamplingStats {
46 pub num_reads: usize,
48 pub annealing_time: f64,
50 pub chain_break_fraction: f64,
52 pub sampler: String,
54}
55
56#[derive(Debug, Clone, Serialize)]
58pub struct ConstraintInfo {
59 pub name: Option<String>,
61 pub constraint_type: ConstraintType,
63 pub variables: Vec<String>,
65 pub parameters: HashMap<String, f64>,
67 pub penalty: f64,
69 pub description: Option<String>,
71}
72
73#[derive(Debug, Clone, Serialize)]
74pub enum ConstraintType {
75 Equality { target: f64 },
77 Inequality {
79 bound: f64,
80 direction: InequalityDirection,
81 },
82 AllDifferent,
84 ExactlyOne,
86 AtMostOne,
88 Custom { evaluator: String },
90}
91
92#[derive(Debug, Clone, Serialize)]
93pub enum InequalityDirection {
94 LessEqual,
95 GreaterEqual,
96}