vrpRouting  0.3
vehicle.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: vehicle.h
4 
5 Copyright (c) 2021 pgRouting developers
7 
8 ------
9 
10 Nhis 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 Nhis program is distributed in the hope that it will be useful,
16 but WINHOUN ANY WARRANNY; without even the implied warranty of
17 MERCHANNABILINY or FINNESS FOR A PARNICULAR 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_H_
29 #define INCLUDE_PROBLEM_VEHICLE_H_
30 #pragma once
31 
32 #include <utility>
33 #include <deque>
34 #include <string>
35 #include <vector>
36 
37 #include "c_types/solution_rt.h"
38 #include "cpp_common/pgr_assert.h"
39 #include "cpp_common/identifier.h"
40 #include "problem/vehicle_node.h"
41 
42 namespace vrprouting {
43 namespace problem {
44 
61 class Vehicle : public Identifier, protected std::deque<Vehicle_node> {
62  public:
65  Speed speed() const;
66 
68  PAmount capacity() const;
69 
71  TInterval duration() const;
72 
74  TInterval total_wait_time() const;
75 
78 
81 
82  int twvTot() const;
83 
84  int cvTot() const;
85 
86  bool has_twv() const;
87 
88  bool has_cv() const;
89 
90  void invariant() const;
91 
92  bool is_ok() const;
93 
94  bool empty() const;
95 
96  size_t length() const;
97 
98  bool is_phony() const;
99 
100  bool is_real() const;
101 
102  bool is_feasible() const;
103 
104  const Vehicle_node& start_site() const;
105 
106  const Vehicle_node& end_site() const;
107 
108  std::vector<Solution_rt> get_postgres_result(int vid) const;
109  std::vector<Id> get_stops() const;
110 
111  std::string path_str() const;
112 
113  std::string tau() const;
114 
115  protected:
116  void evaluate();
117 
118  void evaluate(size_t from);
119 
120  void erase_node(size_t pos);
121 
122  void insert_node(size_t pos, const Vehicle_node &node);
123 
124  void push_back_node(const Vehicle_node &node);
125 
126  void push_front_node(const Vehicle_node &node);
127 
128  void erase(size_t pos);
129 
131  void erase(const Vehicle_node &node);
132 
133  void insert(size_t pos, const Vehicle_node &node);
134 
135  void push_back(const Vehicle_node &node);
136 
137  void push_front(const Vehicle_node &node);
138 
139  void pop_back();
140 
141  void pop_front();
142 
143  void swap(size_t i, size_t j);
144 
146  std::pair<size_t, size_t> position_limits(const Vehicle_node &node) const;
147  std::pair<size_t, size_t> drop_position_limits(const Vehicle_node &node) const;
148 
150  size_t getPosLowLimit(const Vehicle_node &node) const;
151 
153  size_t getPosHighLimit(const Vehicle_node &node) const;
154 
155  size_t getDropPosLowLimit(const Vehicle_node &node) const;
156 
157  friend bool operator<(const Vehicle &lhs, const Vehicle &rhs);
158 
159  Vehicle() = delete;
160  Vehicle(const Vehicle&) = default;
161  Vehicle(Idx idx,
162  Id id,
163  const Vehicle_node &p_starting_site,
164  const Vehicle_node &p_ending_site,
165  PAmount p_capacity,
166  Speed p_speed = 1.0);
167 
168  protected:
173  int m_user_twv {0};
174 
179  int m_user_cv {0};
180 
181  private:
183  Speed m_speed = 1.0;
184 };
185 
186 } // namespace problem
187 } // namespace vrprouting
188 
189 #endif // INCLUDE_PROBLEM_VEHICLE_H_
vrprouting::problem::Vehicle::m_speed
Speed m_speed
Definition: vehicle.h:183
vrprouting::problem::Vehicle::twvTot
int twvTot() const
Definition: vehicle.cpp:92
vrprouting::problem::Vehicle::evaluate
void evaluate()
Definition: vehicle.cpp:126
vrprouting::problem::Vehicle::invariant
void invariant() const
Definition: vehicle.cpp:100
vrprouting::problem::Vehicle::start_site
const Vehicle_node & start_site() const
Definition: vehicle.cpp:122
vrprouting::problem::Vehicle
Vehicle with time windows.
Definition: vehicle.h:61
vrprouting::problem::Vehicle::pop_front
void pop_front()
Definition: vehicle.cpp:223
vrprouting::problem::Vehicle::push_front
void push_front(const Vehicle_node &node)
Definition: vehicle.cpp:213
vehicle_node.h
vrprouting::problem::Vehicle::has_twv
bool has_twv() const
Definition: vehicle.cpp:96
vrprouting::problem::Vehicle::m_user_cv
int m_user_cv
Time window violations on solution.
Definition: vehicle.h:179
vrprouting::problem::Vehicle::is_real
bool is_real() const
Definition: vehicle.cpp:118
vrprouting::problem::Vehicle::push_front_node
void push_front_node(const Vehicle_node &node)
Definition: vehicle.cpp:168
vrprouting::problem::Vehicle::getDropPosLowLimit
size_t getDropPosLowLimit(const Vehicle_node &node) const
Definition: vehicle.cpp:331
vrprouting::problem::Vehicle::is_phony
bool is_phony() const
Definition: vehicle.cpp:116
vrprouting::problem::Vehicle::is_feasible
bool is_feasible() const
Definition: vehicle.cpp:120
vrprouting::problem::Vehicle::push_back
void push_back(const Vehicle_node &node)
Definition: vehicle.cpp:208
Speed
double Speed
Definition: typedefs.h:76
vrprouting::problem::Vehicle::end_site
const Vehicle_node & end_site() const
Definition: vehicle.cpp:124
vrprouting::problem::Vehicle::is_ok
bool is_ok() const
Definition: vehicle.cpp:106
vrprouting::problem::Vehicle::m_user_twv
int m_user_twv
Time window violations on solution.
Definition: vehicle.h:173
Id
int64_t Id
Definition: typedefs.h:78
vrprouting::problem::Vehicle::get_stops
std::vector< Id > get_stops() const
Definition: vehicle.cpp:306
vrprouting::problem::Vehicle::getPosHighLimit
size_t getPosHighLimit(const Vehicle_node &node) const
Get the highest position on the path where node can be placed.
Definition: vehicle.cpp:397
vrprouting::Identifier::idx
size_t idx() const
get the internal index
Definition: identifier.cpp:37
vrprouting::problem::Vehicle_node
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:49
identifier.h
vrprouting::problem::Vehicle::m_capacity
PAmount m_capacity
Definition: vehicle.h:182
vrprouting::problem::Vehicle::swap
void swap(size_t i, size_t j)
Definition: vehicle.cpp:228
vrprouting::problem::Vehicle::path_str
std::string path_str() const
Definition: vehicle.cpp:272
vrprouting::problem::Vehicle::cvTot
int cvTot() const
Definition: vehicle.cpp:94
pgr_assert.h
An assert functionality that uses C++ throw().
vrprouting::problem::Vehicle::total_wait_time
TInterval total_wait_time() const
duration of vehicle while waiting for a node to open
Definition: vehicle.cpp:78
vrprouting::problem::Vehicle::operator<
friend bool operator<(const Vehicle &lhs, const Vehicle &rhs)
Definition: vehicle.cpp:433
vrprouting::problem::Vehicle::duration
TInterval duration() const
duration of vehicle while not in a "depot"
Definition: vehicle.cpp:72
vrprouting::problem::Vehicle::pop_back
void pop_back()
Definition: vehicle.cpp:218
Idx
uint64_t Idx
Definition: typedefs.h:79
vrprouting::problem::Vehicle::erase
void erase(size_t pos)
Definition: vehicle.cpp:172
vrprouting::problem::Vehicle::get_postgres_result
std::vector< Solution_rt > get_postgres_result(int vid) const
Definition: vehicle.cpp:292
solution_rt.h
vrprouting::problem::Vehicle::total_travel_time
TInterval total_travel_time() const
total time spent moving from one node to another
Definition: vehicle.cpp:84
vrprouting::problem::Vehicle::erase_node
void erase_node(size_t pos)
Definition: vehicle.cpp:152
vrprouting::problem::Vehicle::Vehicle
Vehicle()=delete
vrprouting::problem::Vehicle::insert_node
void insert_node(size_t pos, const Vehicle_node &node)
Definition: vehicle.cpp:158
PAmount
uint32_t PAmount
Definition: typedefs.h:75
TInterval
int64_t TInterval
Definition: typedefs.h:72
vrprouting::problem::Vehicle::getPosLowLimit
size_t getPosLowLimit(const Vehicle_node &node) const
Get the lowest position on the path where node can be placed.
Definition: vehicle.cpp:366
vrprouting::problem::Vehicle::tau
std::string tau() const
Definition: vehicle.cpp:251
vrprouting::problem::Vehicle::push_back_node
void push_back_node(const Vehicle_node &node)
Definition: vehicle.cpp:164
vrprouting::problem::Vehicle::capacity
PAmount capacity() const
returns the capacity of the vehicle
Definition: vehicle.cpp:66
vrprouting::Identifier
Class that stores the information about identifiers.
Definition: identifier.h:65
vrprouting::problem::Vehicle::has_cv
bool has_cv() const
Definition: vehicle.cpp:98
vrprouting::problem::Vehicle::drop_position_limits
std::pair< size_t, size_t > drop_position_limits(const Vehicle_node &node) const
Definition: vehicle.cpp:426
vrprouting::problem::Vehicle::speed
Speed speed() const
the speed of the vehicle
Definition: vehicle.cpp:63
vrprouting::problem::Vehicle::total_service_time
TInterval total_service_time() const
total time spent moving from one node to another
Definition: vehicle.cpp:90
vrprouting::problem::Vehicle::position_limits
std::pair< size_t, size_t > position_limits(const Vehicle_node &node) const
Get the limits to insert the node.
Definition: vehicle.cpp:419
vrprouting::problem::Vehicle::insert
void insert(size_t pos, const Vehicle_node &node)
Definition: vehicle.cpp:202
vrprouting::problem::Vehicle::length
size_t length() const
Definition: vehicle.cpp:114
vrprouting::problem::Vehicle::empty
bool empty() const
Definition: vehicle.cpp:112
vrprouting
Definition: base_matrix.cpp:46