PGROUTING  2.6-dev
pd_orders.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: pd_orders.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_PD_ORDERS_H_
29 #define INCLUDE_VRP_PD_ORDERS_H_
30 #pragma once
31 
32 #include <vector>
33 #include <memory>
34 #include <utility>
35 
38 
39 #include "vrp/base_node.h"
40 #include "vrp/pd_problem.h"
41 
42 
43 namespace pgrouting {
44 namespace vrp {
45 
46 class Order;
47 class Vehicle_node;
48 
49 class PD_Orders : public PD_problem {
50  typedef std::vector<Order> Orders;
51 
52  public:
53  typedef Orders::iterator o_iterator;
54  typedef Orders::const_iterator o_const_iterator;
55 
56  public:
60  PD_Orders() = default;
61  PD_Orders(const PD_Orders&) = default;
62  explicit PD_Orders(const std::vector<PickDeliveryOrders_t>&);
65  void set_compatibles(double speed);
66  size_t find_best_J(Identifiers<size_t> &within_this_set) const;
67  size_t find_best_I(Identifiers<size_t> &within_this_set) const;
68 
69 
70  bool is_valid(double speed) const;
71 
76  Order& operator[](size_t o);
77  const Order& operator[](size_t o) const;
78  size_t size() const {return m_orders.size();}
79  o_iterator begin() {return m_orders.begin();}
80  o_iterator end() {return m_orders.end();}
81  o_const_iterator begin() const {return m_orders.begin();}
82  o_const_iterator end() const {return m_orders.end();}
85  private:
86  void build_orders(
87  const std::vector<PickDeliveryOrders_t> &pd_orders);
88 
89  void add_order(
90  const PickDeliveryOrders_t &,
91  std::unique_ptr<Base_node>,
92  const Vehicle_node&,
93  std::unique_ptr<Base_node>,
94  const Vehicle_node&);
95 
96  template <typename T> std::unique_ptr<Base_node> create_b_pick(
97  const PickDeliveryOrders_t &order,
98  size_t node_id) {
99  std::unique_ptr<Base_node> b_pick(new T(
100  node_id,
101  order.pick_node_id,
102  order.pick_x,
103  order.pick_y));
104  return std::move(b_pick);
105  }
106 
107  template <typename T> std::unique_ptr<Base_node> create_b_deliver(
108  const PickDeliveryOrders_t &order,
109  size_t node_id) {
110  std::unique_ptr<Base_node> b_drop(new T(
111  node_id,
112  order.deliver_node_id,
113  order.deliver_x,
114  order.deliver_y));
115  return std::move(b_drop);
116  }
117 
118  private:
119  Orders m_orders;
120 };
121 
122 } // namespace vrp
123 } // namespace pgrouting
124 
125 #endif // INCLUDE_VRP_PD_ORDERS_H_
void build_orders(const std::vector< PickDeliveryOrders_t > &pd_orders)
Definition: pd_orders.cpp:69
o_const_iterator end() const
Definition: pd_orders.h:82
Orders::const_iterator o_const_iterator
Definition: pd_orders.h:54
std::unique_ptr< Base_node > create_b_deliver(const PickDeliveryOrders_t &order, size_t node_id)
Definition: pd_orders.h:107
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:48
std::unique_ptr< Base_node > create_b_pick(const PickDeliveryOrders_t &order, size_t node_id)
Definition: pd_orders.h:96
std::vector< Order > Orders
Definition: pd_orders.h:50
o_const_iterator begin() const
Definition: pd_orders.h:81
size_t find_best_J(Identifiers< size_t > &within_this_set) const
Definition: pd_orders.cpp:165
size_t find_best_I(Identifiers< size_t > &within_this_set) const
Definition: pd_orders.cpp:184
size_t size() const
Definition: pd_orders.h:78
Orders::iterator o_iterator
Definition: pd_orders.h:53
Book keeping class for swapping orders between vehicles.
Definition: basic_edge.cpp:28
Order & operator[](size_t o)
Definition: pd_orders.cpp:144
void set_compatibles(double speed)
Definition: pd_orders.cpp:156
bool is_valid(double speed) const
Definition: pd_orders.cpp:130
void add_order(const PickDeliveryOrders_t &, std::unique_ptr< Base_node >, const Vehicle_node &, std::unique_ptr< Base_node >, const Vehicle_node &)
Definition: pd_orders.cpp:47