PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
6 Mail: project@pgrouting.org
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 
110  bool deltaGeneratesTWV(double delta_time) const;
111 
113 
116  bool feasible() const {return m_twvTot == 0 && m_cvTot == 0;}
117 
119  bool feasible(double cargoLimit) const {
120  return feasible() && !has_twv() && !has_cv(cargoLimit);
121  }
122 
124  bool has_twv() const {
126  }
127 
132  bool has_cv(double cargoLimit) const {
133  return is_end() || is_start() ? m_cargo != 0
134  : m_cargo > cargoLimit || m_cargo < 0;
135  }
137 
139 
141  void evaluate(double cargoLimit);
142  void evaluate(const Vehicle_node &pred, double cargoLimit, double speed);
144 
146 
149  double arrival_i_arrives_j(
150  const Vehicle_node &other,
151  double speed) const;
152 
154 
155 
156 
159  Vehicle_node(const Vehicle_node &) = default;
160  explicit Vehicle_node(const Tw_node &node);
161 
162  private:
164 
166  double m_travel_time;
167  double m_arrival_time;
168  double m_wait_time;
169  double m_departure_time; // /< Departure time from this node
170  double m_delta_time;
171 
173 
175 
177  double m_cargo;
178  int m_twvTot;
179  int m_cvTot;
182  double m_tot_service_time; // /< Accumulated service time
183 
185 };
186 
187 } // namespace vrp
188 } // namespace pgrouting
189 
190 #endif // INCLUDE_VRP_VEHICLE_NODE_H_
bool deltaGeneratesTWV(double delta_time) const
True when arrival_time + delta_time generates TWV.
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 delta_time() const
delta_time = departure_time(this) - departure_time(previous)
Definition: vehicle_node.h:74
bool is_end() const
is_end
Definition: tw_node.cpp:182
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
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:48
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:170
double total_time() const
Truck's travel duration up to this node.
Definition: vehicle_node.h:96
double arrival_time() const
Truck'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 total_travel_time() const
_time spent moving between nodes by the truck
Definition: vehicle_node.h:99
int cvTot() const
Truck's total times it has violated cargo limits.
Definition: vehicle_node.h:90
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
double total_wait_time() const
_time spent by the truck waiting for nodes to open
Definition: vehicle_node.h:102
friend std::ostream & operator<<(std::ostream &log, const Vehicle_node &node)
@ {
bool is_start() const
@ {
Definition: tw_node.cpp:132
double cargo() const
Truck's total cargo after the node was served.
Definition: vehicle_node.h:93
double wait_time() const
Truck'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's departure_time from this node.
Definition: vehicle_node.h:71
double arrival_i_arrives_j(const Vehicle_node &other, double speed) const
@ {
Extends the Node class to create a Node with time window attributes.
Definition: tw_node.h:57
Vehicle_node()
Construct from parameters.
Definition: vehicle_node.h:158
double travel_time() const
@ {
Definition: vehicle_node.h:62
double total_service_time() const
_time spent by the truck servicing the nodes
Definition: vehicle_node.h:105
void evaluate(double cargoLimit)
@ {
bool feasible() const
@ {
Definition: vehicle_node.h:116
bool feasible(double cargoLimit) const
True doesn't have twc nor cv (including total counts)
Definition: vehicle_node.h:119
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