vrpRouting  0.3
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_PROBLEM_TW_NODE_H_
29 #define INCLUDE_PROBLEM_TW_NODE_H_
30 #pragma once
31 
32 #include <string>
33 #include "c_types/typedefs.h"
34 #include "cpp_common/identifier.h"
35 #include "problem/node_types.h"
36 
37 
38 namespace vrprouting {
39 namespace problem {
40 
41 class Matrix;
42 
54 class Tw_node : public Identifier {
55  public:
57  Tw_node() = delete;
58 
60  Tw_node(const Tw_node &) = default;
61 
63  Tw_node(
64  size_t id,
65  const PickDeliveryOrders_t &data,
66  const NodeType &type);
67 
69  Tw_node(
70  size_t id,
71  const Vehicle_t &data,
72  const NodeType &type);
73 
75  inline int64_t order() const {return m_order;}
76 
78  inline TTimestamp opens() const {return m_opens;}
79 
81  inline TTimestamp closes() const {return m_closes;}
82 
84  inline TInterval service_time() const {return m_service_time;}
85 
87  inline auto type() const {return m_type;}
88 
90  inline TInterval window_length() const {return m_closes - m_opens;}
91 
93  bool is_start() const;
94 
96  bool is_pickup() const;
97 
99  bool is_delivery() const;
100 
102  bool is_end() const;
103 
105  bool is_dump() const;
106 
108  bool is_load() const;
109 
111  std::string type_str() const;
112 
114  friend std::ostream& operator<<(std::ostream &, const Tw_node &);
115 
117  bool operator ==(const Tw_node &rhs) const;
118 
119 
121  inline bool is_late_arrival(TTimestamp arrival_time) const {
122  return arrival_time > m_closes;
123  }
124 
126  inline bool is_early_arrival(TTimestamp arrival_time) const {
127  return arrival_time < m_opens;
128  }
129 
131  inline bool is_on_time(TTimestamp arrival_time) const {
132  return !is_early_arrival(arrival_time)
133  && !is_late_arrival(arrival_time);
134  }
135 
137  TInterval travel_time_to(const Tw_node&, TTimestamp, Speed = 1.0) const;
138 
139  static const Matrix* m_time_matrix_ptr;
140 
142  bool is_compatible_IJ(const Tw_node &I, Speed = 1.0) const;
143 
145  TTimestamp arrival_j_opens_i(const Tw_node &I, Speed = 1.0) const;
146 
148  TTimestamp arrival_j_closes_i(const Tw_node &I, Speed = 1.0) const;
149 
151  bool is_partially_compatible_IJ(const Tw_node &I, Speed = 1.0) const;
152 
154  bool is_tight_compatible_IJ(const Tw_node &I, Speed = 1.0) const;
155 
157  bool is_partially_waitTime_compatible_IJ(const Tw_node &I, Speed = 1.0) const;
158 
160  bool is_waitTime_compatible_IJ(const Tw_node &I, Speed = 1.0) const;
161 
163  inline Amount demand() const {return m_demand;}
164 
166  bool is_valid() const;
167 
168  protected:
170  inline void demand(Amount value) {m_demand = value;}
171 
172  private:
174  int64_t m_order { };
175 
178 
181 
184 
187 
190 };
191 
192 } // namespace problem
193 } // namespace vrprouting
194 
195 #endif // INCLUDE_PROBLEM_TW_NODE_H_
node_types.h
vrprouting::problem::Tw_node::window_length
TInterval window_length() const
Returns the length of time between the opening and closing.
Definition: tw_node.h:90
vrprouting::problem::Tw_node::m_order
int64_t m_order
order to which it belongs (idx)
Definition: tw_node.h:174
vrprouting::problem::Tw_node::is_delivery
bool is_delivery() const
Is the node a valid order's delivery node.
Definition: tw_node.cpp:210
vrprouting::problem::Tw_node::arrival_j_opens_i
TTimestamp arrival_j_opens_i(const Tw_node &I, Speed=1.0) const
arrival time at This node, when arrived at I at opening time TODO refine description
Definition: tw_node.cpp:66
vrprouting::problem::Tw_node::m_closes
TTimestamp m_closes
closing time of the node
Definition: tw_node.h:180
PickDeliveryOrders_t
order's attributes
Definition: pickDeliveryOrders_t.h:56
vrprouting::problem::Tw_node::demand
Amount demand() const
Returns the demand associated with this node.
Definition: tw_node.h:163
vrprouting::problem::Tw_node::is_partially_compatible_IJ
bool is_partially_compatible_IJ(const Tw_node &I, Speed=1.0) const
can arrive to this after visiting as late as possible I? TODO refine description
Definition: tw_node.cpp:116
vrprouting::problem::Tw_node::closes
TTimestamp closes() const
Returns the closing time.
Definition: tw_node.h:81
vrprouting::problem::Tw_node::operator==
bool operator==(const Tw_node &rhs) const
equality operator
Definition: tw_node.cpp:258
vrprouting::problem::Tw_node::is_partially_waitTime_compatible_IJ
bool is_partially_waitTime_compatible_IJ(const Tw_node &I, Speed=1.0) const
can arrive to this after visiting as late as possible I? TODO refine description
Definition: tw_node.cpp:146
Vehicle_t
vehicles's attributes
Definition: vehicle_t.h:50
vrprouting::problem::Tw_node::type_str
std::string type_str() const
returns a string code of the kind of node
Definition: tw_node.cpp:171
vrprouting::problem::Tw_node::service_time
TInterval service_time() const
Returns the service time for this node.
Definition: tw_node.h:84
vrprouting::problem::Tw_node::is_dump
bool is_dump() const
Is the node a valid vehicle's dumping node.
Definition: tw_node.cpp:222
vrprouting::problem::Tw_node::type
auto type() const
Returns the type of this node.
Definition: tw_node.h:87
Speed
double Speed
Definition: typedefs.h:76
vrprouting::problem::Matrix
Definition: matrix.h:46
vrprouting::problem::Tw_node::is_late_arrival
bool is_late_arrival(TTimestamp arrival_time) const
True when arrivalTime is after it closes.
Definition: tw_node.h:121
typedefs.h
identifier.h
vrprouting::problem::Tw_node::demand
void demand(Amount value)
Sets the demand value to a new value.
Definition: tw_node.h:170
vrprouting::problem::Tw_node::is_pickup
bool is_pickup() const
Is the node a valid order's pickup node.
Definition: tw_node.cpp:199
vrprouting::problem::Tw_node::is_compatible_IJ
bool is_compatible_IJ(const Tw_node &I, Speed=1.0) const
is possible to arrive to this after visiting other?
Definition: tw_node.cpp:94
vrprouting::problem::Tw_node::is_on_time
bool is_on_time(TTimestamp arrival_time) const
True when arrivalTime in the time window.
Definition: tw_node.h:131
TTimestamp
int64_t TTimestamp
Definition: typedefs.h:71
Amount
int64_t Amount
Definition: typedefs.h:74
vrprouting::problem::Tw_node::m_demand
Amount m_demand
The demand for the Node.
Definition: tw_node.h:186
vrprouting::problem::Tw_node
Time window attributes of a node.
Definition: tw_node.h:54
vrprouting::problem::Tw_node::order
int64_t order() const
Returns the order to which it belongs.
Definition: tw_node.h:75
vrprouting::problem::Tw_node::Tw_node
Tw_node()=delete
Creating a Tw_node is not permitted.
vrprouting::problem::Tw_node::arrival_j_closes_i
TTimestamp arrival_j_closes_i(const Tw_node &I, Speed=1.0) const
arrival time at This node, when arrived at I at closing time TODO refine description
Definition: tw_node.cpp:81
vrprouting::problem::Tw_node::is_end
bool is_end() const
Is the node a valid vehicle's ending node.
Definition: tw_node.cpp:245
vrprouting::problem::NodeType
NodeType
Definition: node_types.h:35
vrprouting::problem::Tw_node::is_waitTime_compatible_IJ
bool is_waitTime_compatible_IJ(const Tw_node &I, Speed=1.0) const
can arrive to this after visiting as late as possible I? TODO refine description
Definition: tw_node.cpp:162
vrprouting::problem::Tw_node::operator<<
friend std::ostream & operator<<(std::ostream &, const Tw_node &)
Print the contents of a Twnode object.
Definition: tw_node.cpp:362
TInterval
int64_t TInterval
Definition: typedefs.h:72
vrprouting::problem::Tw_node::m_time_matrix_ptr
static const Matrix * m_time_matrix_ptr
Definition: tw_node.h:139
vrprouting::problem::Tw_node::m_service_time
TInterval m_service_time
time it takes to be served
Definition: tw_node.h:183
vrprouting::Identifier
Class that stores the information about identifiers.
Definition: identifier.h:65
vrprouting::problem::Tw_node::is_load
bool is_load() const
Is the node a valid vehicle's loading node.
Definition: tw_node.cpp:234
vrprouting::problem::Tw_node::is_early_arrival
bool is_early_arrival(TTimestamp arrival_time) const
True when arrivalTime is before it opens.
Definition: tw_node.h:126
vrprouting::problem::Tw_node::is_tight_compatible_IJ
bool is_tight_compatible_IJ(const Tw_node &I, Speed=1.0) const
can arrive to this after visiting as late as possible I? TODO refine description
Definition: tw_node.cpp:131
vrprouting::problem::Tw_node::travel_time_to
TInterval travel_time_to(const Tw_node &, TTimestamp, Speed=1.0) const
travel time to other node.
Definition: tw_node.cpp:51
vrprouting::problem::Tw_node::opens
TTimestamp opens() const
Returns the opening time.
Definition: tw_node.h:78
vrprouting::problem::Tw_node::is_start
bool is_start() const
Is the node a valid vehicle's starting node.
Definition: tw_node.cpp:187
vrprouting::problem::Tw_node::is_valid
bool is_valid() const
is the node valid?
Definition: tw_node.cpp:274
vrprouting::problem::Tw_node::m_type
NodeType m_type
The kind of Node.
Definition: tw_node.h:189
vrprouting
Definition: base_matrix.cpp:46
vrprouting::problem::Tw_node::m_opens
TTimestamp m_opens
opening time of the node
Definition: tw_node.h:177