PGROUTING  2.6
pgrouting::vrp::PD_Orders Class Reference

#include "pd_orders.h"

Inheritance diagram for pgrouting::vrp::PD_Orders:
Collaboration diagram for pgrouting::vrp::PD_Orders:

Public Types

typedef Orders::const_iterator o_const_iterator
 
typedef Orders::iterator o_iterator
 

Public Member Functions

size_t find_best_I (Identifiers< size_t > &within_this_set) const
 
size_t find_best_J (Identifiers< size_t > &within_this_set) const
 
bool is_valid (double speed) const
 
void set_compatibles (double speed)
 
constructors
 PD_Orders ()=default
 
 PD_Orders (const PD_Orders &)=default
 
 PD_Orders (const std::vector< PickDeliveryOrders_t > &)
 
std container functions

functions with same "meaning" as an std container

Orderoperator[] (size_t o)
 
const Orderoperator[] (size_t o) const
 
size_t size () const
 
o_iterator begin ()
 
o_iterator end ()
 
o_const_iterator begin () const
 
o_const_iterator end () const
 

Static Public Attributes

static Pgr_messages msg
 

Static Protected Attributes

static Pgr_pickDeliverproblem
 

Private Types

typedef std::vector< OrderOrders
 

Private Member Functions

void add_order (const PickDeliveryOrders_t &, std::unique_ptr< Base_node >, const Vehicle_node &, std::unique_ptr< Base_node >, const Vehicle_node &)
 
void build_orders (const std::vector< PickDeliveryOrders_t > &pd_orders)
 
template<typename T >
std::unique_ptr< Base_nodecreate_b_deliver (const PickDeliveryOrders_t &order, size_t node_id)
 
template<typename T >
std::unique_ptr< Base_nodecreate_b_pick (const PickDeliveryOrders_t &order, size_t node_id)
 

Private Attributes

Orders m_orders
 

Detailed Description

Definition at line 49 of file pd_orders.h.

Member Typedef Documentation

typedef Orders::const_iterator pgrouting::vrp::PD_Orders::o_const_iterator

Definition at line 54 of file pd_orders.h.

typedef Orders::iterator pgrouting::vrp::PD_Orders::o_iterator

Definition at line 53 of file pd_orders.h.

typedef std::vector<Order> pgrouting::vrp::PD_Orders::Orders
private

Definition at line 50 of file pd_orders.h.

Constructor & Destructor Documentation

pgrouting::vrp::PD_Orders::PD_Orders ( )
default
pgrouting::vrp::PD_Orders::PD_Orders ( const PD_Orders )
default
pgrouting::vrp::PD_Orders::PD_Orders ( const std::vector< PickDeliveryOrders_t > &  pd_orders)
explicit

Definition at line 39 of file pd_orders.cpp.

References build_orders().

41  {
42  build_orders(pd_orders);
43 }
void build_orders(const std::vector< PickDeliveryOrders_t > &pd_orders)
Definition: pd_orders.cpp:69

Here is the call graph for this function:

Member Function Documentation

void pgrouting::vrp::PD_Orders::add_order ( const PickDeliveryOrders_t order,
std::unique_ptr< Base_node b_pick,
const Vehicle_node pick,
std::unique_ptr< Base_node b_drop,
const Vehicle_node drop 
)
private

Definition at line 47 of file pd_orders.cpp.

References pgrouting::vrp::Pgr_pickDeliver::add_base_node(), pgrouting::vrp::Pgr_pickDeliver::add_node(), PickDeliveryOrders_t::id, m_orders, and pgrouting::vrp::PD_problem::problem.

Referenced by build_orders(), and end().

52  {
53  problem->add_base_node(std::move(b_pick));
54  problem->add_base_node(std::move(b_drop));
55  problem->add_node(pick);
56  problem->add_node(drop);
57 
58  /*
59  * add into an order
60  */
61  m_orders.push_back(
62  Order(m_orders.size(), order.id,
63  pick,
64  drop));
65 }
void add_base_node(std::unique_ptr< Base_node > node_ptr)
void add_node(const Vehicle_node &node)
static Pgr_pickDeliver * problem
Definition: pd_problem.h:51

Here is the call graph for this function:

Here is the caller graph for this function:

o_iterator pgrouting::vrp::PD_Orders::begin ( )
inline

Definition at line 79 of file pd_orders.h.

