PGROUTING  2.6
pgrouting::vrp::Vehicle_node Class Reference

Extend Tw_node to evaluate the vehicle at node level. More...

#include "vehicle_node.h"

Inheritance diagram for pgrouting::vrp::Vehicle_node:
Collaboration diagram for pgrouting::vrp::Vehicle_node:

Public Types

enum  NodeType {
  kStart = 0, kPickup, kDelivery, kDump,
  kLoad, kEnd
}
 

Public Member Functions

 Vehicle_node ()
 Construct from parameters. More...
 
 Vehicle_node (const Vehicle_node &)=default
 
 Vehicle_node (const Tw_node &node)
 Creates a disconected vehicle node. More...
 
bool deltaGeneratesTWV (double delta_time) const
 True when arrival_time + delta_time generates TWV. More...
 
int64_t id () const
 
size_t idx () const
 
void reset_id (int64_t)
 
Node evaluation accessors
double travel_time () const
 @ { More...
 
double arrival_time () const
 Truck's arrival_time to this node. More...
 
double wait_time () const
 Truck's wait_time at this node. More...
 
double departure_time () const
 Truck's departure_time from this node. More...
 
double delta_time () const
 delta_time = departure_time(this) - departure_time(previous) More...
 
Accumulated evaluation accessors
int twvTot () const
 @ { More...
 
int cvTot () const
 Truck's total times it has violated cargo limits. More...
 
double cargo () const
 Truck's total cargo after the node was served. More...
 
double total_time () const
 Truck's travel duration up to this node. More...
 
double total_travel_time () const
 _time spent moving between nodes by the truck More...
 
double total_wait_time () const
 _time spent by the truck waiting for nodes to open More...
 
double total_service_time () const
 _time spent by the truck servicing the nodes More...
 
State
bool feasible () const
 @ { More...
 
bool feasible (double cargoLimit) const
 True doesn't have twc nor cv (including total counts) More...
 
bool has_twv () const
 True when at this node does not violate time windows. More...
 
bool has_cv (double cargoLimit) const
 True when not violation. More...
 
mutators
void evaluate (double cargoLimit)
 @ { More...
 
void evaluate (const Vehicle_node &pred, double cargoLimit, double speed)
 
Document
double arrival_i_arrives_j (const Vehicle_node &other, double speed) const
 @ { More...
 
accessors
int64_t order () const
 @ { More...
 
double opens () const
 Returns the opening time. More...
 
double closes () const
 Returns the closing time. More...
 
double demand () const
 Returns the demand associated with this node. More...
 
void demand (double value)
 
double service_time () const
 Returns the service time for this node. More...
 
NodeType type () const
 Returns the type of this node. More...
 
double window_length () const
 Returns the length of time between the opening and closing. More...
 
double travel_time_to (const Tw_node &other, double speed) const
 time = distance / speed. More...
 
kind of node

A true value when;

  • 0 < opens < closes
  • the type is the requested type
  • the demand are valid for the requested type
bool is_start () const
 @ { More...
 
bool is_pickup () const
 is_pickup More...
 
bool is_delivery () const
 is_delivery More...
 
bool is_dump () const
 is_dump More...
 
bool is_load () const
 is_Load More...
 
bool is_end () const
 is_end More...
 
std::string type_str () const
 
to be or not to be
bool operator== (const Tw_node &rhs) const
 
bool is_early_arrival (double arrival_time) const
 True when arrivalTime is before it opens. More...
 
bool is_late_arrival (double arrival_time) const
 True when arrivalTime is after it closes. More...
 
bool is_on_time (double arrival_time) const
 True when arrivalTime in the time window. More...
 
document functions
double arrival_j_opens_i (const Tw_node &I, double speed) const
 @ { More...
 
double arrival_j_closes_i (const Tw_node &I, double speed) const
 The actual arrival time at this node, given that: this node is visited directly after other node and that the actual arrival time at other node was closes(other) More...
 
bool is_compatible_IJ (const Tw_node &I, double speed) const
 
bool is_partially_compatible_IJ (const Tw_node &I, double speed) const
 
bool is_tight_compatible_IJ (const Tw_node &I, double speed) const
 
bool is_partially_waitTime_compatible_IJ (const Tw_node &I, double speed) const
 
bool is_waitTime_compatible_IJ (const Tw_node &I, double speed) const
 

Static Public Attributes

static Pgr_messages msg
 

Protected Member Functions

bool is_valid () const
 

Static Protected Attributes

static Pgr_pickDeliverproblem
 

Private Attributes

Node evaluation members
double m_travel_time
 @ { More...
 
double m_arrival_time
 Arrival time at this node. More...
 
double m_wait_time
 Wait time at this node when early arrival. More...
 
double m_departure_time
 
double m_delta_time
 Departure time - last nodes departure time. More...
 
Accumulated evaluation members
double m_cargo
 @ { More...
 
int m_twvTot
 Total count of TWV. More...
 
int m_cvTot
 Total count of CV. More...
 
double m_tot_wait_time
 Accumulated wait time. More...
 
double m_tot_travel_time
 Accumulated travel time. More...
 
double m_tot_service_time
 

Friends

log
std::ostream & operator<< (std::ostream &log, const Vehicle_node &node)
 @ { More...
 

Detailed Description

Extend Tw_node to evaluate the vehicle at node level.

This class extends Twnode by adding attributes to store information about the node in a path and provides the tools evaluate the node and to set and get these attribute values.

Definition at line 48 of file vehicle_node.h.

Member Enumeration Documentation

Enumerator
kStart 

starting site

kPickup 

pickup site

kDelivery 

delivery site

kDump 

dump site, empties truck

kLoad 

load site, fills the truck

kEnd 

ending site

Definition at line 59 of file tw_node.h.

59  {
60  kStart = 0,
61  kPickup,
62  kDelivery,
63  kDump,
64  kLoad,
65  kEnd
66  } NodeType;
dump site, empties truck
Definition: tw_node.h:63
load site, fills the truck
Definition: tw_node.h:64

Constructor & Destructor Documentation

pgrouting::vrp::Vehicle_node::Vehicle_node ( )
inline

Construct from parameters.

Definition at line 158 of file vehicle_node.h.

158 : Tw_node() {}
pgrouting::vrp::Vehicle_node::Vehicle_node ( const Vehicle_node )
default
pgrouting::vrp::Vehicle_node::Vehicle_node ( const Tw_node node)
explicit

Creates a disconected vehicle node.

A node that is not served by any vehicle

Parameters
[in]nodeTime window node

Definition at line 122 of file vehicle_node.cpp.

123  : Tw_node(node),
124  m_travel_time(0),
125  m_arrival_time(0),
126  m_wait_time(0),
127  m_departure_time(0),
128  m_delta_time(0),
129  m_cargo(0),
130  m_twvTot(0),
131  m_cvTot(0),
132  m_tot_wait_time(0),
134  m_tot_service_time(0) {
135  }
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:180
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:181
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:170
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:178
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:168
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:179

Member Function Documentation

double pgrouting::vrp::Vehicle_node::arrival_i_arrives_j ( const Vehicle_node other,
double  speed 
) const

@ {

The actual arrival time at This node, given that: this node is visited directly after other node and that the actual arrival time at other node was arrival(other)

returns the arrval time at this visited after other

Definition at line 151 of file vehicle_node.cpp.

References arrival_time(), pgrouting::vrp::Tw_node::service_time(), and pgrouting::vrp::Tw_node::travel_time_to().

Referenced by has_cv().

153  {
154  return other.arrival_time()
155  + other.service_time()
156  + other.travel_time_to(*this, speed);
157 }

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Tw_node::arrival_j_closes_i ( const Tw_node I,
double  speed 
) const
inherited

The actual arrival time at this node, given that: this node is visited directly after other node and that the actual arrival time at other node was closes(other)

Definition at line 64 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::kStart, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::service_time(), and pgrouting::vrp::Tw_node::travel_time_to().

Referenced by pgrouting::vrp::Tw_node::is_on_time(), pgrouting::vrp::Tw_node::is_partially_compatible_IJ(), and pgrouting::vrp::Tw_node::is_tight_compatible_IJ().

64  {
65  if (m_type == kStart) return (std::numeric_limits<double>::max)();
66  return I.closes() + I.service_time() + I.travel_time_to(*this, speed);
67 }
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Tw_node::arrival_j_opens_i ( const Tw_node I,
double  speed 
) const
inherited

@ {

The actual arrival time at This node, given that: this node is visited directly after other node and that the actual arrival time at other node was opens(other)

Definition at line 58 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::kStart, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), pgrouting::vrp::Tw_node::service_time(), and pgrouting::vrp::Tw_node::travel_time_to().

Referenced by pgrouting::vrp::Tw_node::is_compatible_IJ(), pgrouting::vrp::Tw_node::is_on_time(), pgrouting::vrp::Tw_node::is_partially_compatible_IJ(), pgrouting::vrp::Tw_node::is_partially_waitTime_compatible_IJ(), pgrouting::vrp::Tw_node::is_tight_compatible_IJ(), and pgrouting::vrp::Tw_node::is_waitTime_compatible_IJ().

58  {
59  if (m_type == kStart) return (std::numeric_limits<double>::max)();
60  return I.opens() + I.service_time() + I.travel_time_to(*this, speed);
61 }
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::arrival_time ( ) const
inline

Truck's arrival_time to this node.

Definition at line 65 of file vehicle_node.h.

References m_arrival_time.

Referenced by arrival_i_arrives_j(), evaluate(), and pgrouting::vrp::operator<<().

65 {return m_arrival_time;}
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::cargo ( ) const
inline

Truck's total cargo after the node was served.

Definition at line 93 of file vehicle_node.h.

References m_cargo.

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

93 {return m_cargo;}

Here is the caller graph for this function:

int pgrouting::vrp::Vehicle_node::cvTot ( ) const
inline

Truck's total times it has violated cargo limits.

Definition at line 90 of file vehicle_node.h.

References m_cvTot.

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

90 {return m_cvTot;}
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:179

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::delta_time ( ) const
inline

delta_time = departure_time(this) - departure_time(previous)

Definition at line 74 of file vehicle_node.h.

References m_delta_time.

Referenced by total_service_time().

74 {return m_delta_time;}
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:170

Here is the caller graph for this function:

bool pgrouting::vrp::Vehicle_node::deltaGeneratesTWV ( double  delta_time) const

True when arrival_time + delta_time generates TWV.

Definition at line 140 of file vehicle_node.cpp.

References pgrouting::vrp::Tw_node::is_late_arrival(), and m_arrival_time.

Referenced by total_service_time().

140  {
142 }
double delta_time() const
delta_time = departure_time(this) - departure_time(previous)
Definition: vehicle_node.h:74
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:192

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Tw_node::demand ( ) const
inlineinherited

Returns the demand associated with this node.

Definition at line 82 of file tw_node.h.

References pgrouting::vrp::Tw_node::m_demand.

Referenced by evaluate(), pgrouting::vrp::Tw_node::is_delivery(), pgrouting::vrp::Tw_node::is_dump(), pgrouting::vrp::Tw_node::is_end(), pgrouting::vrp::Tw_node::is_load(), pgrouting::vrp::Tw_node::is_pickup(), and pgrouting::vrp::Tw_node::is_start().

82 {return m_demand;}
double m_demand
The demand for the Node.
Definition: tw_node.h:277

Here is the caller graph for this function:

void pgrouting::vrp::Tw_node::demand ( double  value)
inlineinherited

Definition at line 83 of file tw_node.h.

References pgrouting::vrp::Tw_node::m_demand.

83 {m_demand = value;}
double m_demand
The demand for the Node.
Definition: tw_node.h:277
double pgrouting::vrp::Vehicle_node::departure_time ( ) const
inline

Truck's departure_time from this node.

Definition at line 71 of file vehicle_node.h.

References m_departure_time.

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

Here is the caller graph for this function:

void pgrouting::vrp::Vehicle_node::evaluate ( double  cargoLimit)

@ {

Todo:
TODO evaluate with matrix also
Parameters
[in]cargoLimitof the vehicle

Definition at line 38 of file vehicle_node.cpp.

References arrival_time(), pgrouting::vrp::Tw_node::demand(), has_cv(), pgrouting::vrp::Tw_node::is_start(), m_arrival_time, m_cargo, m_cvTot, m_delta_time, m_departure_time, m_tot_service_time, m_tot_travel_time, m_tot_wait_time, m_travel_time, m_twvTot, m_wait_time, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by has_cv().

38  {
39  if (is_start()) {
40  /* time */
41  m_travel_time = 0;
43  m_wait_time = 0;
45 
46  /* time aggregates */
48  m_tot_wait_time = 0;
50 
51  /* cargo aggregates */
52  m_cargo = demand();
53 
54  /* violation aggregates */
55  m_twvTot = m_cvTot = 0;
56  m_cvTot = has_cv(cargoLimit) ? 1 : 0;
57  m_delta_time = 0;
58  }
59 }
bool has_cv(double cargoLimit) const
True when not violation.
Definition: vehicle_node.h:132
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:180
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:181
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:170
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double arrival_time() const
Truck&#39;s arrival_time to this node.
Definition: vehicle_node.h:65
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167
bool is_start() const
@ {
Definition: tw_node.cpp:132
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:178
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:168
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:179

Here is the call graph for this function:

Here is the caller graph for this function:

void pgrouting::vrp::Vehicle_node::evaluate ( const Vehicle_node pred,
double  cargoLimit,
double  speed 
)
Parameters
[in]predThe node preceding this node in the path.
[in]cargoLimitof the vehicle.
[in]speedof the vehicle.

Definition at line 68 of file vehicle_node.cpp.

References arrival_time(), cargo(), cvTot(), pgrouting::vrp::Tw_node::demand(), departure_time(), has_cv(), has_twv(), pgrouting::vrp::Tw_node::is_dump(), pgrouting::vrp::Tw_node::is_early_arrival(), m_arrival_time, m_cargo, m_cvTot, m_delta_time, m_departure_time, m_tot_service_time, m_tot_travel_time, m_tot_wait_time, m_travel_time, m_twvTot, m_wait_time, pgrouting::vrp::Tw_node::opens(), pgrouting::vrp::Tw_node::service_time(), total_service_time(), total_travel_time(), total_wait_time(), travel_time(), pgrouting::vrp::Tw_node::travel_time_to(), twvTot(), and wait_time().

71  {
72  /* time */
73  m_travel_time = pred.travel_time_to(*this, speed);
74  m_arrival_time = pred.departure_time() + travel_time();
76  opens() - m_arrival_time :
77  0;
79 
80  /* time aggregates */
81  m_tot_travel_time = pred.total_travel_time() + travel_time();
82  m_tot_wait_time = pred.total_wait_time() + wait_time();
83  m_tot_service_time = pred.total_service_time() + service_time();
84 
85  /* cargo aggregates */
86  if (is_dump() && pred.cargo() >= 0) {
87  demand(-pred.cargo());
88  }
89  m_cargo = pred.cargo() + demand();
90 
91  /* violations aggregates */
92 
93  m_twvTot = has_twv() ? pred.twvTot() + 1 : pred.twvTot();
94  m_cvTot = has_cv(cargoLimit) ? pred.cvTot() + 1 : pred.cvTot();
95  m_delta_time = departure_time() - pred.departure_time();
96 }
bool has_cv(double cargoLimit) const
True when not violation.
Definition: vehicle_node.h:132
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:180
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:187
bool has_twv() const
True when at this node does not violate time windows.
Definition: vehicle_node.h:124
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:181
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:170
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double arrival_time() const
Truck&#39;s arrival_time to this node.
Definition: vehicle_node.h:65
static size_t pred(size_t i, size_t n)
Definition: pgr_tsp.cpp:64
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167
double wait_time() const
Truck&#39;s wait_time at this node.
Definition: vehicle_node.h:68
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:178
double departure_time() const
Truck&#39;s departure_time from this node.
Definition: vehicle_node.h:71
bool is_dump() const
is_dump
Definition: tw_node.cpp:159
double travel_time() const
@ {
Definition: vehicle_node.h:62
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:168
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:179

Here is the call graph for this function:

bool pgrouting::vrp::Vehicle_node::feasible ( ) const
inline

@ {

True when the total count for violations are 0

Definition at line 116 of file vehicle_node.h.

References m_cvTot, and m_twvTot.

Referenced by feasible().

116 {return m_twvTot == 0 && m_cvTot == 0;}
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:178
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:179

Here is the caller graph for this function:

bool pgrouting::vrp::Vehicle_node::feasible ( double  cargoLimit) const
inline

True doesn't have twc nor cv (including total counts)

Definition at line 119 of file vehicle_node.h.

References feasible(), has_cv(), and has_twv().

119  {
120  return feasible() && !has_twv() && !has_cv(cargoLimit);
121  }
bool has_cv(double cargoLimit) const
True when not violation.
Definition: vehicle_node.h:132
bool has_twv() const
True when at this node does not violate time windows.
Definition: vehicle_node.h:124
bool feasible() const
@ {
Definition: vehicle_node.h:116

Here is the call graph for this function:

bool pgrouting::vrp::Vehicle_node::has_cv ( double  cargoLimit) const
inline

True when not violation.

Ending's or start's cargo should be 0

Definition at line 132 of file vehicle_node.h.

References arrival_i_arrives_j(), evaluate(), pgrouting::vrp::Tw_node::is_end(), pgrouting::vrp::Tw_node::is_start(), m_cargo, and pred().

Referenced by evaluate(), and feasible().

132  {
133  return is_end() || is_start() ? m_cargo != 0
134  : m_cargo > cargoLimit || m_cargo < 0;
135  }
bool is_end() const
is_end
Definition: tw_node.cpp:177
bool is_start() const
@ {
Definition: tw_node.cpp:132

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Vehicle_node::has_twv ( ) const
inline

True when at this node does not violate time windows.

Definition at line 124 of file vehicle_node.h.

References pgrouting::vrp::Tw_node::is_late_arrival(), and m_arrival_time.

Referenced by evaluate(), feasible(), and pgrouting::vrp::operator<<().

124  {
126  }
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:167
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:192

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_compatible_IJ ( const Tw_node I,
double  speed 
) const
inherited

Definition at line 73 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Tw_node::is_late_arrival(), pgrouting::vrp::Tw_node::kEnd, pgrouting::vrp::Tw_node::kStart, and pgrouting::vrp::Tw_node::m_type.

Referenced by pgrouting::vrp::Vehicle::getPosHighLimit(), pgrouting::vrp::Tw_node::is_on_time(), pgrouting::vrp::Tw_node::is_partially_compatible_IJ(), pgrouting::vrp::Tw_node::is_partially_waitTime_compatible_IJ(), pgrouting::vrp::Tw_node::is_tight_compatible_IJ(), pgrouting::vrp::Order::is_valid(), pgrouting::vrp::Tw_node::is_waitTime_compatible_IJ(), and pgrouting::vrp::Order::isCompatibleIJ().

73  {
74  /*
75  * I /-> kStart
76  */
77  if (m_type == kStart) return false;
78  /*
79  * kEnd /-> (*this)
80  */
81  if (I.m_type == kEnd) return false;
82 
83  return !is_late_arrival(arrival_j_opens_i(I, speed));
84 }
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:192
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_delivery ( ) const
inherited

is_delivery

To be a delivery node:

  • type is kDelivery
  • demand < 0

Definition at line 150 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kDelivery, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by pgrouting::vrp::Order::is_valid(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

150  {
151  return m_type == kDelivery
152  && (opens() < closes())
153  && (service_time() >= 0)
154  && (demand() < 0);
155 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_dump ( ) const
inherited

is_dump

To be a dump node:

  • type is kDump
  • demand <= 0

Definition at line 159 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kDump, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by evaluate(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

159  {
160  return m_type == kDump
161  && (opens() < closes())
162  && (service_time() >= 0)
163  && (demand() <= 0);
164 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
dump site, empties truck
Definition: tw_node.h:63
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_early_arrival ( double  arrival_time) const
inlineinherited
bool pgrouting::vrp::Tw_node::is_end ( ) const
inherited

is_end

To be a End node:

  • type is kEnd
  • demand == 0

Definition at line 177 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kEnd, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by pgrouting::vrp::Fleet::add_vehicle(), has_cv(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

177  {
178  return m_type == kEnd
179  && (opens() < closes())
180  && (service_time() >= 0)
181  && (demand() == 0);
182 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_late_arrival ( double  arrival_time) const
inlineinherited

True when arrivalTime is after it closes.

Definition at line 192 of file tw_node.h.

References pgrouting::vrp::Tw_node::m_closes.

Referenced by deltaGeneratesTWV(), has_twv(), pgrouting::vrp::Tw_node::is_compatible_IJ(), pgrouting::vrp::Tw_node::is_on_time(), pgrouting::vrp::Tw_node::is_partially_compatible_IJ(), and pgrouting::vrp::Tw_node::is_tight_compatible_IJ().

192  {
193  return arrival_time > m_closes;
194  }
double m_closes
closing time of the node
Definition: tw_node.h:275

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_load ( ) const
inherited

is_Load

To be a Load node:

  • type is kLoad
  • demand >= 0

Definition at line 168 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kLoad, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

168  {
169  return m_type == kLoad
170  && (opens() < closes())
171  && (service_time() >= 0)
172  && (demand() >= 0);
173 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
load site, fills the truck
Definition: tw_node.h:64
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_on_time ( double  arrival_time) const
inlineinherited
bool pgrouting::vrp::Tw_node::is_partially_compatible_IJ ( const Tw_node I,
double  speed 
) const
inherited

Definition at line 87 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::arrival_j_closes_i(), pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Tw_node::is_compatible_IJ(), pgrouting::vrp::Tw_node::is_early_arrival(), and pgrouting::vrp::Tw_node::is_late_arrival().

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

87  {
88  return
89  is_compatible_IJ(I, speed)
90  && !is_early_arrival(arrival_j_opens_i(I, speed))
91  && is_late_arrival(arrival_j_closes_i(I, speed));
92 }
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:187
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:192
double arrival_j_closes_i(const Tw_node &I, double speed) const
The actual arrival time at this node, given that: this node is visited directly after other node and ...
Definition: tw_node.cpp:64
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_partially_waitTime_compatible_IJ ( const Tw_node I,
double  speed 
) const
inherited

Definition at line 103 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Tw_node::is_compatible_IJ(), and pgrouting::vrp::Tw_node::is_early_arrival().

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

105  {
106  return
107  is_compatible_IJ(I, speed)
108  && is_early_arrival(arrival_j_opens_i(I, speed));
109 }
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:187
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_pickup ( ) const
inherited

is_pickup

To be a pickup node:

  • type is kPickup
  • demand > 0

Definition at line 141 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kPickup, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by pgrouting::vrp::Order::is_valid(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

141  {
142  return m_type == kPickup
143  && (opens() < closes())
144  && (service_time() >= 0)
145  && (demand() > 0);
146 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_start ( ) const
inherited

@ {

is_start

To be a start node:

  • type is kStart
  • demand == 0

Definition at line 132 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::closes(), pgrouting::vrp::Tw_node::demand(), pgrouting::vrp::Tw_node::kStart, pgrouting::vrp::Tw_node::m_type, pgrouting::vrp::Tw_node::opens(), and pgrouting::vrp::Tw_node::service_time().

Referenced by pgrouting::vrp::Fleet::add_vehicle(), evaluate(), has_cv(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::window_length().

132  {
133  return
134  m_type == kStart
135  && (opens() < closes())
136  && (service_time() >= 0)
137  && (demand() == 0);
138 }
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
double opens() const
Returns the opening time.
Definition: tw_node.h:76
double closes() const
Returns the closing time.
Definition: tw_node.h:79
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_tight_compatible_IJ ( const Tw_node I,
double  speed 
) const
inherited

Definition at line 95 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::arrival_j_closes_i(), pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Tw_node::is_compatible_IJ(), pgrouting::vrp::Tw_node::is_early_arrival(), and pgrouting::vrp::Tw_node::is_late_arrival().

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

95  {
96  return
97  is_compatible_IJ(I, speed)
98  && !is_early_arrival(arrival_j_opens_i(I, speed))
99  && !is_late_arrival(arrival_j_closes_i(I, speed));
100 }
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:187
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:192
double arrival_j_closes_i(const Tw_node &I, double speed) const
The actual arrival time at this node, given that: this node is visited directly after other node and ...
Definition: tw_node.cpp:64
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_valid ( ) const
protectedinherited

Definition at line 197 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::is_delivery(), pgrouting::vrp::Tw_node::is_dump(), pgrouting::vrp::Tw_node::is_end(), pgrouting::vrp::Tw_node::is_load(), pgrouting::vrp::Tw_node::is_pickup(), pgrouting::vrp::Tw_node::is_start(), pgrouting::vrp::Tw_node::kDelivery, pgrouting::vrp::Tw_node::kDump, pgrouting::vrp::Tw_node::kEnd, pgrouting::vrp::Tw_node::kLoad, pgrouting::vrp::Tw_node::kPickup, pgrouting::vrp::Tw_node::kStart, and pgrouting::vrp::Tw_node::type().

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

197  {
198  switch (type()) {
199  case kStart:
200  return is_start();
201  break;
202 
203  case kEnd:
204  return is_end();
205  break;
206 
207  case kDump:
208  return is_dump();
209  break;
210 
211  case kDelivery:
212  return is_delivery();
213  break;
214 
215  case kPickup:
216  return is_pickup();
217  break;
218 
219  case kLoad:
220  return is_load();
221  break;
222 
223  default:
224  return false;
225  break;
226  }
227 
228  return false;
229 }
bool is_load() const
is_Load
Definition: tw_node.cpp:168
bool is_end() const
is_end
Definition: tw_node.cpp:177
dump site, empties truck
Definition: tw_node.h:63
load site, fills the truck
Definition: tw_node.h:64
bool is_start() const
@ {
Definition: tw_node.cpp:132
NodeType type() const
Returns the type of this node.
Definition: tw_node.h:89
bool is_pickup() const
is_pickup
Definition: tw_node.cpp:141
bool is_delivery() const
is_delivery
Definition: tw_node.cpp:150
bool is_dump() const
is_dump
Definition: tw_node.cpp:159

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::is_waitTime_compatible_IJ ( const Tw_node I,
double  speed 
) const
inherited

Definition at line 112 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Tw_node::is_compatible_IJ(), and pgrouting::vrp::Tw_node::is_early_arrival().

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

112  {
113  return
114  is_compatible_IJ(I, speed)
115  && is_early_arrival(arrival_j_opens_i(I, speed));
116 }
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:187
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:73
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool pgrouting::vrp::Tw_node::operator== ( const Tw_node rhs) const
inherited

Definition at line 186 of file tw_node.cpp.

References pgrouting::Identifier::idx(), pgrouting::vrp::Pgr_pickDeliver::m_base_nodes, and pgrouting::vrp::PD_problem::problem.

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

186  {
187  if (&other == this) return true;
188  auto lhs = static_cast<const Node&>(
189  *problem->m_base_nodes[idx()].get());
190  auto rhs = static_cast<const Node&>(
191  *problem->m_base_nodes[other.idx()].get());
192  return lhs == rhs;
193 }
static Pgr_pickDeliver * problem
Definition: pd_problem.h:51
std::vector< std::unique_ptr< Base_node > > m_base_nodes
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t pgrouting::vrp::Tw_node::order ( ) const
inlineinherited

@ {

Returns the opening time.

Definition at line 73 of file tw_node.h.

References pgrouting::vrp::Tw_node::m_order.

73 {return m_order;}
int64_t m_order
order to which it belongs
Definition: tw_node.h:273
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:

double pgrouting::vrp::Vehicle_node::total_service_time ( ) const
inline

_time spent by the truck servicing the nodes

Definition at line 105 of file vehicle_node.h.

References delta_time(), deltaGeneratesTWV(), and m_tot_service_time.

Referenced by evaluate().

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::total_time ( ) const
inline

Truck's travel duration up to this node.

Definition at line 96 of file vehicle_node.h.

References m_departure_time.

double pgrouting::vrp::Vehicle_node::total_travel_time ( ) const
inline

_time spent moving between nodes by the truck

Definition at line 99 of file vehicle_node.h.

References m_tot_travel_time.

Referenced by evaluate().

99 {return m_tot_travel_time;}
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:181

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::total_wait_time ( ) const
inline

_time spent by the truck waiting for nodes to open

Definition at line 102 of file vehicle_node.h.

References m_tot_wait_time.

Referenced by evaluate().

102 {return m_tot_wait_time;}
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:180

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::travel_time ( ) const
inline

@ {

Truck's travel_time from previous node to this node.

Definition at line 62 of file vehicle_node.h.

References m_travel_time.

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

62 {return m_travel_time;}

Here is the caller graph for this function:

double pgrouting::vrp::Tw_node::travel_time_to ( const Tw_node other,
double  speed 
) const
inherited

time = distance / speed.

TODO(vicky) shall call Node or Dnode static cast won't work I think

Todo:
TODO evaluate with matrix also

Definition at line 40 of file tw_node.cpp.

References pgrouting::Identifier::idx(), pgrouting::vrp::Pgr_pickDeliver::m_base_nodes, pgassert, and pgrouting::vrp::PD_problem::problem.

Referenced by arrival_i_arrives_j(), pgrouting::vrp::Tw_node::arrival_j_closes_i(), pgrouting::vrp::Tw_node::arrival_j_opens_i(), pgrouting::vrp::Vehicle::deltaTime(), evaluate(), pgrouting::vrp::operator<<(), and pgrouting::vrp::Tw_node::window_length().

40  {
46  auto from = problem->m_base_nodes[idx()].get();
47  auto destination = problem->m_base_nodes[to.idx()].get();
48  pgassert(speed != 0);
50  return from->distance(destination) / speed;
51 }
static Pgr_pickDeliver * problem
Definition: pd_problem.h:51
std::vector< std::unique_ptr< Base_node > > m_base_nodes
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
size_t idx() const
Definition: identifier.cpp:37

Here is the call graph for this function:

Here is the caller graph for this function:

int pgrouting::vrp::Vehicle_node::twvTot ( ) const
inline

@ {

Truck's total times it has violated time windows.

Definition at line 87 of file vehicle_node.h.

References m_twvTot.

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

87 {return m_twvTot;}
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:178

Here is the caller graph for this function:

NodeType pgrouting::vrp::Tw_node::type ( ) const
inlineinherited

Returns the type of this node.

Definition at line 89 of file tw_node.h.

References pgrouting::vrp::Tw_node::m_type.

Referenced by pgrouting::vrp::Tw_node::is_on_time(), pgrouting::vrp::Tw_node::is_valid(), and pgrouting::vrp::Tw_node::type_str().

89 {return m_type;}
NodeType m_type
The demand for the Node.
Definition: tw_node.h:278

Here is the caller graph for this function:

std::string pgrouting::vrp::Tw_node::type_str ( ) const
inherited

Definition at line 119 of file tw_node.cpp.

References pgrouting::vrp::Tw_node::kDelivery, pgrouting::vrp::Tw_node::kDump, pgrouting::vrp::Tw_node::kEnd, pgrouting::vrp::Tw_node::kLoad, pgrouting::vrp::Tw_node::kPickup, pgrouting::vrp::Tw_node::kStart, and pgrouting::vrp::Tw_node::type().

Referenced by pgrouting::vrp::operator<<(), and pgrouting::vrp::Tw_node::window_length().

119  {
120  switch (type()) {
121  case kStart: return "START"; break;
122  case kEnd: return "END"; break;
123  case kDump: return "DUMP"; break;
124  case kLoad: return "LOAD"; break;
125  case kPickup: return "PICKUP"; break;
126  case kDelivery: return "DELIVERY"; break;
127  default: return "UNKNOWN";
128  }
129 }
dump site, empties truck
Definition: tw_node.h:63
load site, fills the truck
Definition: tw_node.h:64
NodeType type() const
Returns the type of this node.
Definition: tw_node.h:89

Here is the call graph for this function:

Here is the caller graph for this function:

double pgrouting::vrp::Vehicle_node::wait_time ( ) const
inline

Truck's wait_time at this node.

Definition at line 68 of file vehicle_node.h.

References m_wait_time.

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

68 {return m_wait_time;}
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:168

Here is the caller graph for this function:

double pgrouting::vrp::Tw_node::window_length ( ) const
inlineinherited

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  log,
const Vehicle_node node 
)
friend

@ {

Definition at line 101 of file vehicle_node.cpp.

101  {
102  log << static_cast<const Tw_node&>(v)
103  << " twv = " << v.has_twv()
104  << ", twvTot = " << v.twvTot()
105  << ", cvTot = " << v.cvTot()
106  << ", cargo = " << v.cargo()
107  << ", travel_time = " << v.travel_time()
108  << ", arrival_time = " << v.arrival_time()
109  << ", wait_time = " << v.wait_time()
110  << ", service_time = " << v.service_time()
111  << ", departure_time = " << v.departure_time();
112  return log;
113 }

Member Data Documentation

double pgrouting::vrp::Vehicle_node::m_arrival_time
private

Arrival time at this node.

Definition at line 167 of file vehicle_node.h.

Referenced by arrival_time(), deltaGeneratesTWV(), evaluate(), and has_twv().

double pgrouting::vrp::Vehicle_node::m_cargo
private

@ {

Accumulated cargo

Definition at line 177 of file vehicle_node.h.

Referenced by cargo(), evaluate(), and has_cv().

int pgrouting::vrp::Vehicle_node::m_cvTot
private

Total count of CV.

Definition at line 179 of file vehicle_node.h.

Referenced by cvTot(), evaluate(), and feasible().

double pgrouting::vrp::Vehicle_node::m_delta_time
private

Departure time - last nodes departure time.

Definition at line 170 of file vehicle_node.h.

Referenced by delta_time(), and evaluate().

double pgrouting::vrp::Vehicle_node::m_departure_time
private

Definition at line 169 of file vehicle_node.h.

Referenced by departure_time(), evaluate(), and total_time().

double pgrouting::vrp::Vehicle_node::m_tot_service_time
private

Definition at line 182 of file vehicle_node.h.

Referenced by evaluate(), and total_service_time().

double pgrouting::vrp::Vehicle_node::m_tot_travel_time
private

Accumulated travel time.

Definition at line 181 of file vehicle_node.h.

Referenced by evaluate(), and total_travel_time().

double pgrouting::vrp::Vehicle_node::m_tot_wait_time
private

Accumulated wait time.

Definition at line 180 of file vehicle_node.h.

Referenced by evaluate(), and total_wait_time().

double pgrouting::vrp::Vehicle_node::m_travel_time
private

@ {

Travel time from last node

Definition at line 166 of file vehicle_node.h.

Referenced by evaluate(), and travel_time().

int pgrouting::vrp::Vehicle_node::m_twvTot
private

Total count of TWV.

Definition at line 178 of file vehicle_node.h.

Referenced by evaluate(), feasible(), and twvTot().

double pgrouting::vrp::Vehicle_node::m_wait_time
private

Wait time at this node when early arrival.

Definition at line 168 of file vehicle_node.h.

Referenced by evaluate(), and wait_time().


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