PGROUTING  3.2
pgrouting::vrp::PD_Orders Class Reference

#include "pd_orders.h"

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
 
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
 

Private Types

typedef std::vector< OrderOrders
 

Private Member Functions

void add_order (const PickDeliveryOrders_t &, const Vehicle_node &, const Vehicle_node &)
 
void build_orders (const std::vector< PickDeliveryOrders_t > &pd_orders)
 
Pgr_messagesmsg () const
 Access to the problem's message. More...
 

Private Attributes

Orders m_orders
 

Static Private Attributes

static Pgr_pickDeliverproblem
 The problem. More...
 

Friends

class PD_problem
 PD_rpblem needs access to set up the problem pointer. More...
 

Detailed Description

Definition at line 48 of file pd_orders.h.

Member Typedef Documentation

◆ o_const_iterator

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

Definition at line 56 of file pd_orders.h.

◆ o_iterator

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

Definition at line 55 of file pd_orders.h.

◆ Orders

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

Definition at line 52 of file pd_orders.h.

Constructor & Destructor Documentation

◆ PD_Orders() [1/3]

pgrouting::vrp::PD_Orders::PD_Orders ( )
default

◆ PD_Orders() [2/3]

pgrouting::vrp::PD_Orders::PD_Orders ( const PD_Orders )
default

◆ PD_Orders() [3/3]

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

Definition at line 40 of file pd_orders.cpp.

42  {
43  build_orders(pd_orders);
44 }

References build_orders().

Member Function Documentation

◆ add_order()

void pgrouting::vrp::PD_Orders::add_order ( const PickDeliveryOrders_t order,
const Vehicle_node pick,
const Vehicle_node drop 
)
private

Definition at line 48 of file pd_orders.cpp.

51  {
52 
53  /*
54  * add into an order
55  */
56  m_orders.push_back(
57  Order(m_orders.size(), order.id,
58  pick,
59  drop));
60 }

References PickDeliveryOrders_t::id, and m_orders.

Referenced by build_orders().

◆ begin() [1/2]

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

Definition at line 80 of file pd_orders.h.

80 {return m_orders.begin();}

References m_orders.

◆ begin() [2/2]

o_const_iterator pgrouting::vrp::PD_Orders::begin ( ) const
inline

Definition at line 82 of file pd_orders.h.

82 {return m_orders.begin();}

References m_orders.

◆ build_orders()

void pgrouting::vrp::PD_Orders::build_orders ( const std::vector< PickDeliveryOrders_t > &  pd_orders)
private

Definition at line 64 of file pd_orders.cpp.

66  {
67 #if 0
68  ENTERING();
69 #endif
70  for (const auto &order : pd_orders) {
71  /*
72  * SAMPLE CORRECT INFORMATION
73  *
74  * 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
75  * 1 | 10 | 35 | 69 | 448 | 505 | 90 | 45 | 68 | 912 | 967 | 90 | 35
76  */
77 
78  /*
79  * matrix version
80  */
81 
82  if (!problem->get_cost_matrix().has_id(order.pick_node_id)) {
83  throw std::make_pair(std::string("Unable to find node on matrix"), order.pick_node_id);
84  }
85  if (!problem->get_cost_matrix().has_id(order.deliver_node_id)) {
86  throw std::make_pair(std::string("Unable to find node on matrix"), order.deliver_node_id);
87  }
88 
89  Vehicle_node pickup({problem->get_nodes().size(), order, Tw_node::NodeType::kPickup});
90  problem->add_node(pickup);
91  Vehicle_node delivery({problem->get_nodes().size(), order, Tw_node::NodeType::kDelivery});
92  problem->add_node(delivery);
93 
94  add_order(order, pickup, delivery);
95  } // for (creating orders)
96 
97 #if 0
98  EXITING();
99 #endif
100 }

References pgrouting::vrp::Pgr_pickDeliver::add_node(), add_order(), ENTERING, EXITING, pgrouting::vrp::Pgr_pickDeliver::get_cost_matrix(), pgrouting::vrp::Pgr_pickDeliver::get_nodes(), pgrouting::tsp::Dmatrix::has_id(), problem, and size().

Referenced by PD_Orders().

◆ end() [1/2]

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

Definition at line 81 of file pd_orders.h.

81 {return m_orders.end();}

References m_orders.

◆ end() [2/2]

o_const_iterator pgrouting::vrp::PD_Orders::end ( ) const
inline

Definition at line 83 of file pd_orders.h.

83 {return m_orders.end();}

References m_orders.

◆ find_best_I()

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

Definition at line 144 of file pd_orders.cpp.

