PGROUTING  2.5
pgrouting::vrp::Order Class Reference

#include "order.h"

Inheritance diagram for pgrouting::vrp::Order:
Collaboration diagram for pgrouting::vrp::Order:

Public Member Functions

int64_t id () const
 
size_t idx () const
 
void reset_id (int64_t)
 
Constructors
 Order (size_t p_id, int64_t p_idx, const Vehicle_node &p_pickup, const Vehicle_node &p_deliver)
 
 Order (const Order &)=default
 
Accessors
const Vehicle_nodedelivery () const
 The delivery node identifier. More...
 
const Vehicle_nodepickup () const
 The delivery node identifier. More...
 
Identifiers< size_t > subsetJ (const Identifiers< size_t > &J) const
 Get a subset of the orders that can be placed after this order. More...
 
Identifiers< size_t > subsetI (const Identifiers< size_t > &I) const
 
Modifiers
void set_compatibles (const Order order, double speed)
 
To be or not to be
bool is_valid (double speed) const
 validate a pickup/delivery order More...
 
bool isCompatibleIJ (const Order &I, double speed) const
 Can order I be placed before this order? More...
 

Private Attributes

Identifiers< size_t > m_compatibleI
 Stores all the orders that can be placed before this order. More...
 
Identifiers< size_t > m_compatibleJ
 Stores all the orders that can be placed after this order. More...
 
Vehicle_node m_delivery
 The delivery node identifier. More...
 
Vehicle_node m_pickup
 The pick up node identifier. More...
 

Friends

Friends
std::ostream & operator<< (std::ostream &, const Order &)
 

Detailed Description

Definition at line 42 of file order.h.

Constructor & Destructor Documentation

pgrouting::vrp::Order::Order ( size_t  p_id,
int64_t  p_idx,
const Vehicle_node p_pickup,
const Vehicle_node p_deliver 
)

Definition at line 45 of file order.cpp.

48  :
49  Identifier(p_idx, p_id),
50  m_pickup(p_pickup),
51  m_delivery(p_delivery) {
52  }
Vehicle_node m_delivery
The delivery node identifier.
Definition: order.h:151
Vehicle_node m_pickup
The pick up node identifier.
Definition: order.h:145
pgrouting::vrp::Order::Order ( const Order )
default

Member Function Documentation

const Vehicle_node & pgrouting::vrp::Order::delivery ( ) const

The delivery node identifier.

It hold's the idx of the node

Definition at line 82 of file order.cpp.

References m_delivery.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::erase(), pgrouting::vrp::Vehicle_pickDeliver::insert(), is_valid(), isCompatibleIJ(), pgrouting::vrp::operator<<(), pgrouting::vrp::Vehicle_pickDeliver::push_back(), and pgrouting::vrp::Vehicle_pickDeliver::push_front().

82  {
83  return m_delivery;
84 }
Vehicle_node m_delivery
The delivery node identifier.
Definition: order.h:151

Here is the caller graph for this function:

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

validate a pickup/delivery order

An order is valid when:

  • The pickup is well formed
  • The delivery is well formed
  • isCompatibleIJ to go to delivery after inmediatly visiting pickup

Definition at line 94 of file order.cpp.

References delivery(), pgrouting::vrp::Tw_node::is_compatible_IJ(), pgrouting::vrp::Tw_node::is_delivery(), pgrouting::vrp::Tw_node::is_pickup(), and pickup().

Referenced by pgrouting::vrp::Fleet::is_order_ok().

94  {
95  return
96  pickup().is_pickup()
97  && delivery().is_delivery()
98  /* IS P -> D */
99  && delivery().is_compatible_IJ(pickup(), speed);
100 }
const Vehicle_node & pickup() const
The delivery node identifier.
Definition: order.cpp:88
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
bool is_pickup() const
is_pickup
Definition: tw_node.cpp:142
bool is_delivery() const
is_delivery
Definition: tw_node.cpp:152
const Vehicle_node & delivery() const
The delivery node identifier.
Definition: order.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Order::isCompatibleIJ ( const Order I,
double  speed 
) const

Can order I be placed before this order?

dot_inline_dotgraph_8.png
Parameters
[in]Iorder
[in]speedto be used for evaluating the order
Returns
true when order I can be placed before this order

Definition at line 135 of file order.cpp.

References delivery(), pgrouting::vrp::Tw_node::is_compatible_IJ(), and pickup().

Referenced by set_compatibles().

135  {
136  /* this is true in all cases */
137  auto all_cases(
138  pickup().is_compatible_IJ(I.pickup(), speed)
139  && delivery().is_compatible_IJ(I.pickup(), speed));
140 
141  /* case other(P) other(D) this(P) this(D) */
142  auto case1(pickup().is_compatible_IJ(I.delivery(), speed)
143  && delivery().is_compatible_IJ(I.delivery(), speed));
144 
145  /* case other(P) this(P) other(D) this(D) */
146  auto case2(I.delivery().is_compatible_IJ(pickup(), speed)
147  && delivery().is_compatible_IJ(I.delivery(), speed));
148 
149  /* case other(P) this(P) this(D) other(D) */
150  auto case3(I.delivery().is_compatible_IJ(pickup(), speed)
151  && I.delivery().is_compatible_IJ(delivery(), speed));
152 
153  return all_cases && (case1 || case2 || case3);
154 }
const Vehicle_node & pickup() const
The delivery node identifier.
Definition: order.cpp:88
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
const Vehicle_node & delivery() const
The delivery node identifier.
Definition: order.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

