PGROUTING  3.2
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...
 
int64_t m_id
 
size_t m_idx
 
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

◆ Order() [1/2]

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  }

◆ Order() [2/2]

pgrouting::vrp::Order::Order ( const Order )
default

Member Function Documentation

◆ delivery()

◆ id()

◆ idx()

◆ is_valid()

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.

94  {
95  return
96  pickup().is_pickup()
97  && delivery().is_delivery()
98  /* IS P -> D */
99  && delivery().is_compatible_IJ(pickup(), speed);
100 }

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().

◆ isCompatibleIJ()

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

Can order I be placed before this order?

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

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 }

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

Referenced by set_compatibles().

◆ pickup()

◆ reset_id()

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

Definition at line 47 of file identifier.cpp.

47  {
48  m_id = _id;
49 }

References pgrouting::Identifier::m_id.

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

◆ set_compatibles()

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

Definition at line 111 of file order.cpp.

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 }

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

◆ subsetI()

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

Definition at line 35 of file order.cpp.

35  {
36  return m_compatibleI * I;
37 }

References m_compatibleI.

◆ subsetJ()

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

40  {
41  return m_compatibleJ * J;
42 }

References m_compatibleJ.

Friends And Related Function Documentation

◆ operator<<

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

◆ m_compatibleI

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

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

dot_inline_dotgraph_5.png

Definition at line 182 of file order.h.

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

◆ m_compatibleJ

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

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

dot_inline_dotgraph_6.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().

◆ m_delivery

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().

◆ m_id

int64_t pgrouting::Identifier::m_id
privateinherited

Definition at line 53 of file identifier.h.

Referenced by pgrouting::Identifier::id(), and pgrouting::Identifier::reset_id().

◆ m_idx

size_t pgrouting::Identifier::m_idx
privateinherited

Definition at line 52 of file identifier.h.

Referenced by pgrouting::Identifier::idx().

◆ m_pickup

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:
pgrouting::vrp::Order::m_delivery
Vehicle_node m_delivery
The delivery node identifier.
Definition: order.h:151
pgrouting::vrp::Order::m_compatibleI
Identifiers< size_t > m_compatibleI
Stores all the orders that can be placed before this order.
Definition: order.h:182
pgrouting::vrp::Tw_node::is_compatible_IJ
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:60
pgrouting::Identifier::idx
size_t idx() const
Definition: identifier.cpp:37
pgrouting::vrp::Tw_node::is_pickup
bool is_pickup() const
is_pickup
Definition: tw_node.cpp:97
pgrouting::vrp::Order::m_pickup
Vehicle_node m_pickup
The pick up node identifier.
Definition: order.h:145
pgrouting::vrp::Tw_node::is_delivery
bool is_delivery() const
is_delivery
Definition: tw_node.cpp:106
pgrouting::vrp::Order::pickup
const Vehicle_node & pickup() const
The delivery node identifier.
Definition: order.cpp:88
pgrouting::Identifier::m_idx
size_t m_idx
Definition: identifier.h:52
pgrouting::vrp::Order::delivery
const Vehicle_node & delivery() const
The delivery node identifier.
Definition: order.cpp:82
pgrouting::Identifier::m_id
int64_t m_id
Definition: identifier.h:53
pgrouting::Identifier::Identifier
Identifier()=default
pgrouting::vrp::Order::m_compatibleJ
Identifiers< size_t > m_compatibleJ
Stores all the orders that can be placed after this order.
Definition: order.h:168
pgrouting::vrp::Order::isCompatibleIJ
bool isCompatibleIJ(const Order &I, double speed) const
Can order I be placed before this order?
Definition: order.cpp:135