Camargue
cut_structs.hpp
1 #ifndef CMR_CUT_STRUCTS_H
2 #define CMR_CUT_STRUCTS_H
3 
4 #include "util.hpp"
5 
6 #include <utility>
7 #include <vector>
8 
9 namespace CMR {
10 namespace Sep {
11 
17 struct ex_blossom {
18  ex_blossom(std::vector<int> &_handle, int _cut_edge, double _val) :
19  handle(_handle), cut_edge(_cut_edge), cut_val(_val){}
20 
21  std::vector<int> handle;
22 
23  int cut_edge;
24 
25  double cut_val;
26 };
27 
29 struct ToothBody : Segment {
30  ToothBody() = default;
31  ToothBody(int _start, int _end, double _slack) :
32  Segment(_start, _end), slack(_slack) {}
33  ToothBody(int _start, int _end) : Segment(_start, _end), slack(1.0) {}
34 
35  double slack;
36 };
37 
39 struct SimpleTooth {
40  SimpleTooth(int _root, int _body_start, int _body_end, double _slack) :
41  root(_root), body_start(_body_start), body_end(_body_end),
42  slack(_slack) {}
43 
44  SimpleTooth(int _root, ToothBody &seg, double _slack) :
45  root(_root), body_start(seg.start), body_end(seg.end), slack(_slack) {}
46 
47  using Ptr = std::unique_ptr<SimpleTooth>;
48 
49  int root, body_start, body_end;
50  int cutgraph_index;
51  double slack;
52 
53  enum Type {
54  LeftAdj = 0,
55  RightAdj = 1,
56  Dist = 2
57  };
58 
59  Type type() const
60  {
61  if (body_start == root + 1)
62  return LeftAdj;
63  if (body_end + 1 == root)
64  return RightAdj;
65  return Dist;
66  }
67 
68  int body_size() const { return body_end - body_start + 1; }
69  bool body_contains(int i) const { return body_start <= i && i <= body_end; }
70  bool is_subset_of(const SimpleTooth &T) const {
71  return root == T.root &&
72  T.body_start <= body_start &&
73  body_end <= T.body_end;
74  }
75 
76 };
77 
84 struct dominoparity {
85  dominoparity() = default;
86  dominoparity(std::vector<SimpleTooth> &_used_teeth,
87  std::vector<int> &_degree_nodes,
88  std::vector<std::pair<int, int>> &_nonneg_edges) :
89  used_teeth(_used_teeth), degree_nodes(_degree_nodes),
90  nonneg_edges(_nonneg_edges) {}
91 
93  std::vector<SimpleTooth> used_teeth;
94 
96  std::vector<int> degree_nodes;
97 
99  std::vector<std::pair<int, int>> nonneg_edges;
100 };
101 
102 }
103 }
104 
105 
106 
107 #endif
std::vector< int > degree_nodes
The handle of the inequality, nodes where the degree eqns are used.
Definition: cut_structs.hpp:96
Structure for storing simple DP inequalities.
Definition: cut_structs.hpp:84
Representing bodies of simple tooth inequalities with associated slack.
Definition: cut_structs.hpp:29
int end
The end index of the Segment.
Definition: util.hpp:235
std::vector< std::pair< int, int > > nonneg_edges
Edges for which is used.
Definition: cut_structs.hpp:99
Utility functions, macros, and structures.
Representing simple tooth inequalities.
Definition: cut_structs.hpp:39
std::vector< SimpleTooth > used_teeth
Simple tooth inequalities to be aggregated to get the simple DP ineq.
Definition: cut_structs.hpp:93
The namespace for this project.
Definition: abc_nodesel.hpp:20
Structure for storing blossom inequalities from exact primal separation.
Definition: cut_structs.hpp:17
Simple utility struct for storing an interval of nodes.
Definition: util.hpp:198
int start
The start index of the Segment.
Definition: util.hpp:234