const Vehicle_node & pgrouting::vrp::Order::pickup ( ) const

The delivery node identifier.

It hold's the idx of the node

Definition at line 88 of file order.cpp.

References m_pickup.

Referenced by pgrouting::vrp::Vehicle_pickDeliver::erase(), pgrouting::vrp::Vehicle_pickDeliver::insert(), is_valid(), isCompatibleIJ(), pgrouting::vrp::operator<<(), pgrouting::vrp::Vehicle_pickDeliver::push_back(), and pgrouting::vrp::Vehicle_pickDeliver::push_front().

88  {
89  return m_pickup;
90 }
Vehicle_node m_pickup
The pick up node identifier.
Definition: order.h:145

Here is the caller graph for this function:

void pgrouting::Identifier::reset_id ( int64_t  _id)
inherited

Definition at line 47 of file identifier.cpp.

References pgrouting::Identifier::m_id.

Referenced by pgrouting::vrp::Tw_node::Tw_node().

47  {
48  m_id = _id;
49 }

Here is the caller graph for this function:

void pgrouting::vrp::Order::set_compatibles ( const Order  order,
double  speed 
)

Definition at line 111 of file order.cpp.

References pgrouting::Identifier::idx(), isCompatibleIJ(), m_compatibleI, and m_compatibleJ.

111  {
112  if (J.idx() == idx()) return;
113  if (J.isCompatibleIJ(*this, speed)) {
114  /*
115  * this -> {J}
116  */
117  m_compatibleJ += J.idx();
118  }
119  if (this->isCompatibleIJ(J, speed)) {
120  /*
121  * {J} -> this
122  */
123  m_compatibleI += J.idx();
124  }
125 }
bool isCompatibleIJ(const Order &I, double speed) const
Can order I be placed before this order?
Definition: order.cpp:135
Identifiers< size_t > m_compatibleI
Stores all the orders that can be placed before this order.
Definition: order.h:182
Identifiers< size_t > m_compatibleJ
Stores all the orders that can be placed after this order.
Definition: order.h:168
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

Identifiers< size_t > pgrouting::vrp::Order::subsetI ( const Identifiers< size_t > &  I) const

Definition at line 35 of file order.cpp.

References m_compatibleI.

35  {
36  return m_compatibleI * I;
37 }
Identifiers< size_t > m_compatibleI
Stores all the orders that can be placed before this order.
Definition: order.h:182
Identifiers< size_t > pgrouting::vrp::Order::subsetJ ( const Identifiers< size_t > &  J) const

Get a subset of the orders that can be placed after this order.

dot_inline_dotgraph_9.png
Parameters
[in]Jset of orders
Returns
ithe set intersection of the J orders with the compatible_J orders of this order

Definition at line 40 of file order.cpp.

References m_compatibleJ.

40  {
41  return m_compatibleJ * J;
42 }
Identifiers< size_t > m_compatibleJ
Stores all the orders that can be placed after this order.
Definition: order.h:168

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  log,
const Order order 
)
friend

Definition at line 55 of file order.cpp.

55  {
56  log << "\n\nOrder "
57  << static_cast<Identifier>(order) << ": \n"
58  << "\tPickup: " << order.pickup() << "\n"
59  << "\tDelivery: " << order.delivery() << "\n\n"
60  << "\tTravel time: "
61  << order.pickup().travel_time_to(order.delivery(), 1);
62  log << "\nThere are | {I}| = "
63  << order.m_compatibleI.size()
64  << " -> order(" << order.idx()
65  << ") -> | {J}| = " << order.m_compatibleJ.size()
66  << "\n\n {";
67  for (const auto o : order.m_compatibleI) {
68  log << o << ", ";
69  }
70  log << "} -> " << order.idx() << " -> {";
71  for (const auto o : order.m_compatibleJ) {
72  log << o << ", ";
73  }
74  log << "}";
75 
76  return log;
77 }

Member Data Documentation

Identifiers<size_t> pgrouting::vrp::Order::m_compatibleI
private

Stores all the orders that can be placed before this order.

dot_inline_dotgraph_10.png

Definition at line 182 of file order.h.

Referenced by pgrouting::vrp::operator<<(), set_compatibles(), and subsetI().

Identifiers<size_t> pgrouting::vrp::Order::m_compatibleJ
private

Stores all the orders that can be placed after this order.

dot_inline_dotgraph_11.png
Todo:
TODO
  • compatibility changes based on the speed this is not taking that into account (here)
  • check where is it talking that into account

Definition at line 168 of file order.h.

Referenced by pgrouting::vrp::operator<<(), set_compatibles(), and subsetJ().

Vehicle_node pgrouting::vrp::Order::m_delivery
private

The delivery node identifier.

It hold's the idx of the node

Definition at line 151 of file order.h.

Referenced by delivery().

Vehicle_node pgrouting::vrp::Order::m_pickup
private

The pick up node identifier.

It hold's the idx of the node

Definition at line 145 of file order.h.

Referenced by pickup().


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