PGROUTING  3.2
book_keeping.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2  *
3  * FILE: book_keeping.h
4  *
5  * Copyright (c) 2017 pgRouting developers
6  * Mail: [email protected]
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_BOOK_KEEPING_H_
29 #define INCLUDE_VRP_BOOK_KEEPING_H_
30 #pragma once
31 
32 #include <queue>
33 #include <vector>
34 #include <iostream>
40 namespace pgrouting {
41 namespace vrp {
42 
43 class Swap_bk;
44 class Swap_info {
45  friend class Swap_bk;
46 
47  public:
48  Swap_info() = delete;
49  Swap_info(const Swap_info &) = default;
50  Swap_info(const Vehicle_pickDeliver &from,
51  const Vehicle_pickDeliver &to,
52  size_t from_o,
53  size_t to_o,
54  double delta);
55  friend std::ostream& operator << (std::ostream& log, const Swap_info &d);
56 #if 0
57  {
58  log
59  << "\n" << d.from_truck.tau() << " --> "
60  << d.from_order
61  << "("
62  << d.from_truck.orders()[d.from_order].pickup().original_id()
63  << ")"
64  << "\n" << d.to_truck.tau() << " --> "
65  << d.to_order
66  << "("
67  << d.to_truck.orders()[d.to_order].pickup().original_id()
68  << ")"
69  << "\n" << "delta = " << d.estimated_delta;
70  return log;
71  }
72 #endif
73 
74  public:
77  size_t from_order;
78  size_t to_order;
80 };
81 
82 
83 class Swap_bk {
84  private:
85  class Compare {
86  public:
87  bool operator() (const Swap_info &lhs, const Swap_info rhs) {
88  return lhs.estimated_delta > rhs.estimated_delta;
89  }
90  };
91 
92  public:
93  typedef std::priority_queue<
94  Swap_info,
95  std::vector<Swap_info>,
97 
98 
100  friend std::ostream& operator<< (std::ostream &log, const Swap_bk &data);
101 
102  public:
103  Swap_bk() = default;
104  Swap_bk(const Swap_bk &bk) = default;
106  void push(const Swap_info& data) {m_swaps.push(data);}
107  Swap_info top() {return m_swaps.top();}
108  void pop() {return m_swaps.pop();}
109  bool empty() {return m_swaps.empty();}
110 };
111 
112 } // namespace vrp
113 } // namespace pgrouting
114 
115 #endif // INCLUDE_VRP_BOOK_KEEPING_H_
pgrouting::vrp::Swap_bk::push
void push(const Swap_info &data)
Definition: book_keeping.h:106
pgrouting::vrp::Swap_info::Swap_info
Swap_info()=delete
pgrouting::vrp::Swap_bk::Swaps_queue
std::priority_queue< Swap_info, std::vector< Swap_info >, Compare > Swaps_queue
Definition: book_keeping.h:96
pgrouting::vrp::Swap_info
Definition: book_keeping.h:44
pgrouting::vrp::Swap_info::from_order
size_t from_order
Definition: book_keeping.h:77
pgrouting::vrp::Vehicle_pickDeliver
Definition: vehicle_pickDeliver.h:47
pgrouting::vrp::Swap_info::estimated_delta
double estimated_delta
Definition: book_keeping.h:79
pgrouting::vrp::Swap_bk::possible_swaps
Swaps_queue & possible_swaps()
Definition: book_keeping.h:105
pgrouting::vrp::Swap_bk::empty
bool empty()
Definition: book_keeping.h:109
pgrouting::vrp::Swap_info::from_truck
Vehicle_pickDeliver from_truck
Definition: book_keeping.h:75
pgrouting::vrp::Swap_info::to_order
size_t to_order
Definition: book_keeping.h:78
pgrouting::vrp::Swap_bk::m_swaps
Swaps_queue m_swaps
Definition: book_keeping.h:99
pgrouting::vrp::Swap_bk::pop
void pop()
Definition: book_keeping.h:108
vehicle_pickDeliver.h
pgrouting::vrp::Swap_bk
Definition: book_keeping.h:83
pgrouting::vrp::Swap_info::to_truck
Vehicle_pickDeliver to_truck
Definition: book_keeping.h:76
pgrouting::vrp::Swap_bk::Swap_bk
Swap_bk()=default
pgrouting::vrp::Swap_info::operator<<
friend std::ostream & operator<<(std::ostream &log, const Swap_info &d)
Definition: book_keeping.cpp:47
pgrouting::vrp::Swap_bk::top
Swap_info top()
Definition: book_keeping.h:107
pgrouting::vrp::Swap_bk::Compare::operator()
bool operator()(const Swap_info &lhs, const Swap_info rhs)
Definition: book_keeping.h:87
pgrouting::vrp::Swap_bk::Compare
Definition: book_keeping.h:85
pgrouting::vrp::Swap_bk::operator<<
friend std::ostream & operator<<(std::ostream &log, const Swap_bk &data)
Definition: book_keeping.cpp:63
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56