-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathsimplex.h
More file actions
76 lines (63 loc) · 2.48 KB
/
simplex.h
File metadata and controls
76 lines (63 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SIMPLEX_HPP
#define SIMPLEX_HPP
#include <vector>
#include "common.h"
#include "stim.h"
struct HighsModel;
struct Highs;
enum class HighsStatus;
struct SimplexConfig {
stim::DetectorErrorModel dem;
bool parallelize = false;
size_t window_length = 0;
size_t window_slide_length = 0;
bool verbose = false;
bool windowing_enabled() { return (window_length != 0); }
std::string str();
};
struct SimplexDecoder {
SimplexConfig config;
std::vector<common::Error> errors;
size_t num_detectors = 0;
size_t num_observables = 0;
std::vector<size_t> predicted_errors_buffer;
std::vector<common::ObservablesMask> error_masks;
std::vector<std::vector<size_t>> start_time_to_errors;
std::vector<std::vector<size_t>> end_time_to_errors;
std::unique_ptr<HighsModel> model;
std::unique_ptr<Highs> highs;
std::unique_ptr<HighsStatus> return_status;
// For consistency with Tesseract, we provide a low confidence flag on Simplex
// decoder which is always set to false
const bool low_confidence_flag = false;
SimplexDecoder(SimplexConfig config);
void init_ilp();
// Clears the predicted_errors_buffer and fills it with the decoded errors for
// these detection events.
void decode_to_errors(const std::vector<uint64_t>& detections);
// Returns the bitwise XOR of all the observables bitmasks of all errors in
// the predicted errors buffer.
common::ObservablesMask mask_from_errors(
const std::vector<size_t>& predicted_errors);
// Returns the sum of the likelihood costs (minus-log-likelihood-ratios) of
// all errors in the predicted errors buffer.
double cost_from_errors(const std::vector<size_t>& predicted_errors);
common::ObservablesMask decode(const std::vector<uint64_t>& detections);
void decode_shots(std::vector<stim::SparseShot>& shots,
std::vector<common::ObservablesMask>& obs_predicted);
~SimplexDecoder();
};
#endif // SIMPLEX_HPP