Camargue
branch_node.hpp
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9 
10 #ifndef CMR_BRANCH_NODE_H
11 #define CMR_BRANCH_NODE_H
12 
13 #include "lp_util.hpp"
14 #include "util.hpp"
15 
16 #include <array>
17 #include <iostream>
18 #include <list>
19 #include <utility>
20 
21 
22 namespace CMR {
23 namespace ABC {
24 
25 struct BranchNode {
26  enum Dir : int {
27  Down = 0,
28  Up = 1
29  };
30 
31  enum class Status {
32  NeedsCut,
33  NeedsBranch,
34  NeedsPrice,
35  NeedsRecover,
36  Pruned,
37  Done,
38  };
39 
40  BranchNode();
41 
43  BranchNode(EndPts ends_, Dir direction_, const BranchNode &parent_,
44  double tourlen_, double estimate_);
45 
46  BranchNode(BranchNode &&B) noexcept;
47  BranchNode &operator=(BranchNode &&B) noexcept;
48 
50  using Split = std::array<BranchNode, 2>;
51 
53  Dir direction;
54 
55  Status stat;
56 
57  const BranchNode *parent;
58  int depth;
59 
60  double tourlen;
61 
63  LP::Basis::Ptr price_basis;
64  double estimate;
65 
67  bool is_root() const { return parent == nullptr; }
68 
70  bool visited() const
71  { return stat == Status::Pruned || stat == Status::Done; }
72 
90 
93  static bool tour_worse(const std::list<BranchNode>::iterator &A,
94  const std::list<BranchNode>::iterator &B);
95 
97  static bool bound_worse(const std::list<BranchNode>::iterator &A,
98  const std::list<BranchNode>::iterator &B);
99 
100  using Pref = decltype(&tour_worse);
101 
103 };
104 
106 BranchNode::Dir dir_from_int(int entry);
107 
109 std::string bnode_brief(const BranchNode &B);
110 
111 std::ostream &operator<<(std::ostream &os, const BranchNode::Dir &dir);
112 std::ostream &operator<<(std::ostream &os, const BranchNode &B);
113 
114 using BranchHistory = std::list<BranchNode>;
115 
117 using EndsDir = std::pair<EndPts, BranchNode::Dir>;
118 
119 
120 
121 
122 }
123 }
124 
125 #endif
int depth
Search tree depth of this node.
Definition: branch_node.hpp:58
Miscellaneous functions, structs/enums, and constants for LPs.
Status stat
The type of processing required by the node.
Definition: branch_node.hpp:55
static bool tour_worse(const std::list< BranchNode >::iterator &A, const std::list< BranchNode >::iterator &B)
Returns true if A has a worse tour than B.
Definition: branch_node.cpp:92
BranchNode()
Construct a root node.
Definition: branch_node.cpp:24
LP::Basis::Ptr price_basis
A starting basis for if Status is NeedsPrice or NeedsRecover.
Definition: branch_node.hpp:63
bool is_root() const
Is this the root problem.
Definition: branch_node.hpp:67
EndPts ends
The endpoints of the branch edge.
Definition: branch_node.hpp:52
Utility functions, macros, and structures.
BranchNode::Dir dir_from_int(int entry)
Turn a 0-1 value entry into a BranchNode::Dir.
Definition: branch_node.cpp:113
Dir direction
Down branch or up branch.
Definition: branch_node.hpp:53
std::array< BranchNode, 2 > Split
Alias declaration for returning two split child problems.
Definition: branch_node.hpp:50
The namespace for this project.
Definition: abc_nodesel.hpp:20
static bool bound_worse(const std::list< BranchNode >::iterator &A, const std::list< BranchNode >::iterator &B)
Returns true if A has a worse (higher) SB estimate than B.
Definition: branch_node.cpp:106
bool visited() const
Has the problem been processed.
Definition: branch_node.hpp:70
std::string bnode_brief(const BranchNode &B)
A concise "label" for the BranchNode B.
Definition: branch_node.cpp:125
Definition: branch_node.hpp:25
Simple base class for storing edge of a graph as a sorted pair of nodes.
Definition: util.hpp:239
double estimate
The objective value estimate from edge selection.
Definition: branch_node.hpp:64
std::pair< EndPts, BranchNode::Dir > EndsDir
Alias declaration for EndPts and branching direction.
Definition: branch_node.hpp:117
double tourlen
Estimated best tour length for this node.
Definition: branch_node.hpp:60