PGROUTING  2.4
 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 
26 #pragma once
27 
28 
29 #include <string>
30 
31 #include "./tw_node.h"
32 
33 namespace pgrouting {
34 namespace vrp {
35 
36 
46 class Vehicle_node: public Tw_node {
47  public:
49 
51  friend std::ostream& operator<<(
52  std::ostream &log, const Vehicle_node &node);
53 
55 
57 
60  inline double travel_time() const {return m_travel_time;}
61 
63  inline double arrival_time() const {return m_arrival_time;}
64 
66  inline double wait_time() const {return m_wait_time;}
67 
69  inline double departure_time() const {return m_departure_time;}
70 
72  inline double delta_time() const {return m_delta_time;}
73 
75 
76 
77 
78 
79 
80 
82 
85  inline int twvTot() const {return m_twvTot;}
86 
88  inline int cvTot() const {return m_cvTot;}
89 
91  inline double cargo() const {return m_cargo;}
92 
94  inline double total_time() const {return m_departure_time;}
95 
97  inline double total_travel_time() const {return m_tot_travel_time;}
98 
100  inline double total_wait_time() const {return m_tot_wait_time;}
101 
103  inline double total_service_time() const {return m_tot_service_time;}
104 
106 
108  bool deltaGeneratesTWV(double delta_time) const;
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  void evaluate(double cargoLimit);
139  void evaluate(const Vehicle_node &pred, double cargoLimit);
141 
143 
146  double arrival_i_arrives_j(
147  const Vehicle_node &other) const;
148 
150 
151 
152 
154  Vehicle_node(const Vehicle_node &node) = default;
155  Vehicle_node(const Tw_node &node);
156 
157  protected:
159 
161  double m_travel_time;
162  double m_arrival_time;
163  double m_wait_time;
164  double m_departure_time; // /< Departure time from this node
165  double m_delta_time;
166 
168 
170 
172  double m_cargo;
173  int m_twvTot;
174  int m_cvTot;
177  double m_tot_service_time; // /< Accumulated service time
178 
180 };
181 
182 } // namespace vrp
183 } // namespace pgrouting
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:130
double m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:175
double delta_time() const
delta_time = departure_time(this) - departure_time(previous)
Definition: vehicle_node.h:72
bool is_end() const
is_end
Definition: tw_node.cpp:172
bool has_twv() const
True when at this node does not violate time windows.
Definition: vehicle_node.h:122
double m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:176
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:46
double m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:165
double total_time() const
Truck's travel duration up to this node.
Definition: vehicle_node.h:94
double arrival_time() const
Truck's arrival_time to this node.
Definition: vehicle_node.h:63
static size_t pred(size_t i, size_t n)
Definition: pgr_tsp.cpp:65
double total_travel_time() const
_time spent moving between nodes by the truck
Definition: vehicle_node.h:97
int cvTot() const
Truck's total times it has violated cargo limits.
Definition: vehicle_node.h:88
PGDLLEXPORT Datum vrp(PG_FUNCTION_ARGS)
Definition: VRP.c:732
double m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:162
bool is_late_arrival(double arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:201
double total_wait_time() const
_time spent by the truck waiting for nodes to open
Definition: vehicle_node.h:100
friend std::ostream & operator<<(std::ostream &log, const Vehicle_node &node)
@ {
double arrival_i_arrives_j(const Vehicle_node &other) const
@ {
bool is_start() const
@ {
Definition: tw_node.cpp:122
double cargo() const
Truck's total cargo after the node was served.
Definition: vehicle_node.h:91
Vehicle_node(const Vehicle_node &node)=default
Construct from parameters.
double wait_time() const
Truck's wait_time at this node.
Definition: vehicle_node.h:66
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:173
double departure_time() const
Truck's departure_time from this node.
Definition: vehicle_node.h:69
Extends the Node class to create a Node with time window attributes.
Definition: tw_node.h:50
double travel_time() const
@ {
Definition: vehicle_node.h:60
double total_service_time() const
_time spent by the truck servicing the nodes
Definition: vehicle_node.h:103
void evaluate(double cargoLimit)
@ {
bool feasible() const
@ {
Definition: vehicle_node.h:114
bool feasible(double cargoLimit) const
True doesn't have twc nor cv (including total counts)
Definition: vehicle_node.h:117
double m_wait_time
Wait time at this node when early arrival.
Definition: vehicle_node.h:163
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:174