References m_orders.

79 {return m_orders.begin();}
o_const_iterator pgrouting::vrp::PD_Orders::begin ( ) const
inline

Definition at line 81 of file pd_orders.h.

References m_orders.

81 {return m_orders.begin();}
void pgrouting::vrp::PD_Orders::build_orders ( const std::vector< PickDeliveryOrders_t > &  pd_orders)
private

Definition at line 69 of file pd_orders.cpp.

References add_order(), pgrouting::tsp::Dmatrix::empty(), ENTERING, EXITING, pgrouting::Pgr_messages::log, pgrouting::vrp::Pgr_pickDeliver::m_cost_matrix, pgrouting::vrp::PD_problem::msg, pgrouting::vrp::Pgr_pickDeliver::node_id(), and pgrouting::vrp::PD_problem::problem.

Referenced by end(), and PD_Orders().

71  {
72  ENTERING();
73  for (const auto order : pd_orders) {
74  /*
75  * SAMPLE CORRECT INFORMATION
76  *
77  * id | demand | pick_x | pick_y | pick_open_t | pick_close_t | pick_service_t | deliver_x | deliver_y | deliver_open_t | deliver_open_t | deliver_close_t | deliver_service_t
78  * 1 | 10 | 35 | 69 | 448 | 505 | 90 | 45 | 68 | 912 | 967 | 90 | 35
79  */
80 
81  if (problem->m_cost_matrix.empty()) {
82  /*
83  * Euclidean version
84  */
85  auto b_pick = create_b_pick<Node>(order, problem->node_id());
86  Vehicle_node pickup(
87  {problem->node_id()++, order, Tw_node::NodeType::kPickup});
88 
89  auto b_drop = create_b_deliver<Node>(order, problem->node_id());
90  Vehicle_node delivery({
91  problem->node_id()++,
92  order,
93  Tw_node::NodeType::kDelivery});
94 
95 
96  add_order(order,
97  std::move(b_pick), pickup,
98  std::move(b_drop), delivery);
99  } else {
100  /*
101  * matrix version
102  */
103  msg.log << "pickup \n"
104  << "pick_node_id: " << order.pick_node_id
105  << "\n";
106 
107  msg.log << "pickup \n"
108  << "deliver_node_id: " << order.deliver_node_id
109  << "\n";
110  auto b_pick = create_b_pick<Dnode>(order, problem->node_id());
111  Vehicle_node pickup(
112  {problem->node_id()++, order, Tw_node::NodeType::kPickup});
113 
114  auto b_drop = create_b_deliver<Dnode>(order, problem->node_id());
115  Vehicle_node delivery({
116  problem->node_id()++,
117  order,
118  Tw_node::NodeType::kDelivery});
119 
120  add_order(order,
121  std::move(b_pick), pickup,
122  std::move(b_drop), delivery);
123  }
124  } // for (creating orders)
125 
126  EXITING();
127 }
static Pgr_pickDeliver * problem
Definition: pd_problem.h:51
std::ostringstream log
Stores the hint information.
Definition: pgr_messages.h:102
#define EXITING()
Definition: pgr_messages.h:119
#define ENTERING()
Definition: pgr_messages.h:118
pgrouting::tsp::Dmatrix m_cost_matrix
double empty() const
Definition: Dmatrix.h:116
static Pgr_messages msg
Definition: pd_problem.h:48
void add_order(const PickDeliveryOrders_t &, std::unique_ptr< Base_node >, const Vehicle_node &, std::unique_ptr< Base_node >, const Vehicle_node &)
Definition: pd_orders.cpp:47

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
std::unique_ptr<Base_node> pgrouting::vrp::PD_Orders::create_b_deliver ( const PickDeliveryOrders_t order,
size_t  node_id 
)
inlineprivate

Definition at line 107 of file pd_orders.h.

References PickDeliveryOrders_t::deliver_node_id, PickDeliveryOrders_t::deliver_x, and PickDeliveryOrders_t::deliver_y.

109  {
110  std::unique_ptr<Base_node> b_drop(new T(
111  node_id,
112  order.deliver_node_id,
113  order.deliver_x,
114  order.deliver_y));
115  return std::move(b_drop);
116  }
template<typename T >
std::unique_ptr<Base_node> pgrouting::vrp::PD_Orders::create_b_pick ( const PickDeliveryOrders_t order,
size_t  node_id 
)
inlineprivate

