PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 #pragma once
26 
27 #include <deque>
28 #include <tuple>
29 #include <string>
30 #include <vector>
31 
32 #include "./vehicle_pickDeliver.h"
33 #include "./order.h"
34 
35 namespace pgrouting {
36 namespace vrp {
37 
38 
39 class Pgr_pckDeliver;
40 class Optimize;
41 
42 class Solution {
43  friend class Optimize;
44  protected:
45  double EPSILON;
46  std::deque<Vehicle_pickDeliver> fleet;
47 
48  /* this solution belongs to this problem*/
50 
51 
52  public:
54  std::vector< General_vehicle_orders_t > &result) const;
55 
56 
57  /* @brief constructor
58  *
59  * @params [in] p_problem \t pointer to problem
60  *
61  */
62  explicit Solution(const Pgr_pickDeliver *p_problem) :
63  EPSILON(0.0001),
64  problem(p_problem)
65  {};
66 
67 
68  /* @brief move constructor */
69  Solution(const Solution && sol) :
70  EPSILON(0.0001),
71  fleet(std::move(sol.fleet)),
72  problem(std::move(sol.problem))
73  {};
74 
75  /* @brief copy constructor */
76  Solution(const Solution &sol) :
77  EPSILON(0.0001),
78  fleet(sol.fleet),
79  problem(sol.problem)
80  {};
81 
82  /* @brief move assignment */
83  Solution& operator = (const Solution && sol) {
84  EPSILON = 0.0001,
85  fleet = sol.fleet;
86  return *this;
87  };
88 
89  /* @brief copy assignment */
90  Solution& operator = (const Solution& sol) {
91  EPSILON = 0.0001,
92  fleet = sol.fleet;
93  return *this;
94  };
95 
96  std::string cost_str() const;
97  std::string tau(const std::string &title = "Tau") const;
98  friend std::ostream& operator<<(
99  std::ostream &log,
100  const Solution &solution);
101  bool operator <(const Solution &s_rhs) const;
102 
103  bool is_feasable() const;
104  double duration() const;
105  double wait_time() const;
106  double total_travel_time() const;
107  double total_service_time() const;
108  int twvTot() const;
109  int cvTot() const;
110  size_t fleet_size() const {return fleet.size();}
111 
112  /*
113  * Cost in terms of a tuple
114  * <0> time window violations
115  * <1> capacity violations
116  * <2> fleet size TODO
117  * <3> wait_time
118  * <4> duration
119  */
120  Vehicle::Cost cost() const;
121 };
122 
123 
124 } // namespace vrp
125 } // namespace pgrouting
bool is_feasable() const
Definition: solution.cpp:54
bool operator<(const Solution &s_rhs) const
Definition: solution.cpp:176
Solution(const Pgr_pickDeliver *p_problem)
Definition: solution.h:62
void get_postgres_result(std::vector< General_vehicle_orders_t > &result) const
Definition: solution.cpp:38
Vehicle::Cost cost() const
Definition: solution.cpp:117
Solution(const Solution &sol)
Definition: solution.h:76
std::deque< Vehicle_pickDeliver > fleet
Definition: solution.h:46
size_t fleet_size() const
Definition: solution.h:110
const Pgr_pickDeliver * problem
Definition: solution.h:49
PGDLLEXPORT Datum vrp(PG_FUNCTION_ARGS)
Definition: VRP.c:732
double wait_time() const
Definition: solution.cpp:81
std::string tau(const std::string &title="Tau") const
Definition: solution.cpp:151
friend std::ostream & operator<<(std::ostream &log, const Solution &solution)
Definition: solution.cpp:164
Solution & operator=(const Solution &&sol)
Definition: solution.h:83
double total_travel_time() const
Definition: solution.cpp:90
std::string cost_str() const
Definition: solution.cpp:136
double duration() const
Definition: solution.cpp:63
Solution(const Solution &&sol)
Definition: solution.h:69
double total_service_time() const
Definition: solution.cpp:99
std::tuple< int, int, size_t, double, double > Cost
Definition: vehicle.h:74