PGROUTING  2.6-dev
solution.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: solution.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 
28 #ifndef INCLUDE_VRP_SOLUTION_H_
29 #define INCLUDE_VRP_SOLUTION_H_
30 #pragma once
31 
32 #include <deque>
33 #include <tuple>
34 #include <string>
35 #include <vector>
36 
38 #include "vrp/fleet.h"
39 #include "vrp/pd_problem.h"
40 
41 namespace pgrouting {
42 namespace vrp {
43 
44 
45 class Solution : public PD_problem {
46  friend class Optimize;
47  protected:
48  double EPSILON;
49  std::deque<Vehicle_pickDeliver> fleet;
50 
51  /* this solution belongs to this problem*/
53 
54  public:
55  std::vector<General_vehicle_orders_t>
56  get_postgres_result() const;
57 
58 
59  /* @brief constructor
60  *
61  */
62  Solution();
63 
64 
65 #if 0
66  /* @brief move constructor */
67  Solution(Solution &&sol) = default;
68 #endif
69 
70  /* @brief copy constructor */
71  Solution(const Solution &sol) :
72  PD_problem(),
73  EPSILON(0.0001),
74  fleet(sol.fleet),
75  trucks(sol.trucks)
76  {};
77 
78  /* @brief copy assignment */
79  Solution& operator = (const Solution& sol) {
80  EPSILON = 0.0001,
81  fleet = sol.fleet;
82  trucks = sol.trucks;
83  return *this;
84  };
85 
86  void sort_by_id();
87 
88  std::string cost_str() const;
89  std::string tau(const std::string &title = "Tau") const;
90  friend std::ostream& operator<<(
91  std::ostream &log,
92  const Solution &solution);
93  bool operator <(const Solution &s_rhs) const;
94 
95  bool is_feasable() const;
96  double duration() const;
97  double wait_time() const;
98  double total_travel_time() const;
99  double total_service_time() const;
100  int twvTot() const;
101  int cvTot() const;
102  size_t fleet_size() const {return fleet.size();}
103 
104  /*
105  * Cost in terms of a tuple
106  * <0> time window violations
107  * <1> capacity violations
108  * <2> fleet size TODO
109  * <3> wait_time
110  * <4> duration
111  */
112  Vehicle::Cost cost() const;
113 };
114 
115 
116 } // namespace vrp
117 } // namespace pgrouting
118 
119 #endif // INCLUDE_VRP_SOLUTION_H_
bool is_feasable() const
Definition: solution.cpp:56
bool operator<(const Solution &s_rhs) const
Definition: solution.cpp:187
Vehicle::Cost cost() const
Definition: solution.cpp:119
Solution(const Solution &sol)
Definition: solution.h:71
std::deque< Vehicle_pickDeliver > fleet
Definition: solution.h:49
size_t fleet_size() const
Definition: solution.h:102
double wait_time() const
Definition: solution.cpp:83
std::vector< General_vehicle_orders_t > get_postgres_result() const
Definition: solution.cpp:39
std::string tau(const std::string &title="Tau") const
Definition: solution.cpp:153
friend std::ostream & operator<<(std::ostream &log, const Solution &solution)
Definition: solution.cpp:175
Book keeping class for swapping orders between vehicles.
Definition: basic_edge.cpp:28
double total_travel_time() const
Definition: solution.cpp:92
std::string cost_str() const
Definition: solution.cpp:138
double duration() const
Definition: solution.cpp:65
double total_service_time() const
Definition: solution.cpp:101
std::tuple< int, int, size_t, double, double > Cost
Definition: vehicle.h:86
Solution & operator=(const Solution &sol)
Definition: solution.h:79