PGROUTING  3.2
tw_node.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: tw_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_TW_NODE_H_
29 #define INCLUDE_VRP_TW_NODE_H_
30 #pragma once
31 
32 #include <string>
33 
36 #include "cpp_common/pgr_assert.h"
37 #include "cpp_common/identifier.h"
38 
39 #include "vrp/pd_problem.h"
40 #include "vrp/dnode.h"
41 
42 namespace pgrouting {
43 namespace vrp {
44 
45 
57 class Tw_node : public Dnode {
58  public:
59  typedef enum {
60  kStart = 0,
66  } NodeType;
67 
68 
70 
73  inline int64_t order() const {return m_order;}
74 
76  inline double opens() const {return m_opens;}
77 
79  inline double closes() const {return m_closes;}
80 
82  inline double demand() const {return m_demand;}
83  inline void demand(double value) {m_demand = value;}
84 
86  inline double service_time() const {return m_service_time;}
87 
89  inline NodeType type() const {return m_type;}
90 
92  inline double window_length() const {return m_closes - m_opens;}
93 
95  double travel_time_to(const Tw_node &other, double speed) const;
96 
98 
108 
110 
118  bool is_start() const;
119 
120 
128  bool is_pickup() const;
129 
130 
138  bool is_delivery() const;
139 
140 
148  bool is_dump() const;
149 
150 
151 
152 
160  bool is_end() const;
161 
162 
163  std::string type_str() const;
164 
169  friend std::ostream& operator<< (std::ostream &log, const Tw_node &node);
170 
174  bool operator ==(const Tw_node &rhs) const;
175 
176 
177 
179  inline bool is_early_arrival(double arrival_time) const {
180  return arrival_time < m_opens;
181  }
182 
184  inline bool is_late_arrival(double arrival_time) const {
185  return arrival_time > m_closes;
186  }
187 
188 
190 
196  double arrival_j_opens_i(const Tw_node &I, double speed) const;
197 
198 
199 
200  /*
201  * is possible to arrive to @b this after visiting @bother
202  * - departing as early as possible from @b other it can arrives to @b this
203  */
204  bool is_compatible_IJ(const Tw_node &I, double speed) const;
205 
206 
207 
209 
210 
211 
212  Tw_node() = default;
213  Tw_node(const Tw_node &) = default;
214  Tw_node(
215  size_t id,
217  NodeType type);
218  Tw_node(
219  size_t id,
220  Vehicle_t data,
221  NodeType type);
222 
223 
224  private:
225  int64_t m_order;
226  double m_opens;
227  double m_closes;
228  double m_service_time; // /< time it takes to be served
229  double m_demand;
231 };
232 
233 } // namespace vrp
234 } // namespace pgrouting
235 
236 #endif // INCLUDE_VRP_TW_NODE_H_
pgrouting::vrp::Dnode
The Dnode class defines a the basic operations when data is a matrix.
Definition: dnode.h:48
pgrouting::vrp::Tw_node::travel_time_to
double travel_time_to(const Tw_node &other, double speed) const
time = distance / speed.
Definition: tw_node.cpp:40
dnode.h
pickDeliveryOrders_t.h
vehicle_t.h
pgrouting::vrp::Tw_node::kDump
@ kDump
dump site, empties truck
Definition: tw_node.h:63
pgrouting::vrp::Tw_node::m_type
NodeType m_type
The demand for the Node.
Definition: tw_node.h:230
PickDeliveryOrders_t
Definition: pickDeliveryOrders_t.h:43
pgrouting::vrp::Tw_node::is_end
bool is_end() const
is_end
Definition: tw_node.cpp:126
pgrouting::vrp::Tw_node::order
int64_t order() const
@ {
Definition: tw_node.h:73
pgrouting::vrp::Tw_node::kDelivery
@ kDelivery
delivery site
Definition: tw_node.h:62
pgrouting::vrp::Tw_node::kStart
@ kStart
starting site
Definition: tw_node.h:60
pgrouting::vrp::Tw_node::operator<<
friend std::ostream & operator<<(std::ostream &log, const Tw_node &node)
Print the contents of a Twnode object.
Definition: tw_node.cpp:191
pgrouting::vrp::Tw_node::demand
double demand() const
Returns the demand associated with this node.
Definition: tw_node.h:82
pgrouting::vrp::Tw_node::m_opens
double m_opens
opening time of the node
Definition: tw_node.h:226
pgrouting::vrp::Tw_node::is_compatible_IJ
bool is_compatible_IJ(const Tw_node &I, double speed) const
Definition: tw_node.cpp:60
Vehicle_t
Definition: vehicle_t.h:40
pgrouting::vrp::Tw_node::type_str
std::string type_str() const
Definition: tw_node.cpp:75
pgrouting::vrp::Tw_node::arrival_j_opens_i
double arrival_j_opens_i(const Tw_node &I, double speed) const
@ {
Definition: tw_node.cpp:50
pgrouting::vrp::Tw_node::is_early_arrival
bool is_early_arrival(double arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:179
pgrouting::vrp::Tw_node::is_pickup
bool is_pickup() const
is_pickup
Definition: tw_node.cpp:97
pgrouting::vrp::Tw_node::kEnd
@ kEnd
ending site
Definition: tw_node.h:65
identifier.h
pgrouting::vrp::Tw_node::closes
double closes() const
Returns the closing time.
Definition: tw_node.h:79
pgrouting::vrp::Tw_node::is_delivery
bool is_delivery() const
is_delivery
Definition: tw_node.cpp:106
pgrouting::vrp::Tw_node::m_service_time
double m_service_time
Definition: tw_node.h:228
pgrouting::vrp::Tw_node::is_start
bool is_start() const
@ {
Definition: tw_node.cpp:88
pgrouting::vrp::Tw_node::Tw_node
Tw_node()=default
pgrouting::vrp::Tw_node::kLoad
@ kLoad
load site, fills the truck
Definition: tw_node.h:64
pgr_assert.h
An assert functionality that uses C++ throw().
pgrouting::vrp::Tw_node::window_length
double window_length() const
Returns the length of time between the opening and closing.
Definition: tw_node.h:92
pgrouting::vrp::Tw_node::kPickup
@ kPickup
pickup site
Definition: tw_node.h:61
pgrouting::vrp::Tw_node::m_order
int64_t m_order
order to which it belongs
Definition: tw_node.h:225
pgrouting::vrp::Tw_node::m_closes
double m_closes
closing time of the node
Definition: tw_node.h:227
pgrouting::vrp::Tw_node
Extends the Node class to create a Node with time window attributes.
Definition: tw_node.h:57
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::Tw_node::opens
double opens() const
Returns the opening time.
Definition: tw_node.h:76
pgrouting::vrp::Tw_node::service_time
double service_time() const
Returns the service time for this node.
Definition: tw_node.h:86
pgrouting::vrp::Tw_node::demand
void demand(double value)
Definition: tw_node.h:83
pd_problem.h
pgrouting::vrp::Tw_node::operator==
bool operator==(const Tw_node &rhs) const
Definition: tw_node.cpp:135
pgrouting::vrp::Tw_node::is_dump
bool is_dump() const
is_dump
Definition: tw_node.cpp:115
pgrouting::vrp::Tw_node::type
NodeType type() const
Returns the type of this node.
Definition: tw_node.h:89
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56
pgrouting::vrp::Tw_node::NodeType
NodeType
Definition: tw_node.h:59
pgrouting::vrp::Tw_node::m_demand
double m_demand
The demand for the Node.
Definition: tw_node.h:229