discrete-modulus (C++)
Reference implementations of discrete modulus algorithms (C++)
Loading...
Searching...
No Matches
solver_trace.hpp
Go to the documentation of this file.
1
16#pragma once
17
18#include <ostream>
19#include <utility>
20#include <vector>
21
22#include <boost/rational.hpp>
23
24#include "graphs.hpp"
25
26namespace discrete_modulus {
27
28using namespace boost;
29
41struct TraceRound {
42 rational<long> theta;
43 std::vector<Vertex> vertices;
44 std::vector<std::pair<Vertex, Vertex>> crit_set;
45};
46
49 std::vector<TraceRound> rounds;
50};
51
59inline void write_trace_json(std::ostream& os, const SolverTrace& trace) {
60 os << "{\n \"version\": 1,\n \"rounds\": [\n";
61 for (std::size_t r = 0; r < trace.rounds.size(); ++r) {
62 const TraceRound& round = trace.rounds[r];
63
64 os << " {\n \"vertices\": [";
65 for (std::size_t i = 0; i < round.vertices.size(); ++i) {
66 if (i > 0) {
67 os << ", ";
68 }
69 os << round.vertices[i];
70 }
71
72 os << "],\n \"crit_set\": [";
73 for (std::size_t i = 0; i < round.crit_set.size(); ++i) {
74 if (i > 0) {
75 os << ", ";
76 }
77 os << "[" << round.crit_set[i].first << ", " << round.crit_set[i].second << "]";
78 }
79
80 os << "],\n \"theta\": [" << round.theta.numerator() << ", " << round.theta.denominator() << "]\n";
81 os << " }" << (r + 1 < trace.rounds.size() ? ",\n" : "\n");
82 }
83 os << " ]\n}\n";
84}
85
86} // namespace discrete_modulus
Graph/flow-graph type aliases, subgraph/component helpers, and demo graph generators used by cunningh...
Definition cunningham.hpp:50
void write_trace_json(std::ostream &os, const SolverTrace &trace)
Writes trace to os as versioned JSON ("version": 1).
Definition solver_trace.hpp:59
The full recorded trace of a spanning_tree_modulus run.
Definition solver_trace.hpp:48
std::vector< TraceRound > rounds
Definition solver_trace.hpp:49
One round of spanning_tree_modulus's main loop: the component it was carved from, the edge set dispat...
Definition solver_trace.hpp:41
rational< long > theta
Definition solver_trace.hpp:42
std::vector< std::pair< Vertex, Vertex > > crit_set
the dispatched edges
Definition solver_trace.hpp:44
std::vector< Vertex > vertices
the component's vertex set
Definition solver_trace.hpp:43