PGROUTING  3.2
vehicle_node.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: vehicle_node.h
4 
5 Copyright (c) 2015 pgRouting developers
7 
8 ------
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 
24  ********************************************************************PGR-GNU*/
25 
28 #ifndef INCLUDE_VRP_VEHICLE_NODE_H_
29 #define INCLUDE_VRP_VEHICLE_NODE_H_
30 #pragma once
31 
32 
33 #include <string>
34 
35 #include "vrp/tw_node.h"
36 
37 namespace pgrouting {
38 namespace vrp {
39 
40 
48 class Vehicle_node: public Tw_node {
49  public:
51 
53  friend std::ostream& operator<<(
54  std::ostream &log, const Vehicle_node &node);
55 
57 
59 
62  inline double travel_time() const {return m_travel_time;}
63 
65  inline double arrival_time() const {return m_arrival_time;}
66 
68  inline double wait_time() const {return m_wait_time;}
69 
71  inline double departure_time() const {return m_departure_time;}
72 
74  inline double delta_time() const {return m_delta_time;}
75 
77 
78 
79 
80 
81 
82 
84 
87  inline int twvTot() const {return m_twvTot;}
88 
90  inline int cvTot() const {return m_cvTot;}
91 
93  inline double cargo() const {return m_cargo;}
94 
96  inline double total_time() const {return m_departure_time;}
97 
99  inline double total_travel_time() const {return m_tot_travel_time;}
100 
102  inline double total_wait_time() const {return m_tot_wait_time;}
103 
105  inline double total_service_time() const {return m_tot_service_time;}
106 
108 
109 
111 
114  bool feasible() const {return m_twvTot == 0 && m_cvTot == 0;}
115 
117  bool feasible(double cargoLimit) const {
118  return feasible() && !has_twv() && !has_cv(cargoLimit);
119  }
120 
122  bool has_twv() const {
124  }
125 
130  bool has_cv(double cargoLimit) const {
131  return is_end() || is_start() ? m_cargo != 0
132  : m_cargo > cargoLimit || m_cargo < 0;
133  }
135 
137 
139  void evaluate(double cargoLimit);
140  void evaluate(const Vehicle_node &pred, double cargoLimit, double speed);
142 
143 
144 
145 
147  Vehicle_node() = delete;
148  Vehicle_node(const Vehicle_node &) = default;
149  explicit Vehicle_node(const Tw_node &node);
150 
151  private:
153 
155  double m_travel_time;
156  double m_arrival_time;
157  double m_wait_time;
158  double m_departure_time; // /< Departure time from this node
159  double m_delta_time;
160 
162 
164 
166  double m_cargo;
167  int m_twvTot;
168  int m_cvTot;
171  double m_tot_service_time; // /< Accumulated service time
172 
174 };
175 
176 } // namespace vrp
177 } // namespace pgrouting
178 
179 #endif // INCLUDE_VRP_VEHICLE_NODE_H_
pgrouting::vrp::Vehicle_node::m_tot_travel_time
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:170
pgrouting::vrp::Vehicle_node::m_departure_time
double m_departure_time
Definition: vehicle_node.h:158
pgrouting::vrp::Vehicle_node::total_travel_time
double total_travel_time() const
_time spent moving between nodes by the truck
Definition: vehicle_node.h:99
pgrouting::vrp::Vehicle_node::total_service_time
double total_service_time() const
_time spent by the truck servicing the nodes
Definition: vehicle_node.h:105
pgrouting::vrp::Vehicle_node::m_twvTot
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:167
pgrouting::vrp::Vehicle_node::departure_time
double departure_time() const
Truck's departure_time from this node.
Definition: vehicle_node.h:71
pgrouting::vrp::Tw_node::is_end
bool is_end() const
is_end
Definition: tw_node.cpp:126
pgrouting::vrp::Vehicle_node::m_travel_time
double m_travel_time
@ {
Definition: vehicle_node.h:155
pgrouting::vrp::Vehicle_node::m_cvTot
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:168
pgrouting::vrp::Vehicle_node::total_wait_time
double total_wait_time() const
_time spent by the truck waiting for nodes to open
Definition: vehicle_node.h:102
pgrouting::vrp::Vehicle_node
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:48
pgrouting::vrp::Vehicle_node::cvTot
int cvTot() const
Truck's total times it has violated cargo limits.
Definition: vehicle_node.h:90
pgrouting::vrp::Vehicle_node::m_cargo
double m_cargo
@ {
Definition: vehicle_node.h:166
pgrouting::vrp::Vehicle_node::delta_time
double delta_time() const
delta_time = departure_time(this) - departure_time(previous)
Definition: vehicle_node.h:74
pgrouting::vrp::Vehicle_node::m_delta_time
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:159
tw_node.h
pred
static size_t pred(size_t i, size_t n)
Definition: pgr_tsp.cpp:64
pgrouting::vrp::Vehicle_node::travel_time
double travel_time() const
@ {
Definition: vehicle_node.h:62
pgrouting::vrp::Tw_node::is_start
bool is_start() const
@ {
Definition: tw_node.cpp:88
pgrouting::vrp::Vehicle_node::has_cv
bool has_cv(double cargoLimit) const
True when not violation.
Definition: vehicle_node.h:130
pgrouting::vrp::Vehicle_node::twvTot
int twvTot() const
@ {
Definition: vehicle_node.h:87
pgrouting::vrp::Vehicle_node::m_wait_time
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:157
pgrouting::vrp::Vehicle_node::evaluate
void evaluate(double cargoLimit)
@ {
Definition: vehicle_node.cpp:38
pgrouting::vrp::Tw_node
Extends the Node class to create a Node with time window attributes.
Definition: tw_node.h:57
pgrouting::vrp::Vehicle_node::m_arrival_time
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:156
pgrouting::vrp::Tw_node::is_late_arrival
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:184
pgrouting::vrp::Vehicle_node::m_tot_wait_time
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:169
pgrouting::vrp::Vehicle_node::total_time
double total_time() const
Truck's travel duration up to this node.
Definition: vehicle_node.h:96
pgrouting::vrp::Vehicle_node::wait_time
double wait_time() const
Truck's wait_time at this node.
Definition: vehicle_node.h:68
pgrouting::vrp::Vehicle_node::feasible
bool feasible(double cargoLimit) const
True doesn't have twc nor cv (including total counts)
Definition: vehicle_node.h:117
pgrouting::vrp::Vehicle_node::Vehicle_node
Vehicle_node()=delete
Construct from parameters.
pgrouting::vrp::Vehicle_node::arrival_time
double arrival_time() const
Truck's arrival_time to this node.
Definition: vehicle_node.h:65
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56
pgrouting::vrp::Vehicle_node::operator<<
friend std::ostream & operator<<(std::ostream &log, const Vehicle_node &node)
@ {
Definition: vehicle_node.cpp:101
pgrouting::vrp::Vehicle_node::cargo
double cargo() const
Truck's total cargo after the node was served.
Definition: vehicle_node.h:93
pgrouting::vrp::Vehicle_node::feasible
bool feasible() const
@ {
Definition: vehicle_node.h:114
pgrouting::vrp::Vehicle_node::has_twv
bool has_twv() const
True when at this node does not violate time windows.
Definition: vehicle_node.h:122
pgrouting::vrp::Vehicle_node::m_tot_service_time
double m_tot_service_time
Definition: vehicle_node.h:171