145  {
146  pgassert(!within_this_set.empty());
147  auto best_order = within_this_set.front();
148  size_t max_size = 0;
149 
150 
151  for (auto o : within_this_set) {
152  auto size_I = m_orders[o].subsetI(within_this_set).size();
153  if (max_size < size_I) {
154  max_size = size_I;
155  best_order = o;
156  }
157  }
158  return best_order;
159 }

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

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

◆ find_best_J()

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

Definition at line 125 of file pd_orders.cpp.

126  {
127  pgassert(!within_this_set.empty());
128  auto best_order = within_this_set.front();
129  size_t max_size = 0;
130 
131 
132  for (auto o : within_this_set) {
133  auto size_J = m_orders[o].subsetJ(within_this_set).size();
134  if (max_size < size_J) {
135  max_size = size_J;
136  best_order = o;
137  }
138  }
139  return best_order;
140 }

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

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

◆ msg()

Pgr_messages& pgrouting::vrp::PD_Orders::msg ( ) const
private

Access to the problem's message.

◆ operator[]() [1/2]

Order & pgrouting::vrp::PD_Orders::operator[] ( size_t  o)

Definition at line 104 of file pd_orders.cpp.

104  {
105  pgassert(i < m_orders.size());
106  return m_orders[i];
107 }

References m_orders, and pgassert.

◆ operator[]() [2/2]

const Order & pgrouting::vrp::PD_Orders::operator[] ( size_t  o) const

Definition at line 110 of file pd_orders.cpp.

110  {
111  pgassert(i < m_orders.size());
112  return m_orders[i];
113 }

References m_orders, and pgassert.

◆ set_compatibles()

void pgrouting::vrp::PD_Orders::set_compatibles ( double  speed)

Definition at line 116 of file pd_orders.cpp.

116  {
117  for (auto &I : m_orders) {
118  for (const auto &J : m_orders) {
119  I.set_compatibles(J, speed);
120  }
121  }
122 }

References m_orders.

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

◆ size()

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

Definition at line 79 of file pd_orders.h.

79 {return m_orders.size();}

References m_orders.

Referenced by build_orders(), and pgrouting::vrp::Pgr_pickDeliver::solve().

Friends And Related Function Documentation

◆ PD_problem

friend class PD_problem
friend

PD_rpblem needs access to set up the problem pointer.

Definition at line 50 of file pd_orders.h.

Member Data Documentation

◆ m_orders

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

Definition at line 97 of file pd_orders.h.

Referenced by add_order(), begin(), end(), find_best_I(), find_best_J(), operator[](), set_compatibles(), and size().

◆ problem

Pgr_pickDeliver * pgrouting::vrp::PD_Orders::problem
staticprivate

The problem.

Definition at line 103 of file pd_orders.h.

Referenced by build_orders(), and pgrouting::vrp::PD_problem::PD_problem().


The documentation for this class was generated from the following files:
pgrouting::vrp::PD_Orders::m_orders
Orders m_orders
Definition: pd_orders.h:97
pgrouting::vrp::PD_Orders::size
size_t size() const
Definition: pd_orders.h:79
EXITING
#define EXITING(x)
Definition: pgr_messages.h:94
ENTERING
#define ENTERING(x)
Definition: pgr_messages.h:93
PickDeliveryOrders_t::id
int64_t id
Definition: pickDeliveryOrders_t.h:46
pgrouting::vrp::Pgr_pickDeliver::get_nodes
std::vector< Vehicle_node > get_nodes() const
Definition: pgr_pickDeliver.h:88
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
pgrouting::tsp::Dmatrix::has_id
bool has_id(int64_t id) const
original id -> true
Definition: Dmatrix.cpp:79
pgrouting::vrp::Pgr_pickDeliver::get_cost_matrix
pgrouting::tsp::Dmatrix get_cost_matrix() const
Definition: pgr_pickDeliver.h:92
pgrouting::vrp::PD_Orders::build_orders
void build_orders(const std::vector< PickDeliveryOrders_t > &pd_orders)
Definition: pd_orders.cpp:64
Identifiers::empty
bool empty() const
Definition: identifiers.hpp:79
pgrouting::vrp::PD_Orders::problem
static Pgr_pickDeliver * problem
The problem.
Definition: pd_orders.h:103
Identifiers::front
T front() const
Definition: identifiers.hpp:80
pgrouting::vrp::PD_Orders::add_order
void add_order(const PickDeliveryOrders_t &, const Vehicle_node &, const Vehicle_node &)
Definition: pd_orders.cpp:48
pgrouting::vrp::Pgr_pickDeliver::add_node
void add_node(const Vehicle_node &node)
Definition: pgr_pickDeliver.cpp:128