46 Solver(
const std::string &tsp_fname,
const std::string &tour_fname,
48 Solver(
const std::string &tsp_fname,
const std::string &tour_fname,
61 void set_lowerbound(
double lb);
64 LP::PivType cutting_loop(
bool do_price,
bool try_recover,
67 template <
typename SelectionRule>
73 const LP::ActiveTour &active_tour()
const {
return core_lp.active_tour; }
74 const LP::CoreLP &get_core_lp()
const {
return core_lp; }
102 bool localcuts =
false;
105 bool handling =
false;
106 bool teething =
false;
108 bool consec1 =
false;
110 bool tighten =
false;
111 bool tighten_pool =
false;
114 bool safeGMI =
false;
127 using AugObj = std::pair<Aug, double>;
128 const std::vector<AugObj> &get_aug_chart()
const {
return aug_chart; }
133 void report_aug(
Aug aug_type);
134 void initial_prints();
136 std::string file_infix();
139 static double PH_delta(
double new_val,
double prev_val,
double tourlen);
142 bool restart_loop(
LP::PivType piv,
double delta_metric);
162 void reset_separator(std::unique_ptr<Sep::Separator> &S);
164 void reset_separator(std::unique_ptr<Sep::MetaCuts> &MS);
166 void reset_separator(std::unique_ptr<Sep::SafeGomory> &GS);
173 initial_piv(first_piv), prev_val(first_piv), lowest_piv(first_piv)
176 void update(
double new_val,
double tourlen);
178 void report_extrema();
181 double prev_val = 0.0;
182 double delta_ratio = 0.0;
183 double lowest_piv = 0.0;
184 double max_ratio = 0.0;
185 double first_last_ratio = 0.0;
187 bool found_cuts =
false;
191 template <
typename Qtype>
192 bool call_separator(
const std::function<
bool()> &sepcall,
193 Qtype &sep_q,
const std::string sep_name,
196 double target_lb{-std::numeric_limits<double>::max() + 1.0};
205 std::unique_ptr<Price::Pricer> edge_pricer;
207 std::unique_ptr<ABC::BaseBrancher> branch_controller;
209 bool branch_engaged =
false;
214 std::vector<AugObj> aug_chart;
216 std::array<char, 80> p_bar;
217 void place_pivot(
double low_limit,
double best_tourlen,
double piv_val);
219 Timer time_overall{
"Solver Overall"};
220 Timer time_piv{
"Pivoting", &time_overall};
221 Timer time_price{
"Pricing", &time_overall};
222 Timer time_branch{
"Branching", &time_overall};
224 using TimerCalled = std::pair<Timer, bool>;
226 std::map<std::string, TimerCalled> sep_times{
227 {
"CutPool", {
Timer(
"CutPool", &time_overall),
false}},
228 {
"SegmentCuts", {
Timer(
"SegmentCuts", &time_overall),
false}},
229 {
"ConnectCuts", {
Timer(
"ConnectCuts", &time_overall),
false}},
230 {
"ExactSub", {
Timer(
"ExactSub", &time_overall),
false}},
231 {
"FastBlossoms", {
Timer(
"FastBlossoms", &time_overall),
false}},
232 {
"ExactBlossoms", {
Timer(
"FastBlossoms", &time_overall),
false}},
233 {
"BlockCombs", {
Timer(
"BlockCombs", &time_overall),
false}},
234 {
"SimpleDP", {
Timer(
"SimpleDP", &time_overall),
false}},
235 {
"LocalCuts", {
Timer(
"LocalCuts", &time_overall),
false}},
236 {
"Decker", {
Timer(
"Decker", &time_overall),
false}},
237 {
"Handling", {
Timer(
"Handling", &time_overall),
false}},
238 {
"Teething", {
Timer(
"Teething", &time_overall),
false}},
239 {
"Consec1", {
Timer(
"Consec1", &time_overall),
false}},
240 {
"Tighten", {
Timer(
"Tighten", &time_overall),
false}},
241 {
"TightenPool", {
Timer(
"TightenPool", &time_overall),
false}},
242 {
"SafeGMI", {
Timer(
"SafeGMI", &time_overall),
false}},
246 std::ostream &operator<<(std::ostream &os,
Solver::Aug aug);
257 template <
typename SelectionRule>
263 using std::runtime_error;
264 using std::logic_error;
268 runtime_error err(
"Problem in Solver::abc");
272 try { piv = cutting_loop(do_price,
true,
true); }
275 if (piv != PivType::Frac) {
276 if (piv == PivType::FathomedTour) {
280 cerr <<
"Pivot status " << piv <<
" in abc.\n";
281 throw logic_error(
"Invalid pivot type for running Solver::abc.");
288 edge_pricer->elim_edges(
true);
289 core_lp.primal_opt();
291 cout <<
"\tcol count " << core_lp.num_cols()
292 <<
", opt objval " << core_lp.get_objval() << endl;
296 core_lp.primal_opt();
298 cout <<
"\tRoot LP optimized with obj val " << core_lp.get_objval()
303 cout <<
"\tCommencing ABC search....\n";
306 branch_controller = util::make_unique<SelectionRule>(tsp_instance,
312 branch_engaged =
true;
313 branch_controller->verbose = output_prefs.verbose;
315 if (cut_sel.safeGMI) {
316 cout <<
"(Disabling GMI and purging cuts for branching.....)\n";
317 cut_sel.safeGMI =
false;
318 try { core_lp.purge_gmi(
true); }
322 try { piv = abc_bcp(do_price); }
325 cout <<
"\n\tABC search completed, optimal tour has length " 326 << best_data.min_tour_value << endl;
330 const ABC::BranchHistory &BH = branch_controller->get_history();
331 for (
const auto &B : BH)
332 if (B.depth > max_depth)
335 cout <<
"\t" << BH.size() <<
" branch nodes, max depth " 336 << max_depth << endl;
const double initial_piv
The first pivot val before adding cuts.
Definition: solver.hpp:180
Classes for node selection rules.
Aug
Types of augmentations that can take place.
Definition: solver.hpp:120
Tracking objective values of pivots within a cut_and_piv loop.
Definition: solver.hpp:170
PivType
Enum class for categorizing lp solutions.
Definition: lp_util.hpp:34
Information about the current best tour.
Definition: datagroups.hpp:154
Which separation routines should be called.
Definition: solver.hpp:77
LP::PivType abc(bool do_price)
Augment-branch-cut search.
Definition: solver.hpp:258
Add safe Gomory cuts.
Definition: solver.hpp:82
Graph structures for the edges currently in a CoreLP::Relaxation.
Definition: datagroups.hpp:100
Some straightforward separation routines.
Storing TSP instance data.
Definition: datagroups.hpp:36
ERROR HANDLING CLASSES AND ROUTINES.
Karp partitions of TSP instances.
Information about the active tour in a CoreLP.
Definition: active_tour.hpp:30
Utility functions, macros, and structures.
Preferences related to tour file output and verbosity.
Definition: util.hpp:25
A class for recording CPU and wall clock time.
Definition: timer.hpp:10
Presets
Preset selection routine choices. Each contains the one before it.
Definition: solver.hpp:79
Solution of TSP instances.
Definition: solver.hpp:37
EdgePlan
Edge generation protocol to use.
Definition: datagroups.hpp:94
The namespace for this project.
Definition: abc_nodesel.hpp:20
PivStats(double first_piv)
Construct PivStats from the first pivot before adding cuts.
Definition: solver.hpp:172
#define CMR_CATCH_PRINT_THROW(msg, new_ex)
Macro for handling errors in function with multiple failure points.
Definition: err_util.hpp:25
Class for storing the core lp associated to a TSP instance and pivoting.
Definition: core_lp.hpp:33
Class for computing and storing Karp partitions.
Definition: karp.hpp:30
Definition: branch_node.hpp:25
The default initializations indicated below.
Definition: solver.hpp:80
Managing Core LP relaxations of TSP instances.
Add cut metamorphoses/local cuts.
Definition: solver.hpp:81