Definition at line 96 of file pd_orders.h.

References PickDeliveryOrders_t::pick_node_id, PickDeliveryOrders_t::pick_x, and PickDeliveryOrders_t::pick_y.

98  {
99  std::unique_ptr<Base_node> b_pick(new T(
100  node_id,
101  order.pick_node_id,
102  order.pick_x,
103  order.pick_y));
104  return std::move(b_pick);
105  }
o_iterator pgrouting::vrp::PD_Orders::end ( )
inline

Definition at line 80 of file pd_orders.h.

References m_orders.

80 {return m_orders.end();}
o_const_iterator pgrouting::vrp::PD_Orders::end ( ) const
inline

Definition at line 82 of file pd_orders.h.

References add_order(), build_orders(), and m_orders.

82 {return m_orders.end();}

Here is the call graph for this function:

size_t pgrouting::vrp::PD_Orders::find_best_I ( Identifiers< size_t > &  within_this_set) const

Definition at line 184 of file pd_orders.cpp.

References Identifiers< T >::empty(), Identifiers< T >::front(), m_orders, and pgassert.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::do_while_feasable().

185  {
186  pgassert(!within_this_set.empty());
187  auto best_order = within_this_set.front();
188  size_t max_size = 0;
189 
190 
191  for (auto o : within_this_set) {
192  auto size_I = m_orders[o].subsetI(within_this_set).size();
193  if (max_size < size_I) {
194  max_size = size_I;
195  best_order = o;
196  }
197  }
198  return best_order;
199 }
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
T front() const
Definition: identifiers.hpp:79
bool empty() const
Definition: identifiers.hpp:78

Here is the call graph for this function:

Here is the caller graph for this function:

size_t pgrouting::vrp::PD_Orders::find_best_J ( Identifiers< size_t > &  within_this_set) const

Definition at line 165 of file pd_orders.cpp.

References Identifiers< T >::empty(), Identifiers< T >::front(), m_orders, and pgassert.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::do_while_feasable().

166  {
167  pgassert(!within_this_set.empty());
168  auto best_order = within_this_set.front();
169  size_t max_size = 0;
170 
171 
172  for (auto o : within_this_set) {
173  auto size_J = m_orders[o].subsetJ(within_this_set).size();
174  if (max_size < size_J) {
175  max_size = size_J;
176  best_order = o;
177  }
178  }
179  return best_order;
180 }
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
T front() const
Definition: identifiers.hpp:79
bool empty() const
Definition: identifiers.hpp:78

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::PD_Orders::is_valid ( double  speed) const

Definition at line 130 of file pd_orders.cpp.

References m_orders, and pgassert.

130  {
131  for (const auto &o : m_orders) {
132  if (!o.is_valid(speed)) {
133  return false;
134  }
135  pgassert(o.pickup().is_pickup());
136  pgassert(o.delivery().is_delivery());
137  /* P -> D */
138  pgassert(o.delivery().is_compatible_IJ(o.pickup(), speed));
139  }
140  return true;
141 }
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
Order & pgrouting::vrp::PD_Orders::operator[] ( size_t  o)

Definition at line 144 of file pd_orders.cpp.

References m_orders, and pgassert.

144  {
145  pgassert(i < m_orders.size());
146  return m_orders[i];
147 }
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
const Order & pgrouting::vrp::PD_Orders::operator[] ( size_t  o) const

Definition at line 150 of file pd_orders.cpp.

References m_orders, and pgassert.

150  {
151  pgassert(i < m_orders.size());
152  return m_orders[i];
153 }
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
void pgrouting::vrp::PD_Orders::set_compatibles ( double  speed)

Definition at line 156 of file pd_orders.cpp.

References m_orders.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::set_compatibles().

156  {
157  for (auto &I : m_orders) {
158  for (const auto J : m_orders) {
159  I.set_compatibles(J, speed);
160  }
161  }
162 }

Here is the caller graph for this function:

size_t pgrouting::vrp::PD_Orders::size ( ) const
inline

Definition at line 78 of file pd_orders.h.

References m_orders.

Referenced by pgrouting::vrp::Pgr_pickDeliver::solve().

78 {return m_orders.size();}

Here is the caller graph for this function:

Member Data Documentation

Orders pgrouting::vrp::PD_Orders::m_orders
private

The documentation for this class was generated from the following files: