vrpRouting  0.3
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_PROBLEM_VEHICLE_NODE_H_
29 #define INCLUDE_PROBLEM_VEHICLE_NODE_H_
30 #pragma once
31 
32 
33 #include <string>
34 
35 #include "problem/tw_node.h"
36 
37 typedef struct Solution_rt Solution_rt;
38 
39 namespace vrprouting {
40 namespace problem {
41 
42 
49 class Vehicle_node: public Tw_node {
50  public:
52  friend std::ostream& operator<<(
53  std::ostream &log, const Vehicle_node &v);
54 
56  Vehicle_node() = delete;
57 
59  Vehicle_node(const Vehicle_node &) = default;
60 
62  explicit Vehicle_node(const Tw_node &node);
63 
65  inline TInterval travel_time() const {return m_travel_time;}
66 
68  inline TTimestamp arrival_time() const {return m_arrival_time;}
69 
71  inline TInterval wait_time() const {return m_wait_time;}
72 
74  inline TTimestamp departure_time() const {return m_departure_time;}
75 
80  inline int twvTot() const {return m_twvTot;}
81 
83  inline int cvTot() const {return m_cvTot;}
84 
86  inline Amount cargo() const {return m_cargo;}
87 
90 
92  inline TInterval total_wait_time() const {return m_tot_wait_time;}
93 
99  double objective() const;
100 
102  void evaluate(PAmount cargoLimit);
103 
104  void evaluate(const Vehicle_node &pred, PAmount, Speed = 1.0);
105 
106  Solution_rt get_postgres_result(int vid, int64_t v_id, int stop_seq) const;
107 
108  protected:
112  bool has_twv() const;
113 
115  bool has_cv(PAmount cargoLimit) const;
116 
118 
120  inline TInterval delta_time() const {return m_delta_time;}
121 
124 
128  bool feasible() const {return m_twvTot == 0 && m_cvTot == 0;}
129 
131  bool feasible(PAmount cargoLimit) const {
132  return feasible() && !has_twv() && !has_cv(cargoLimit);
133  }
137  private:
143 
146 
152 
155 
166 
168  int m_twvTot;
169 
171  int m_cvTot;
172 
175 
178 
182 };
183 
184 } // namespace problem
185 } // namespace vrprouting
186 
187 #endif // INCLUDE_PROBLEM_VEHICLE_NODE_H_
vrprouting::problem::Vehicle_node::arrival_time
TTimestamp arrival_time() const
Vehicle's arrival_time to this node.
Definition: vehicle_node.h:68
vrprouting::problem::Vehicle_node::feasible
bool feasible() const
True when the total count for violations are 0.
Definition: vehicle_node.h:128
vrprouting::problem::Vehicle_node::get_postgres_result
Solution_rt get_postgres_result(int vid, int64_t v_id, int stop_seq) const
Definition: vehicle_node.cpp:193
vrprouting::problem::Vehicle_node::twvTot
int twvTot() const
Vehicle's total times it has violated time windows.
Definition: vehicle_node.h:80
vrprouting::problem::Vehicle_node::m_delta_time
TInterval m_delta_time
Departure time - last nodes departure time.
Definition: vehicle_node.h:157
vrprouting::problem::Vehicle_node::m_travel_time
TInterval m_travel_time
Travel time from last node.
Definition: vehicle_node.h:142
vrprouting::problem::Vehicle_node::Vehicle_node
Vehicle_node()=delete
Construction without information is not allowed.
vrprouting::problem::Vehicle_node::has_twv
bool has_twv() const
does the node violates the time windows constraints?
Definition: vehicle_node.cpp:182
vrprouting::problem::Vehicle_node::total_service_time
TInterval total_service_time() const
_time spent by the truck servicing the nodes
Definition: vehicle_node.h:95
vrprouting::problem::Vehicle_node::feasible
bool feasible(PAmount cargoLimit) const
True doesn't have twc nor cv (including total counts)
Definition: vehicle_node.h:131
tw_node.h
vrprouting::problem::Vehicle_node::operator<<
friend std::ostream & operator<<(std::ostream &log, const Vehicle_node &v)
Print the contents of a Vehicle_node object.
Definition: vehicle_node.cpp:119
Speed
double Speed
Definition: typedefs.h:76
vrprouting::problem::Vehicle_node::delta_time
TInterval delta_time() const
delta_time = departure_time(this) - departure_time(previous)
Definition: vehicle_node.h:120
vrprouting::problem::Vehicle_node::total_wait_time
TInterval total_wait_time() const
_time spent by the truck waiting for nodes to open
Definition: vehicle_node.h:92
vrprouting::problem::Vehicle_node
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:49
vrprouting::problem::Vehicle_node::cvTot
int cvTot() const
Vehicle's total times it has violated cargo limits.
Definition: vehicle_node.h:83
vrprouting::problem::Vehicle_node::has_cv
bool has_cv(PAmount cargoLimit) const
does the node violates the capacity constraints?
Definition: vehicle_node.cpp:172
vrprouting::problem::Vehicle_node::m_tot_wait_time
TInterval m_tot_wait_time
Accumulated wait time.
Definition: vehicle_node.h:174
vrprouting::problem::Vehicle_node::departure_time
TTimestamp departure_time() const
Vehicle's departure_time from this node.
Definition: vehicle_node.h:74
vrprouting::problem::Vehicle_node::m_cargo
Amount m_cargo
Accumulated cargo.
Definition: vehicle_node.h:165
Solution_rt
Solution schedule when twv & cw are hard restrictions.
Definition: solution_rt.h:56
vrprouting::problem::Vehicle_node::total_travel_time
TInterval total_travel_time() const
_time spent moving between nodes by the truck
Definition: vehicle_node.h:89
vrprouting::problem::Vehicle_node::total_time
TInterval total_time() const
Definition: vehicle_node.h:117
TTimestamp
int64_t TTimestamp
Definition: typedefs.h:71
Amount
int64_t Amount
Definition: typedefs.h:74
vrprouting::problem::Vehicle_node::travel_time
TInterval travel_time() const
Vehicle's travel_time from previous node to this node.
Definition: vehicle_node.h:65
vrprouting::problem::Vehicle_node::m_twvTot
int m_twvTot
Total count of TWV.
Definition: vehicle_node.h:168
vrprouting::problem::Vehicle_node::m_tot_travel_time
TInterval m_tot_travel_time
Accumulated travel time.
Definition: vehicle_node.h:177
vrprouting::problem::Vehicle_node::m_tot_service_time
TInterval m_tot_service_time
Accumulated service time.
Definition: vehicle_node.h:180
vrprouting::problem::Tw_node
Time window attributes of a node.
Definition: tw_node.h:54
vrprouting::problem::Vehicle_node::objective
double objective() const
the basic objective function for this node
Definition: vehicle_node.cpp:39
vrprouting::problem::Vehicle_node::m_wait_time
TInterval m_wait_time
Wait time at this node.
Definition: vehicle_node.h:151
vrprouting::problem::Vehicle_node::cargo
Amount cargo() const
Vehicle's total cargo after the node was served.
Definition: vehicle_node.h:86
vrprouting::problem::Vehicle_node::wait_time
TInterval wait_time() const
Vehicle's wait_time at this node.
Definition: vehicle_node.h:71
PAmount
uint32_t PAmount
Definition: typedefs.h:75
TInterval
int64_t TInterval
Definition: typedefs.h:72
vrprouting::problem::Vehicle_node::m_arrival_time
TTimestamp m_arrival_time
Arrival time at this node.
Definition: vehicle_node.h:145
vrprouting::problem::Vehicle_node::m_departure_time
TTimestamp m_departure_time
Departure time from this node.
Definition: vehicle_node.h:154
vrprouting::problem::Vehicle_node::deltaGeneratesTWV
bool deltaGeneratesTWV(TInterval delta_time) const
True when arrival_time + delta_time generates TWV.
Definition: vehicle_node.cpp:158
vrprouting::problem::Vehicle_node::evaluate
void evaluate(PAmount cargoLimit)
evaluate this node
Definition: vehicle_node.cpp:52
vrprouting
Definition: base_matrix.cpp:46
vrprouting::problem::Vehicle_node::m_cvTot
int m_cvTot
Total count of CV.
Definition: vehicle_node.h:171