PGROUTING  3.2
solution.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: solution.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_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 
40 namespace pgrouting {
41 namespace vrp {
42 
43 
44 class Solution {
45  friend class Optimize;
46  friend class PD_problem;
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 
66  /* @brief copy constructor */
67  Solution(const Solution &sol) :
68  EPSILON(0.0001),
69  fleet(sol.fleet),
70  trucks(sol.trucks)
71  {};
72 
73  /* @brief copy assignment */
74  Solution& operator = (const Solution& sol) {
75  EPSILON = 0.0001,
76  fleet = sol.fleet;
77  trucks = sol.trucks;
78  return *this;
79  };
80 
81 
82  Initials_code get_kind() const;
83 
84  std::string cost_str() const;
85  std::string tau(const std::string &title = "Tau") const;
86  friend std::ostream& operator<<(
87  std::ostream &log,
88  const Solution &solution);
89  bool operator <(const Solution &s_rhs) const;
90 
91  bool is_feasable() const;
92  double duration() const;
93  double wait_time() const;
94  double total_travel_time() const;
95  double total_service_time() const;
96  int twvTot() const;
97  int cvTot() const;
98 
99  /*
100  * Cost in terms of a tuple
101  * <0> time window violations
102  * <1> capacity violations
103  * <2> fleet size TODO
104  * <3> wait_time
105  * <4> duration
106  */
107  Vehicle::Cost cost() const;
108 
110  static Pgr_messages& msg() ;
111 
112 private:
115 
116 };
117 
118 
119 } // namespace vrp
120 } // namespace pgrouting
121 
122 #endif // INCLUDE_VRP_SOLUTION_H_
pgrouting::vrp::Solution::tau
std::string tau(const std::string &title="Tau") const
Definition: solution.cpp:164
pgrouting::Pgr_messages
Definition: pgr_messages.h:39
pgrouting::vrp::Solution
Definition: solution.h:44
pgrouting::vrp::Fleet
Definition: fleet.h:47
pgrouting::vrp::Solution::is_feasable
bool is_feasable() const
Definition: solution.cpp:67
pgrouting::vrp::Solution::problem
static Pgr_pickDeliver * problem
this solution belongs to this problem
Definition: solution.h:114
pgrouting::vrp::Solution::trucks
Fleet trucks
Definition: solution.h:52
pgrouting::vrp::Solution::fleet
std::deque< Vehicle_pickDeliver > fleet
Definition: solution.h:49
pgrouting::vrp::Solution::EPSILON
double EPSILON
Definition: solution.h:48
pgrouting::vrp::Solution::get_postgres_result
std::vector< General_vehicle_orders_t > get_postgres_result() const
Definition: solution.cpp:42
pgrouting::vrp::Solution::cost
Vehicle::Cost cost() const
Definition: solution.cpp:130
pgrouting::vrp::Solution::cost_str
std::string cost_str() const
Definition: solution.cpp:149
pgrouting::vrp::Solution::cvTot
int cvTot() const
Definition: solution.cpp:121
pgrouting::vrp::Pgr_pickDeliver
Definition: pgr_pickDeliver.h:57
pgrouting::vrp::Solution::Solution
Solution(const Solution &sol)
Definition: solution.h:67
pgrouting::vrp::Solution::operator<
bool operator<(const Solution &s_rhs) const
Definition: solution.cpp:189
pgrouting::vrp::Solution::wait_time
double wait_time() const
Definition: solution.cpp:94
pgrouting::vrp::Solution::total_travel_time
double total_travel_time() const
Definition: solution.cpp:103
pgrouting::vrp::Solution::Solution
Solution()
Definition: solution.cpp:241
pgrouting::vrp::Solution::operator=
Solution & operator=(const Solution &sol)
Definition: solution.h:74
vehicle_pickDeliver.h
pgrouting::vrp::Solution::get_kind
Initials_code get_kind() const
Definition: solution.cpp:237
pgrouting::vrp::Solution::twvTot
int twvTot() const
Definition: solution.cpp:85
pgrouting::vrp::Solution::total_service_time
double total_service_time() const
Definition: solution.cpp:112
pgrouting::vrp::Solution::operator<<
friend std::ostream & operator<<(std::ostream &log, const Solution &solution)
Definition: solution.cpp:177
pgrouting::vrp::Solution::duration
double duration() const
Definition: solution.cpp:76
pgrouting::vrp::Optimize
Definition: optimize.h:41
pgrouting::vrp::PD_problem
Definition: pd_problem.h:42
pgrouting::vrp::Initials_code
Initials_code
Different kinds to insert an order into the vehicle.
Definition: initials_code.h:36
pgrouting::vrp::Vehicle::Cost
std::tuple< int, int, size_t, double, double > Cost
Definition: vehicle.h:90
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56
pgrouting::vrp::Solution::msg
static Pgr_messages & msg()
The problem's message.
Definition: solution.cpp:60
fleet.h