vrpRouting  0.3
pickDeliver.h
Go to the documentation of this file.
1 /*WC-GNU*****************************************************************
2 
3 FILE: pgr_pickDeliver.h
4 
5 Copyright (c) 2017 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  ********************************************************************WC-GNU*/
25 
28 #ifndef INCLUDE_PROBLEM_PICKDELIVER_H_
29 #define INCLUDE_PROBLEM_PICKDELIVER_H_
30 #pragma once
31 
32 
33 
34 #include <vector>
35 #include <utility>
37 #include "c_types/solution_rt.h"
39 #include "c_types/vehicle_t.h"
41 #include "problem/vehicle_node.h"
42 #include "problem/orders.h"
43 #include "problem/fleet.h"
44 #include "problem/matrix.h"
45 
46 namespace vrprouting {
47 namespace problem {
48 
50 class PickDeliver {
51  public:
54  PickDeliveryOrders_t* p_orders, size_t p_orders_size,
55  Vehicle_t* p_vehicles, size_t p_vehicles_size,
56  const Matrix &p_cost_matrix) :
57  m_cost_matrix(p_cost_matrix),
58  m_orders(p_orders, p_orders_size, this),
59  m_trucks(p_vehicles, p_vehicles_size, m_orders, m_nodes, m_node_id) {
60  if (!msg.get_error().empty()) return;
61  m_trucks.clean();
64  }
65 
68  PickDeliveryOrders_t* p_orders, size_t p_orders_size,
69  Vehicle_t* p_vehicles, size_t p_vehicles_size,
70  std::vector<Short_vehicle> new_stops,
71  const Matrix &p_cost_matrix) :
72  m_cost_matrix(p_cost_matrix),
73  m_orders(p_orders, p_orders_size, this),
74  m_trucks(p_vehicles, p_vehicles_size, new_stops, m_orders, m_nodes, m_node_id) {
75  if (!msg.get_error().empty()) return;
76  m_trucks.clean();
79  }
80 
81  virtual ~PickDeliver() = default;
82 
84  std::vector<CompatibleVehicles_rt> get_pg_compatibleVehicles() const {
85  std::vector<CompatibleVehicles_rt> result;
86  for (const auto& v : m_trucks) {
87  if (v.is_phony()) continue;
88  for (const auto o : v.feasible_orders()) {
89  result.push_back({m_orders[o].id(), v.id()});
90  }
91  }
92  return result;
93  }
94 
95  const Orders& orders() {return m_orders;}
96  const Fleet& vehicles() {return m_trucks;}
97 
100 
103  const Matrix& time_matrix() {return m_cost_matrix;}
104  size_t& node_id() {return m_node_id;}
105 
106 
108  void add_node(const Vehicle_node &node) {m_nodes.push_back(node);}
109 
110  private:
118  size_t m_node_id = 0;
119 
124  std::vector<Vehicle_node> m_nodes { };
125 
126  protected:
129 
130 
133 };
134 
135 } // namespace problem
136 } // namespace vrprouting
137 
138 #endif // INCLUDE_PROBLEM_PICKDELIVER_H_
pickDeliveryOrders_t.h
vrprouting::problem::PickDeliver::m_trucks
Fleet m_trucks
the set of vehicles
Definition: pickDeliver.h:132
vrprouting::problem::PickDeliver::orders
const Orders & orders()
Definition: pickDeliver.h:95
pgr_messages.h
vehicle_t.h
vrprouting::problem::Fleet
Definition: fleet.h:52
PickDeliveryOrders_t
order's attributes
Definition: pickDeliveryOrders_t.h:56
vrprouting::problem::PickDeliver::~PickDeliver
virtual ~PickDeliver()=default
vehicle_node.h
vrprouting::problem::PickDeliver
the pick deliver problem
Definition: pickDeliver.h:50
vrprouting::problem::PickDeliver::get_pg_compatibleVehicles
std::vector< CompatibleVehicles_rt > get_pg_compatibleVehicles() const
get the vehicles compatibility results as C++ container
Definition: pickDeliver.h:84
Vehicle_t
vehicles's attributes
Definition: vehicle_t.h:50
compatibleVehicles_rt.h
vrprouting::problem::PickDeliver::PickDeliver
PickDeliver(PickDeliveryOrders_t *p_orders, size_t p_orders_size, Vehicle_t *p_vehicles, size_t p_vehicles_size, const Matrix &p_cost_matrix)
General Constructor.
Definition: pickDeliver.h:53
vrprouting::problem::PickDeliver::m_nodes
std::vector< Vehicle_node > m_nodes
set of vehicle nodes
Definition: pickDeliver.h:124
vrprouting::problem::Orders::set_compatibles
void set_compatibles(Speed=1.0)
set the compatability between all orders
Definition: orders.cpp:128
vrprouting::problem::Orders
Definition: orders.h:48
matrix.h
vrprouting::problem::PickDeliver::msg
Pgr_messages msg
message controller for all classes
Definition: pickDeliver.h:99
vrprouting::problem::Matrix
Definition: matrix.h:46
vrprouting::problem::Fleet::set_compatibles
void set_compatibles(const Orders &orders)
sets the compatability of orders on the fleet
Definition: fleet.cpp:313
vrprouting::problem::Vehicle_node
Extend Tw_node to evaluate the vehicle at node level.
Definition: vehicle_node.h:49
vrprouting::problem::PickDeliver::node_id
size_t & node_id()
Definition: pickDeliver.h:104
vrprouting::Pgr_messages::get_error
std::string get_error() const
gets the contents of error message
Definition: pgr_messages.cpp:53
vrprouting::problem::PickDeliver::vehicles
const Fleet & vehicles()
Definition: pickDeliver.h:96
vrprouting::problem::PickDeliver::time_matrix
const Matrix & time_matrix()
Definition: pickDeliver.h:103
vrprouting::problem::PickDeliver::m_cost_matrix
const Matrix & m_cost_matrix
the cost matrix
Definition: pickDeliver.h:102
solution_rt.h
vrprouting::Pgr_messages
Messages Handling.
Definition: pgr_messages.h:52
vrprouting::problem::PickDeliver::m_node_id
size_t m_node_id
used to keep track of the next index the node gets
Definition: pickDeliver.h:118
orders.h
vrprouting::problem::PickDeliver::m_orders
Orders m_orders
the set of orders
Definition: pickDeliver.h:128
vrprouting::problem::PickDeliver::add_node
void add_node(const Vehicle_node &node)
add a node to the set of nodes
Definition: pickDeliver.h:108
vrprouting::problem::Fleet::clean
void clean()
removes from fleet all invalid vehicles
Definition: fleet.cpp:107
vrprouting::problem::PickDeliver::PickDeliver
PickDeliver(PickDeliveryOrders_t *p_orders, size_t p_orders_size, Vehicle_t *p_vehicles, size_t p_vehicles_size, std::vector< Short_vehicle > new_stops, const Matrix &p_cost_matrix)
Override stops constructor.
Definition: pickDeliver.h:67
vrprouting
Definition: base_matrix.cpp:46
fleet.h