Camargue
core_lp.hpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
5 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
6 
7 #ifndef CMR_CORE_LP_H
8 #define CMR_CORE_LP_H
9 
10 #include "lp_interface.hpp"
11 #include "active_tour.hpp"
12 #include "cc_lpcuts.hpp"
13 #include "process_cuts.hpp"
14 #include "datagroups.hpp"
15 #include "hypergraph.hpp"
16 #include "util.hpp"
17 
18 #include <algorithm>
19 #include <utility>
20 #include <vector>
21 
22 namespace CMR {
23 
24 class Solver;
25 
26 namespace LP {
27 
28 
33 class CoreLP : public Relaxation {
34 public:
36  CoreLP(Graph::CoreGraph &core_graph_, Data::BestGroup &best_data_);
37 
40 
41  void pivot_back(bool prune_slacks);
42 
46 
48  void add_cuts(Sep::LPcutList &cutq);
49  void add_cuts(Sep::CutQueue<Sep::dominoparity> &dp_q);
50  void add_cuts(Sep::CutQueue<LP::SparseRow> &gmi_q);
51  void add_cuts(Sep::CutQueue<Sep::ex_blossom> &ex2m_q);
52  void add_cuts(Sep::CutQueue<Sep::HyperGraph> &pool_q);
53 
55 
57  void add_edges(const std::vector<Graph::Edge> &add_batch,
58  bool reinstate);
59 
61  void remove_edges(std::vector<int> edge_delstat, bool reinstate);
62 
63 
65  template<typename numtype>
66  bool check_feas(const std::vector<numtype> &x_vec);
67 
68  const Data::SupportGroup &support_data() const { return supp_data; }
69  const Sep::ExternalCuts &external_cuts() const { return ext_cuts; }
70  const LP::ActiveTour &get_active_tour() const { return active_tour; }
71 
73  void set_active_tour(std::vector<int> tour_nodes);
74 
75  void tourless_mode();
76 
78  int avg_itcount() const { return sum_it_count / num_nd_pivots; }
79 
80  double active_tourlen() const { return active_tour.length(); }
81 
83  double global_ub() const { return best_data.min_tour_value; }
84 
85  bool verbose = false;
86 
87  friend class CMR::Solver;
88 
89 private:
91  void instate_active();
92 
94  void reset_instate_active();
95 
97  void handle_aug_pivot(std::vector<int> tour_nodes, Basis aug_base);
98 
99  void prune_slacks();
100 
101  void purge_gmi(bool instate);
102 
103  Graph::CoreGraph &core_graph;
104  Data::BestGroup &best_data;
105  Data::SupportGroup supp_data;
106 
107  Sep::ExternalCuts ext_cuts;
108 
109  ActiveTour active_tour;
110 
111  std::vector<double> lp_edges;
112  std::vector<double> pi_vals;
113  std::vector<double> feas_stat;
114 
115  int num_nd_pivots = 0;
116  int sum_it_count = 0;
117 
118  int prev_numrows;
119 
120  bool steepest_engaged = false;
121 };
122 
123 
124 }
125 }
126 
127 #endif
Support graph data for an LP solution.
Definition: datagroups.hpp:174
void instate_active()
Instate active_tour, checking feasibility if it throws.
Definition: core_lp.cpp:221
PivType
Enum class for categorizing lp solutions.
Definition: lp_util.hpp:34
Representing cuts outside the LP solver.
Information about the current best tour.
Definition: datagroups.hpp:154
double global_ub() const
The global upper bound for this instance.
Definition: core_lp.hpp:83
Management of Concorde lpcut_in linked list.
Definition: cc_lpcuts.hpp:56
void pivot_back(bool prune_slacks)
Pivot back to active_tour.
Definition: core_lp.cpp:164
The external storage of a collection of HyperGraph cuts in a Relaxation.
Definition: hypergraph.hpp:126
void add_edges(const std::vector< Graph::Edge > &add_batch, bool reinstate)
Add the edges in add_batch to the LP, modifying CoreLP::core_graph.
Definition: core_lp.cpp:512
void remove_edges(std::vector< int > edge_delstat, bool reinstate)
Remove edges in by edge_delstat from LP, modifying CoreLP::core_graph.
Definition: core_lp.cpp:558
Data group structures.
void set_active_tour(std::vector< int > tour_nodes)
Set active_tour from a list of nodes.
Definition: core_lp.cpp:311
Class template for queue of cuts in some form.
Definition: process_cuts.hpp:30
void tourless_mode()
Set active_tour to tourless mode.
Definition: core_lp.cpp:343
Graph structures for the edges currently in a CoreLP::Relaxation.
Definition: datagroups.hpp:100
Interface to the LP solver.
Row and column basic statuses corresponding to some LP solution.
Definition: lp_util.hpp:76
Information about the active tour in a CoreLP.
Definition: active_tour.hpp:30
Utility functions, macros, and structures.
Structures for storing and processing cuts.
int avg_itcount() const
Average number of iterations per primal_pivot.
Definition: core_lp.hpp:78
CoreLP(Graph::CoreGraph &core_graph_, Data::BestGroup &best_data_)
Construct a CoreLP from combinatorial TSP instance + best tour data.
Definition: core_lp.cpp:37
double min_tour_value
The tour length.
Definition: datagroups.hpp:170
Solution of TSP instances.
Definition: solver.hpp:37
Class for storing an lp relaxation via interface to an lp solver.
Definition: lp_interface.hpp:33
The namespace for this project.
Definition: abc_nodesel.hpp:20
void reset_instate_active()
As above but with a reset instate.
Definition: core_lp.cpp:247
void prune_slacks()
Prune cuts which are not tight at active_tour.
Definition: core_lp.cpp:352
void purge_gmi(bool instate)
Get rid of any GMI cuts in the LP.
Definition: core_lp.cpp:606
Class for storing the core lp associated to a TSP instance and pivoting.
Definition: core_lp.hpp:33
Monitoring the active tour in the solution process.
Wrappers for Concorde cut structures/separators.
bool check_feas(const std::vector< numtype > &x_vec)
Returns true iff x_vec satisfies all constraints and column bounds.
Definition: core_lp.cpp:640
void handle_aug_pivot(std::vector< int > tour_nodes, Basis aug_base)
Update active_tour via an augmenting pivot.
Definition: core_lp.cpp:279
LP::PivType primal_pivot()
Compute a primal non-degenerate pivot from the active_tour.
Definition: core_lp.cpp:81