Camargue
tooth.hpp
1 #ifndef CMR_TOOTH_HPP
2 #define CMR_TOOTH_HPP
3 
4 #include "graph.hpp"
5 #include "active_tour.hpp"
6 #include "datagroups.hpp"
7 #include "cut_structs.hpp"
8 #include "util.hpp"
9 #include "timer.hpp"
10 
11 #include <array>
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 #include <utility>
16 #include <vector>
17 
18 namespace CMR {
19 namespace Sep {
20 
22 public:
23  CandidateTeeth(const LP::ActiveTour &active_tour_,
24  Data::SupportGroup &_supp_dat);
25 
26  void get_light_teeth();
27 
29  static std::pair<int, int> get_range(ToothBody s,
30  const std::vector<int> &perm,
31  const std::vector<Graph::AdjObj>
32  &root_nbrs);
33 
34  static bool root_equivalent(int root, ToothBody s1, ToothBody s2,
35  const std::vector<int> &tour,
36  const std::vector<int> &perm,
37  const std::vector<Graph::Node> &nodelist);
38 
39  bool root_equivalent(int root, ToothBody s1, ToothBody s2) const;
40 
41  void sort_by_root();
42 
43  static void print_tooth(const SimpleTooth &T, bool full,
44  const std::vector<int> &tour_nodes);
45  void print_tooth(const SimpleTooth &T, bool full);
46  std::string print_label(const SimpleTooth &T);
47 
48  void profile();
49 
50  using ToothList = std::vector<SimpleTooth::Ptr>;
52 
53  std::vector<ToothList> light_teeth;
54 
55  static std::vector<IteratorMat> seen_ranges;
56  std::vector<std::array<int, 3>> list_sizes;
57 
58 private:
59  friend class DPwitness;
60 
61  std::vector<int> endmark;
62 
63  static void add_tooth(ToothList &teeth,
64  std::vector<IteratorMat> &ranges,
65  std::array<int, 3> &sizes,
66  int root, int body_start,
67  int body_end, double slack,
68  const std::vector<int> &tour,
69  const std::vector<int> &perm,
70  const std::vector<Graph::Node> &nodelist);
71 
72  static int teeth_cb(double cut_val, int cut_start, int cut_end,
73  void *u_data);
74 
75  struct LinsubCBData {
76  LinsubCBData(std::vector<ToothList> &_light_teeth,
77  std::vector<IteratorMat> &_ranges,
78  std::vector<std::array<int, 3>> &_list_sizes,
79  std::vector<bool> &_node_marks,
80  const std::vector<int> &_tour_nodes,
81  const std::vector<int> &_perm,
82  const Graph::AdjList &_G_s) :
83  light_teeth(_light_teeth),ranges(_ranges), list_sizes(_list_sizes),
84  node_marks(_node_marks),
85  tour_nodes(_tour_nodes), perm(_perm),
86  G_s(_G_s),
87  old_seg(_G_s.node_count - 1, _G_s.node_count - 1, 0.0)
88  {}
89 
90  std::vector<std::vector<SimpleTooth::Ptr>> &light_teeth;
91  std::vector<IteratorMat> &ranges;
92  std::vector<std::array<int, 3>> &list_sizes;
93 
94  std::vector<bool> &node_marks;
95  const std::vector<int> &tour_nodes;
96  const std::vector<int> &perm;
97 
98  const Graph::AdjList &G_s;
99 
100  ToothBody old_seg;
101 
102  std::unordered_map<int, double> rb_sums;
103  };
104 
105  const LP::ActiveTour &active_tour;
106  Data::SupportGroup &supp_dat;
107 
108  Timer t_all;
109  Timer t_pre;
110  Timer t_find;
111  Timer t_sort;
112 };
113 
114 }
115 }
116 
117 #endif
Class template for a square upper triangular matrix.
Definition: util.hpp:141
Support graph data for an LP solution.
Definition: datagroups.hpp:174
Class for building miniature simple DP witness cutgraphs.
Definition: witness.hpp:19
Representing bodies of simple tooth inequalities with associated slack.
Definition: cut_structs.hpp:29
Header for classes/structures/functions to work with graphs.
Data group structures.
static std::pair< int, int > get_range(ToothBody s, const std::vector< int > &perm, const std::vector< Graph::AdjObj > &root_nbrs)
Get the range of adjacency zones for a tooth body wrt a given root.
Definition: tooth.cpp:164
Information about the active tour in a CoreLP.
Definition: active_tour.hpp:30
Utility functions, macros, and structures.
A class for recording CPU and wall clock time.
Definition: timer.hpp:10
Representing simple tooth inequalities.
Definition: cut_structs.hpp:39
The namespace for this project.
Definition: abc_nodesel.hpp:20
Representation of a graph as an adjacency list.
Definition: graph.hpp:80
Definition: tooth.hpp:21
Monitoring the active tour in the solution process.