diff --git a/include/cpp_common/messages.hpp b/include/cpp_common/messages.hpp index dc42f527a..fff61ebcf 100644 --- a/include/cpp_common/messages.hpp +++ b/include/cpp_common/messages.hpp @@ -101,8 +101,8 @@ class Messages { #define ENTERING(x) #define EXITING(x) #else -#define ENTERING(x) x.log << "\n--> " << __PRETTY_FUNCTION__ << "\n" -#define EXITING(x) x.log << "\n<-- " << __PRETTY_FUNCTION__ << "\n" +#define ENTERING(x) x << "\n--> " << __PRETTY_FUNCTION__ << "\n" +#define EXITING(x) x << "\n<-- " << __PRETTY_FUNCTION__ << "\n" #endif diff --git a/include/cpp_common/short_vehicle.hpp b/include/cpp_common/short_vehicle.hpp index 4720e9f3e..b520ab2b9 100644 --- a/include/cpp_common/short_vehicle.hpp +++ b/include/cpp_common/short_vehicle.hpp @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include "c_types/typedefs.h" +namespace vrprouting { + /** @brief short_vehicle @note C/C++/postgreSQL connecting structure for input @@ -38,10 +40,12 @@ name | description id | Vehicle's identifier stops | Vehicle's stops */ -struct Short_vehicle{ - Id id; /** Vehicle's identifier */ - std::vector stops; /** Stops */ +class Short_vehicle{ + public: + Id id; /** Vehicle's identifier */ + std::vector stops; /** Stops */ }; +} // namespace vrprouting #endif // INCLUDE_CPP_COMMON_SHORT_VEHICLE_HPP_ diff --git a/include/initialsol/simple.hpp b/include/initialsol/simple.hpp index ac31a71f4..e4d98d9fe 100644 --- a/include/initialsol/simple.hpp +++ b/include/initialsol/simple.hpp @@ -45,7 +45,7 @@ namespace simple { class Initial_solution : public problem::Solution { public: Initial_solution() = delete; - Initial_solution(Initials_code, problem::PickDeliver*); + Initial_solution(Initials_code, problem::PickDeliver&); void invariant() const; @@ -55,7 +55,7 @@ class Initial_solution : public problem::Solution { */ void one_truck_all_orders(); - void do_while_foo(int kind); + void do_while_foo(Initials_code); void do_while_feasible( problem::Vehicle_pickDeliver& truck, diff --git a/include/initialsol/tabu.hpp b/include/initialsol/tabu.hpp index c0b96f619..caeca10ca 100644 --- a/include/initialsol/tabu.hpp +++ b/include/initialsol/tabu.hpp @@ -48,7 +48,7 @@ class Initial_solution : public problem::Solution { Initial_solution() = delete; /** @brief Creating a complete initial solution */ - Initial_solution(TTimestamp, bool, problem::PickDeliver*); + Initial_solution(TTimestamp, bool, problem::PickDeliver&); private: using Solution::vehicles; diff --git a/include/problem/fleet.hpp b/include/problem/fleet.hpp index 1de81e793..dbe237f71 100644 --- a/include/problem/fleet.hpp +++ b/include/problem/fleet.hpp @@ -33,22 +33,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include -#include "c_types/typedefs.h" -#include "cpp_common/short_vehicle.hpp" #include "problem/vehicle_pickDeliver.hpp" -typedef struct Vehicle_t Vehicle_t; - namespace vrprouting { class Messages; +class Short_vehicle; namespace problem { class Orders; class Vehicle_node; -/* - * PVR = pnode - */ class Fleet: protected std::vector { public: using std::vector::begin; @@ -59,21 +53,17 @@ class Fleet: protected std::vector { /** @brief Create a fleet based on the Vehicles of the problem */ Fleet( - Vehicle_t* vehicles , size_t size_vehicles, - const Orders& p_orders, std::vector& p_nodes, size_t& node_id) - : m_used(), - m_unused() { - build_fleet(vehicles, size_vehicles, {}, p_orders, p_nodes, node_id); - } + Vehicle_t* , size_t, + const Orders&, + std::vector&, size_t&); /** @brief Create a fleet based on the Vehicles of the problem */ - Fleet(Vehicle_t* vehicles , size_t size_vehicles, - const std::vector &new_stops, - const Orders& p_orders, std::vector& p_nodes, size_t& node_id) - : m_used(), - m_unused() { - build_fleet(vehicles, size_vehicles, new_stops, p_orders, p_nodes, node_id); - } + Fleet( + Vehicle_t*, size_t, + const std::vector&, + const Orders&, + std::vector&, + size_t&); /** @brief creating a fleet without information is not allowed */ Fleet() = delete; @@ -131,9 +121,10 @@ class Fleet: protected std::vector { /** @brief build the fleet */ void build_fleet( - Vehicle_t*, size_t, const std::vector&, + Vehicle_t*, size_t, + const std::vector&, const Orders&, - std::vector& p_nodes, size_t& node_id); + std::vector&, size_t&); void invariant() const; diff --git a/include/problem/matrix.hpp b/include/problem/matrix.hpp index 25a59c5af..428dfc5d3 100644 --- a/include/problem/matrix.hpp +++ b/include/problem/matrix.hpp @@ -30,15 +30,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #pragma once #include -#include -#include #include #include #include "cpp_common/base_matrix.hpp" #include "cpp_common/identifiers.hpp" -#include "c_types/typedefs.h" +using Time_multipliers_t = struct Time_multipliers_t; namespace vrprouting { namespace problem { @@ -50,9 +48,6 @@ class Matrix : public base::Base_Matrix { /** brief constructor for matrix version with time dependant multipliers */ Matrix(Matrix_cell_t *, size_t, Time_multipliers_t*, size_t, const Identifiers&, Multiplier = 1.0); - /** brief constructor for euclidean version with time dependant multipliers */ - Matrix(const std::map, Id>&, Time_multipliers_t*, size_t, Multiplier = 1.0); - /** brief constructor for matrix version default multipliers */ Matrix(Matrix_cell_t *, size_t, const Identifiers&, Multiplier = 1.0); diff --git a/include/problem/order.hpp b/include/problem/order.hpp index 762101cca..524cd550e 100644 --- a/include/problem/order.hpp +++ b/include/problem/order.hpp @@ -46,13 +46,7 @@ class Order : public Identifier { Order() = delete; /** @brief initializing an order with the pick & drop information */ - Order(Idx o_idx, Id o_id, - const Vehicle_node &p_pickup, - const Vehicle_node &p_delivery) : - Identifier(o_idx, o_id), - m_pickup(p_pickup), - m_delivery(p_delivery) { - } + Order(Idx, Id, const Vehicle_node&, const Vehicle_node&); /** @name Accessors * @{ diff --git a/include/problem/orders.hpp b/include/problem/orders.hpp index dd98b5ef5..72077c50a 100644 --- a/include/problem/orders.hpp +++ b/include/problem/orders.hpp @@ -45,17 +45,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. namespace vrprouting { namespace problem { +class PickDeliver; + class Orders : public std::vector { public: using std::vector::size; Orders() = default; - // todo remove template its problem::PickDeliver - template - Orders(Orders_t* p_orders, size_t p_size_orders, const PTR problem_ptr) { - Tw_node::m_time_matrix_ptr = &problem_ptr->time_matrix(); - build_orders(p_orders, p_size_orders, problem_ptr); - } + Orders(Orders_t* , size_t, PickDeliver&); /** @brief find the best order -> @b this */ size_t find_best_I(const Identifiers &within_this_set) const; @@ -80,8 +77,7 @@ class Orders : public std::vector { } private: - template - void build_orders(Orders_t *, size_t, const PTR problem_ptr); + void build_orders(Orders_t *, size_t, PickDeliver&); /** @brief add in an order */ void add_order(const Orders_t &order, @@ -91,42 +87,6 @@ class Orders : public std::vector { } }; -/** - @param [in] orders - @param [in] size_orders - @param [in] problem_ptr pointer to problem to get some needed information - */ -template -void -Orders::build_orders(Orders_t *orders, size_t size_orders, const PTR problem_ptr) { - /** - * - Sort orders: ASC pick_open_t, deliver_close_t, id - */ - std::sort(orders, orders + size_orders, - [] (const Orders_t &lhs, const Orders_t &rhs) { - if (lhs.pick_open_t == rhs.pick_open_t) { - if (lhs.deliver_close_t == rhs.deliver_close_t) { - return lhs.id < rhs.id; - } else { - return lhs.deliver_close_t < rhs.deliver_close_t; - } - } else { - return lhs.pick_open_t < rhs.pick_open_t; - } - }); - - for (size_t i = 0; i < size_orders; ++i) { - auto order = orders[i]; - Vehicle_node pick({problem_ptr->node_id()++, order, NodeType::kPickup}); - Vehicle_node drop({problem_ptr->node_id()++, order, NodeType::kDelivery}); - - problem_ptr->add_node(pick); - problem_ptr->add_node(drop); - - this->emplace_back(Order{size(), order.id, pick, drop}); - } -} - } // namespace problem } // namespace vrprouting diff --git a/include/problem/pickDeliver.hpp b/include/problem/pickDeliver.hpp index fac81e3ae..5140cd5b1 100644 --- a/include/problem/pickDeliver.hpp +++ b/include/problem/pickDeliver.hpp @@ -29,23 +29,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #define INCLUDE_PROBLEM_PICKDELIVER_HPP_ #pragma once - - #include #include -#include "c_types/compatibleVehicles_rt.h" -#include "c_types/solution_rt.h" -#include "cpp_common/orders_t.hpp" -#include "cpp_common/vehicle_t.hpp" + #include "cpp_common/messages.hpp" -#include "problem/vehicle_node.hpp" #include "problem/orders.hpp" #include "problem/fleet.hpp" -#include "problem/matrix.hpp" + +using CompatibleVehicles_rt = struct CompatibleVehicles_rt; +using Orders_t = struct Orders_t; +using Vehicle_t = struct Vehicle_t; namespace vrprouting { + +class Short_vehicle; + namespace problem { +class Matrix; +class Vehicle_node; + + /** @brief the pick deliver problem */ class PickDeliver { public: @@ -53,44 +57,19 @@ class PickDeliver { PickDeliver( Orders_t* p_orders, size_t p_orders_size, Vehicle_t* p_vehicles, size_t p_vehicles_size, - const Matrix &p_cost_matrix) : - m_cost_matrix(p_cost_matrix), - m_orders(p_orders, p_orders_size, this), - m_trucks(p_vehicles, p_vehicles_size, m_orders, m_nodes, m_node_id) { - if (!msg.get_error().empty()) return; - m_trucks.clean(); - m_orders.set_compatibles(); - m_trucks.set_compatibles(m_orders); - } + const Matrix &p_cost_matrix); /** @brief Override stops constructor */ PickDeliver( Orders_t* p_orders, size_t p_orders_size, Vehicle_t* p_vehicles, size_t p_vehicles_size, std::vector new_stops, - const Matrix &p_cost_matrix) : - m_cost_matrix(p_cost_matrix), - m_orders(p_orders, p_orders_size, this), - m_trucks(p_vehicles, p_vehicles_size, new_stops, m_orders, m_nodes, m_node_id) { - if (!msg.get_error().empty()) return; - m_trucks.clean(); - m_orders.set_compatibles(); - m_trucks.set_compatibles(m_orders); - } + const Matrix &p_cost_matrix); virtual ~PickDeliver() = default; /** @brief get the vehicles compatibility results as C++ container */ - std::vector get_pg_compatibleVehicles() const { - std::vector result; - for (const auto& v : m_trucks) { - if (v.is_phony()) continue; - for (const auto o : v.feasible_orders()) { - result.push_back({m_orders[o].id(), v.id()}); - } - } - return result; - } + std::vector get_pg_compatibleVehicles() const; const Orders& orders() {return m_orders;} const Fleet& vehicles() {return m_trucks;} @@ -100,7 +79,7 @@ class PickDeliver { /** the cost matrix */ const Matrix& m_cost_matrix; - const Matrix& time_matrix() {return m_cost_matrix;} + const Matrix& time_matrix() const {return m_cost_matrix;} size_t& node_id() {return m_node_id;} diff --git a/include/problem/solution.hpp b/include/problem/solution.hpp index ce40056bd..db2ce81a0 100644 --- a/include/problem/solution.hpp +++ b/include/problem/solution.hpp @@ -38,27 +38,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include +#include "cpp_common/messages.hpp" #include "problem/vehicle_pickDeliver.hpp" +#include "problem/orders.hpp" #include "problem/fleet.hpp" -#include "cpp_common/short_vehicle.hpp" -typedef struct Solution_rt Solution_rt; +using Solution_rt = struct Solution_rt; namespace vrprouting { + +class Messages; +class Short_vehicle; + namespace problem { -class Solution { +class Orders; +class Fleet; +class Vehicle_pickDeliver; + +class Solution : public Messages { public: /** @brief constructor */ Solution() = delete; /** @brief constructor */ - template - explicit Solution(P* p_problem) : - m_orders(p_problem->orders()), - m_trucks(p_problem->vehicles()), - m_msg(p_problem->msg) { } - + explicit Solution(PickDeliver &p_problem); /** @brief copy constructor */ Solution(const Solution &sol) = default; @@ -73,11 +77,7 @@ class Solution { std::vector get_postgres_result() const; /** @brief printing function */ - friend std::ostream& operator<< (std::ostream &log, const Solution &solution) { - for (const auto& vehicle : solution.m_fleet) log << vehicle; - log << "\n SOLUTION:\n\n " << solution.tau(); - return log; - } + friend std::ostream& operator<< (std::ostream &log, const Solution &solution); /** @brief writing the solution in compact form into a string */ std::string tau(const std::string &title = "Tau") const; @@ -107,7 +107,7 @@ class Solution { const std::deque& fleet() const {return m_fleet;} /** @brief Get the value of the objective function */ - double objective() const {return static_cast(total_travel_time());} + double objective() const; /** @brief Get all statistics in one cycle */ std::tuple cost() const; @@ -116,7 +116,6 @@ class Solution { bool operator<(const Solution&) const; - Messages& msg() {return m_msg;} const Orders& orders() const {return m_orders;} Fleet& vehicles() {return m_trucks;} diff --git a/include/problem/vehicle.hpp b/include/problem/vehicle.hpp index 50d8b38b2..f6d8cbc67 100644 --- a/include/problem/vehicle.hpp +++ b/include/problem/vehicle.hpp @@ -23,8 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ********************************************************************PGR-GNU*/ -/*! @file */ - #ifndef INCLUDE_PROBLEM_VEHICLE_HPP_ #define INCLUDE_PROBLEM_VEHICLE_HPP_ #pragma once @@ -35,8 +33,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include "c_types/solution_rt.h" + #include "cpp_common/assert.hpp" #include "cpp_common/identifier.hpp" +#include "cpp_common/messages.hpp" #include "problem/vehicle_node.hpp" namespace vrprouting { @@ -58,7 +58,7 @@ namespace problem { * has: * @b capacity */ -class Vehicle : public Identifier, protected std::deque { +class Vehicle : public Messages, public Identifier, protected std::deque { public: /** @brief the speed of the vehicle */ diff --git a/include/problem/vehicle_node.hpp b/include/problem/vehicle_node.hpp index bb46b980f..1a47ad7d4 100644 --- a/include/problem/vehicle_node.hpp +++ b/include/problem/vehicle_node.hpp @@ -49,8 +49,7 @@ namespace problem { class Vehicle_node: public Tw_node { public: /** @brief Print the contents of a Vehicle_node object. */ - friend std::ostream& operator<<( - std::ostream &log, const Vehicle_node &v); + friend std::ostream& operator<<(std::ostream &log, const Vehicle_node &v); /** @brief Construction without information is not allowed */ Vehicle_node() = delete; diff --git a/include/problem/vehicle_pickDeliver.hpp b/include/problem/vehicle_pickDeliver.hpp index cd176e75b..0fdc817d8 100644 --- a/include/problem/vehicle_pickDeliver.hpp +++ b/include/problem/vehicle_pickDeliver.hpp @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include -#include "c_types/typedefs.h" + #include "cpp_common/assert.hpp" #include "cpp_common/messages.hpp" #include "cpp_common/identifiers.hpp" @@ -40,8 +40,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. namespace vrprouting { namespace problem { + class Order; -class Orders; class Vehicle_pickDeliver : public Vehicle { public: @@ -56,26 +56,8 @@ class Vehicle_pickDeliver : public Vehicle { using Vehicle::at; using Vehicle::empty; - /** - * @returns The vehicle's information on the log - * @param [in,out] log place to store the vehicle's information - * @param [in] v the vehicle to work with - */ - friend std::ostream& operator<< (std::ostream &log, const Vehicle_pickDeliver &v) { - int i(0); - log << "\n\n****************** " << v.idx() << "th VEHICLE*************\n"; - log << "id = " << v.id() - << "\tcapacity = " << v.capacity() << "\n"; - - for (const auto &path_stop : v) { - log << "Path_stop" << ++i << "\n"; - log << path_stop << "\n"; - } - - log << v.feasible_orders() << "\n"; - return log; - } - + /** @returns The vehicle's information on the log */ + friend std::ostream& operator<< (std::ostream &log, const Vehicle_pickDeliver &v); Vehicle_pickDeliver() = delete; Vehicle_pickDeliver( @@ -86,14 +68,7 @@ class Vehicle_pickDeliver : public Vehicle { const std::vector& p_stops, PAmount p_capacity, Speed p_speed, - const Orders& p_orders) : - Vehicle(p_idx, p_id, p_starting_site, p_ending_site, p_capacity, p_speed), - m_cost((std::numeric_limits::max)()), - m_orders_in_vehicle(), - m_feasible_orders(), - m_orders(p_orders), - m_stops(p_stops) {} - + const Orders& p_orders); /** @brief returns the set of feasible orders for modification*/ Identifiers& feasible_orders() {return m_feasible_orders;} @@ -126,11 +101,7 @@ class Vehicle_pickDeliver : public Vehicle { size_t pop_back(); size_t pop_front(); - // TODO(pending): move code to cpp file - Order get_first_order() const { - pgassert(!empty()); - return orders()[at(1).idx()]; - } + Order get_first_order() const; /** @brief Get the value of the objective function */ double objective() const; @@ -144,9 +115,7 @@ class Vehicle_pickDeliver : public Vehicle { bool is_order_feasible(const Order &order) const; - const Orders& orders() const {pgassert(m_orders.size() != 0); return m_orders;} - - Messages& msg() {return m_msg;} + const Orders& orders() const; protected: using Vehicle::begin; @@ -164,8 +133,6 @@ class Vehicle_pickDeliver : public Vehicle { Orders m_orders; - Messages m_msg; - private: /** * order ids of an initial solution given by the user diff --git a/include/vroom/vroom.hpp b/include/vroom/vroom.hpp index 54d1cf76f..0569f248c 100644 --- a/include/vroom/vroom.hpp +++ b/include/vroom/vroom.hpp @@ -49,24 +49,26 @@ namespace vrprouting { namespace problem { class Vroom : public vrprouting::Messages { + using MapTW = std::vector; + public: /** @brief sets m_jobs by adding the Vroom_job_t */ void add_jobs( const std::vector&, - const std::vector&); + const MapTW&); void add_jobs(const Vroom_job_t*, size_t, const Vroom_time_window_t*, size_t); /** @brief sets m_shipments by adding the Vroom_shipment_t */ void add_shipments( const std::vector&, - const std::vector&); + const MapTW&); void add_shipments(const Vroom_shipment_t*, size_t, const Vroom_time_window_t*, size_t); /** @brief sets m_vehicles by adding the Vroom_vehicle_t */ void add_vehicles( const std::vector&, const std::vector&, - const std::vector&); + const MapTW&); void add_vehicles(const Vroom_vehicle_t*, size_t, const Vroom_break_t*, size_t, const Vroom_time_window_t*, size_t); /** @brief sets m_matrix */ @@ -94,10 +96,10 @@ class Vroom : public vrprouting::Messages { const Vroom_vehicle_t&, const std::vector&, const std::vector&) const; - void get_amount(::vroom::Amount, Amount**); - StepType get_job_step_type(::vroom::JOB_TYPE); - StepType get_step_type(::vroom::Step); - std::vector get_results(::vroom::Solution); + void get_amount(const ::vroom::Amount&, Amount**); + StepType get_job_step_type(const ::vroom::JOB_TYPE&); + StepType get_step_type(const ::vroom::Step&); + std::vector get_results(const ::vroom::Solution&); private: std::vector<::vroom::Job> m_jobs; diff --git a/src/initialsol/simple.cpp b/src/initialsol/simple.cpp index d0f4cfb57..abcf572c7 100644 --- a/src/initialsol/simple.cpp +++ b/src/initialsol/simple.cpp @@ -46,13 +46,13 @@ Initial_solution::invariant() const { Initial_solution::Initial_solution( Initials_code kind, - problem::PickDeliver* problem_ptr) : + problem::PickDeliver &problem_ptr) : problem::Solution(problem_ptr), all_orders(m_orders.size()), unassigned(m_orders.size()), assigned() { invariant(); - pgassert(kind >= 0 && kind <= OneDepot); + pgassert(kind >= OneTruck && kind <= OneDepot); switch (kind) { case OneTruck: @@ -74,9 +74,10 @@ Initial_solution::Initial_solution( } void -Initial_solution::do_while_foo(int kind) { +Initial_solution::do_while_foo(Initials_code kind) { invariant(); - pgassert(kind > 0 && kind <= OneDepot); + pgassert(kind != OneTruck); + pgassert(kind > OneTruck && kind <= OneDepot); Identifiers notused; @@ -87,21 +88,20 @@ Initial_solution::do_while_foo(int kind) { * kind 1 to 7 work with the same code structure */ do_while_feasible(truck, (Initials_code)kind, unassigned, assigned); - pgassertwm(current > unassigned.size(), msg().get_log().c_str()); + pgassertwm(current > unassigned.size(), get_log().c_str()); m_fleet.push_back(truck); invariant(); } - pgassertwm(true, msg().get_log().c_str()); - pgassert(is_feasible()); + pgassertwm(true, get_log().c_str()); invariant(); } void Initial_solution::one_truck_all_orders() { invariant(); - msg().log << "\nInitial_solution::one_truck_all_orders\n"; + log << "\nInitial_solution::one_truck_all_orders\n"; auto truck = vehicles().get_truck(); while (!unassigned.empty()) { auto order(truck.orders().at(*unassigned.begin())); diff --git a/src/initialsol/tabu.cpp b/src/initialsol/tabu.cpp index 42e152e98..13f18d295 100644 --- a/src/initialsol/tabu.cpp +++ b/src/initialsol/tabu.cpp @@ -60,7 +60,7 @@ Initial_solution::invariant() const { Initial_solution::Initial_solution( TTimestamp execution_date, bool optimize, - problem::PickDeliver* problem_ptr) : + problem::PickDeliver &problem_ptr) : Solution(problem_ptr), m_all_orders(), m_unassigned(), @@ -182,7 +182,7 @@ Initial_solution::process_unassigned() { phony_v.push_back(orders()[o]); m_unassigned -= o; m_all_orders -= o; - msg().error << "\n**Illegal Order** pick.opens() + tt > drop.closes() can not be inserted on any vehicle"; + error << "\n**Illegal Order** pick.opens() + tt > drop.closes() can not be inserted on any vehicle"; continue; } diff --git a/src/optimize/optimize_driver.cpp b/src/optimize/optimize_driver.cpp index 4b0b8de2a..d9c90040d 100644 --- a/src/optimize/optimize_driver.cpp +++ b/src/optimize/optimize_driver.cpp @@ -53,6 +53,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. namespace { +using Short_vehicle = vrprouting::Short_vehicle; + /** @brief Executes an optimization with the input data * * @param[in] shipments_arr A C Array of pickup and dropoff shipments @@ -97,7 +99,7 @@ one_processing( */ using Initial_solution = vrprouting::initialsol::tabu::Initial_solution; using Solution = vrprouting::problem::Solution; - auto sol = static_cast(Initial_solution(execution_date, true, &pd_problem)); + auto sol = static_cast(Initial_solution(execution_date, true, pd_problem)); /* * Optimize the initial solution: diff --git a/src/optimizers/simple.cpp b/src/optimizers/simple.cpp index 994a3e6aa..21fe023c8 100644 --- a/src/optimizers/simple.cpp +++ b/src/optimizers/simple.cpp @@ -48,30 +48,30 @@ Optimize::Optimize( m_kind(p_kind) { inter_swap(times); this->m_fleet = best_solution.fleet(); - msg().log << tau("bestSol before sort by size"); + log << tau("bestSol before sort by size"); sort_by_size(); - msg().log << tau("bestSol after sort by size"); - msg().log << tau(); + log << tau("bestSol after sort by size"); + log << tau(); } void Optimize::inter_swap(size_t times) { - msg().log << tau("before sort by size"); + log << tau("before sort by size"); sort_by_size(); - msg().log << tau("before decrease"); + log << tau("before decrease"); decrease_truck(); - msg().log << tau("after decrease"); + log << tau("after decrease"); sort_by_size(); - msg().log << tau("after sort by size"); + log << tau("after sort by size"); size_t i = 0; while (i++ < times) { - msg().log << "\n*************************** CYCLE" << i; + log << "\n*************************** CYCLE" << i; inter_swap(); - msg().log << tau("after inter swap"); + log << tau("after inter swap"); std::rotate(m_fleet.begin(), m_fleet.begin() + 1, m_fleet.end()); - msg().log << tau("before next cycle"); + log << tau("before next cycle"); } } @@ -85,7 +85,7 @@ Optimize::inter_swap(size_t times) { */ bool Optimize::inter_swap() { - msg().log + log << "\n" <m_fleet = best_solution.fleet(); - msg().log << tau("Best solution found"); - EXITING(msg()); + log << tau("Best solution found"); + EXITING(log); } /** @@ -132,7 +132,7 @@ Optimize::Optimize( */ bool Optimize::move_2_real() { - ENTERING(msg()); + ENTERING(log); /* * nothing to do: * - No orders pending on phony vehicle @@ -227,7 +227,7 @@ Optimize::move_2_real() { } } // orders } // from phony - EXITING(msg()); + EXITING(log); if (moves_were_done) tabu_list.clear(); return moves_were_done; } @@ -272,7 +272,7 @@ Optimize::set_tabu_list_length() { */ void Optimize::tabu_search() { - ENTERING(msg()); + ENTERING(log); sort_by_size(true); @@ -311,12 +311,8 @@ Optimize::tabu_search() { bool do_spi = true; - [[maybe_unused]] int could_not_spi = 0; - int stuck_counter = 0; - [[maybe_unused]] int wander_counter = 0; - int max_no_improvement = 1000; std::string neighborhood; @@ -357,9 +353,6 @@ Optimize::tabu_search() { if (!moved) { no_moves += 1; - if (neighborhood == "spi") { - could_not_spi += 1; - } if (neighborhood == "sbr") { intensify(); } @@ -376,7 +369,6 @@ Optimize::tabu_search() { */ if (curr_best == best_solution.objective()) { stuck_counter += 1; - wander_counter += 1; if (stuck_counter % wander_length == 0) { intensification = !intensification; diversification = !diversification; @@ -394,7 +386,7 @@ Optimize::tabu_search() { } iter++; } - EXITING(msg()); + EXITING(log); } @@ -805,7 +797,7 @@ void Optimize::save_if_best() { if (objective() < best_solution.objective()) { best_solution = (*this); - msg().log << "\t*** best objective " << best_solution.cost_str(); + log << "\t*** best objective " << best_solution.cost_str(); } } diff --git a/src/pgr_pickDeliver/pgr_pickDeliverEuclidean_driver.cpp b/src/pgr_pickDeliver/pgr_pickDeliverEuclidean_driver.cpp index f064173a7..b0f9a4f3b 100644 --- a/src/pgr_pickDeliver/pgr_pickDeliverEuclidean_driver.cpp +++ b/src/pgr_pickDeliver/pgr_pickDeliverEuclidean_driver.cpp @@ -48,7 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. namespace { vrprouting::problem::Solution -get_initial_solution(vrprouting::problem::PickDeliver* problem_ptr, int m_initial_id) { +get_initial_solution(vrprouting::problem::PickDeliver &problem_ptr, int m_initial_id) { using Solution = vrprouting::problem::Solution; using Initial_solution = vrprouting::initialsol::simple::Initial_solution; using Initials_code = vrprouting::initialsol::simple::Initials_code; @@ -223,7 +223,7 @@ vrp_do_pgr_pickDeliverEuclidean( log << pd_problem.msg.get_log(); log << "Finish Reading data\n"; - auto sol = get_initial_solution(&pd_problem, initial_solution_id); + auto sol = get_initial_solution(pd_problem, initial_solution_id); using Optimize = vrprouting::optimizers::simple::Optimize; using Initials_code = vrprouting::initialsol::simple::Initials_code; sol = Optimize(sol, static_cast(max_cycles), (Initials_code)initial_solution_id); diff --git a/src/pgr_pickDeliver/pgr_pickDeliver_driver.cpp b/src/pgr_pickDeliver/pgr_pickDeliver_driver.cpp index 1a0248e13..8dc4c4e6c 100644 --- a/src/pgr_pickDeliver/pgr_pickDeliver_driver.cpp +++ b/src/pgr_pickDeliver/pgr_pickDeliver_driver.cpp @@ -49,7 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. namespace { vrprouting::problem::Solution -get_initial_solution(vrprouting::problem::PickDeliver* problem_ptr, int m_initial_id) { +get_initial_solution(vrprouting::problem::PickDeliver &problem_ptr, int m_initial_id) { using Solution = vrprouting::problem::Solution; using Initial_solution = vrprouting::initialsol::simple::Initial_solution; using Initials_code = vrprouting::initialsol::simple::Initials_code; @@ -188,7 +188,7 @@ vrp_do_pgr_pickDeliver( pd_problem.msg.clear(); using Initials_code = vrprouting::initialsol::simple::Initials_code; - auto sol = get_initial_solution(&pd_problem, initial_solution_id); + auto sol = get_initial_solution(pd_problem, initial_solution_id); using Optimize = vrprouting::optimizers::simple::Optimize; sol = Optimize(sol, static_cast(max_cycles), (Initials_code)initial_solution_id); diff --git a/src/pickDeliver/pickDeliver_driver.cpp b/src/pickDeliver/pickDeliver_driver.cpp index e183fc635..1e60c6d82 100644 --- a/src/pickDeliver/pickDeliver_driver.cpp +++ b/src/pickDeliver/pickDeliver_driver.cpp @@ -228,7 +228,7 @@ vrp_do_pickDeliver( */ using Initial_solution = vrprouting::initialsol::tabu::Initial_solution; using Solution = vrprouting::problem::Solution; - auto sol = static_cast(Initial_solution(execution_date, optimize, &pd_problem)); + auto sol = static_cast(Initial_solution(execution_date, optimize, pd_problem)); /* * Solve (optimize) diff --git a/src/problem/CMakeLists.txt b/src/problem/CMakeLists.txt index 5d215dc02..9b46816ae 100644 --- a/src/problem/CMakeLists.txt +++ b/src/problem/CMakeLists.txt @@ -9,4 +9,5 @@ ADD_LIBRARY(problem OBJECT vehicle_node.cpp solution.cpp vroom.cpp + pickDeliver.cpp ) diff --git a/src/problem/fleet.cpp b/src/problem/fleet.cpp index 7583d54a5..dbea54b36 100644 --- a/src/problem/fleet.cpp +++ b/src/problem/fleet.cpp @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include "cpp_common/vehicle_t.hpp" +#include "cpp_common/short_vehicle.hpp" namespace vrprouting { namespace problem { @@ -78,7 +79,7 @@ Fleet::get_used_trucks() { */ std::vector Fleet::get_unused_trucks() { - ENTERING(m_msg); + ENTERING(m_msg.log); invariant(); std::vector trucks; m_msg.log << "fleet size" << size(); @@ -142,7 +143,7 @@ Fleet::get_truck(size_t order_idx) { bool Fleet::is_fleet_ok() const { - ENTERING(m_msg); + ENTERING(m_msg.log); if (!m_msg.get_error().empty()) return false; for (auto truck : *this) { if (!truck.is_ok()) { @@ -166,7 +167,7 @@ Fleet::is_fleet_ok() const { return false; } } - EXITING(m_msg); + EXITING(m_msg.log); return true; } @@ -391,6 +392,7 @@ Fleet::build_fleet( for (size_t i = 0; i < size_vehicles; ++i) { add_vehicle(vehicles[i], new_stops, p_orders, p_nodes, node_id); } + /** * creating a phony vehicle with max capacity and max window * with the start & end points of the first vehicle given @@ -439,5 +441,25 @@ Fleet::build_fleet( invariant(); } +/* Constructors */ +Fleet::Fleet( + Vehicle_t* vehicles , size_t size_vehicles, + const Orders& p_orders, + std::vector& p_nodes, + size_t& node_id) + : m_used(), m_unused() { + build_fleet(vehicles, size_vehicles, {}, p_orders, p_nodes, node_id); + } + +Fleet::Fleet( + Vehicle_t* vehicles , size_t size_vehicles, + const std::vector &new_stops, + const Orders& p_orders, + std::vector& p_nodes, + size_t& node_id) + : m_used(), m_unused() { + build_fleet(vehicles, size_vehicles, new_stops, p_orders, p_nodes, node_id); + } + } // namespace problem } // namespace vrprouting diff --git a/src/problem/matrix.cpp b/src/problem/matrix.cpp index 7946b0005..2439658d2 100644 --- a/src/problem/matrix.cpp +++ b/src/problem/matrix.cpp @@ -172,15 +172,6 @@ Matrix::Matrix( Base_Matrix(matrix, size_matrix, node_ids, multiplier), m_multipliers(set_tdm(multipliers, size_multipliers)) { } -/* - * constructor for euclidean with time dependant multipliers - */ -Matrix::Matrix( - const std::map, Id> &euclidean_data, - Time_multipliers_t *multipliers, size_t size_multipliers, - Multiplier multiplier) : - Base_Matrix(euclidean_data, multiplier), - m_multipliers(set_tdm(multipliers, size_multipliers)) { } /* * constructor for euclidean default multipliers diff --git a/src/problem/order.cpp b/src/problem/order.cpp index 9f567ddec..f80dbe635 100644 --- a/src/problem/order.cpp +++ b/src/problem/order.cpp @@ -179,6 +179,15 @@ Order::isCompatibleIJ(const Order &I, Speed speed) const { return all_cases && (case1 || case2 || case3); } +/** Constructor */ +Order::Order(Idx o_idx, Id o_id, + const Vehicle_node &p_pickup, + const Vehicle_node &p_delivery) : + Identifier(o_idx, o_id), + m_pickup(p_pickup), + m_delivery(p_delivery) { +} + } // namespace problem } // namespace vrprouting diff --git a/src/problem/orders.cpp b/src/problem/orders.cpp index 60fcdcf8d..8228c9c6d 100644 --- a/src/problem/orders.cpp +++ b/src/problem/orders.cpp @@ -27,16 +27,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include "problem/orders.hpp" +#include #include -#include #include "cpp_common/assert.hpp" #include "cpp_common/identifiers.hpp" +#include "problem/pickDeliver.hpp" namespace vrprouting { namespace problem { +Orders::Orders( + Orders_t *p_orders, size_t p_size_orders, + PickDeliver &problem_ptr) { + Tw_node::m_time_matrix_ptr = &(problem_ptr.time_matrix()); + build_orders(p_orders, p_size_orders, problem_ptr); +} + /** @returns the index of the order within_this_set that has more possibilities of placing orders after it @param [in] within_this_set @@ -133,6 +141,43 @@ Orders::set_compatibles(Speed speed) { } } +/** + @param [in] orders set of orders + @param [in] sizer_orders + @param [in] problem_ptr pointer to problem to get some needed information + */ +void +Orders::build_orders( + Orders_t *orders, size_t size_orders, + PickDeliver& problem_ptr) { + /** + * - Sort orders: ASC pick_open_t, deliver_close_t, id + */ + std::sort(orders, orders + size_orders, + [] (const Orders_t &lhs, const Orders_t &rhs) { + if (lhs.pick_open_t == rhs.pick_open_t) { + if (lhs.deliver_close_t == rhs.deliver_close_t) { + return lhs.id < rhs.id; + } else { + return lhs.deliver_close_t < rhs.deliver_close_t; + } + } else { + return lhs.pick_open_t < rhs.pick_open_t; + } + }); + + for (size_t i = 0; i < size_orders; ++i) { + auto o = orders[i]; + Vehicle_node pick({problem_ptr.node_id()++, o, NodeType::kPickup}); + Vehicle_node drop({problem_ptr.node_id()++, o, NodeType::kDelivery}); + + problem_ptr.add_node(pick); + problem_ptr.add_node(drop); + + this->emplace_back(Order{size(), o.id, pick, drop}); + } +} + } // namespace problem } // namespace vrprouting diff --git a/src/problem/pickDeliver.cpp b/src/problem/pickDeliver.cpp new file mode 100644 index 000000000..1b79b04cc --- /dev/null +++ b/src/problem/pickDeliver.cpp @@ -0,0 +1,86 @@ +/*WC-GNU***************************************************************** + +FILE: pickDeliver.cpp + +Copyright (c) 2017 pgRouting developers +Mail: project@pgrouting.org + +------ + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + ********************************************************************WC-GNU*/ + +#include "problem/pickDeliver.hpp" + +#include +#include +#include "c_types/compatibleVehicles_rt.h" +#include "c_types/solution_rt.h" +#include "cpp_common/orders_t.hpp" +#include "cpp_common/vehicle_t.hpp" +#include "cpp_common/short_vehicle.hpp" +#include "cpp_common/messages.hpp" +#include "problem/vehicle_node.hpp" +#include "problem/orders.hpp" +#include "problem/fleet.hpp" +#include "problem/matrix.hpp" + +namespace vrprouting { +namespace problem { + +PickDeliver::PickDeliver( + Orders_t* p_orders, size_t p_orders_size, + Vehicle_t* p_vehicles, size_t p_vehicles_size, + const Matrix &p_cost_matrix) : + m_cost_matrix(p_cost_matrix), + m_orders(p_orders, p_orders_size, *this), + m_trucks(p_vehicles, p_vehicles_size, m_orders, m_nodes, m_node_id) { + if (!msg.get_error().empty()) return; + m_trucks.clean(); + m_orders.set_compatibles(); + m_trucks.set_compatibles(m_orders); + } + +/** @brief Override stops constructor */ +PickDeliver::PickDeliver( + Orders_t* p_orders, size_t p_orders_size, + Vehicle_t* p_vehicles, size_t p_vehicles_size, + std::vector new_stops, + const Matrix &p_cost_matrix) : + m_cost_matrix(p_cost_matrix), + m_orders(p_orders, p_orders_size, *this), + m_trucks(p_vehicles, p_vehicles_size, new_stops, m_orders, m_nodes, m_node_id) { + if (!msg.get_error().empty()) return; + m_trucks.clean(); + m_orders.set_compatibles(); + m_trucks.set_compatibles(m_orders); + } + + +/** @brief get the vehicles compatibility results as C++ container */ +std::vector PickDeliver::get_pg_compatibleVehicles() const { + std::vector result; + for (const auto& v : m_trucks) { + if (v.is_phony()) continue; + for (const auto o : v.feasible_orders()) { + result.push_back({m_orders[o].id(), v.id()}); + } + } + return result; +} + +} // namespace problem +} // namespace vrprouting diff --git a/src/problem/solution.cpp b/src/problem/solution.cpp index 8479a485d..4f2bcd892 100644 --- a/src/problem/solution.cpp +++ b/src/problem/solution.cpp @@ -36,8 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #include #include "problem/pickDeliver.hpp" #include "cpp_common/short_vehicle.hpp" - -typedef struct Solution_rt Solution_rt; +#include "c_types/solution_rt.h" namespace vrprouting { namespace problem { @@ -311,6 +310,22 @@ Solution::operator<(const Solution &s_rhs) const { return false; } +std::ostream& operator<< (std::ostream &log, const Solution &solution) { + for (const auto& vehicle : solution.m_fleet) log << vehicle; + log << "\n SOLUTION:\n\n " << solution.tau(); + return log; +} + +double +Solution::objective() const { + return static_cast(total_travel_time()); +} + +Solution::Solution(PickDeliver &p_problem) : + m_orders(p_problem.orders()), + m_trucks(p_problem.vehicles()), + m_msg(p_problem.msg) { } + } // namespace problem } // namespace vrprouting diff --git a/src/problem/vehicle_pickDeliver.cpp b/src/problem/vehicle_pickDeliver.cpp index 4fc6f13b4..9e3a63886 100644 --- a/src/problem/vehicle_pickDeliver.cpp +++ b/src/problem/vehicle_pickDeliver.cpp @@ -39,6 +39,22 @@ namespace vrprouting { namespace problem { +Vehicle_pickDeliver::Vehicle_pickDeliver( + Idx p_idx, + Id p_id, + const Vehicle_node & p_starting_site, + const Vehicle_node & p_ending_site, + const std::vector& p_stops, + PAmount p_capacity, + Speed p_speed, + const Orders& p_orders) : + Vehicle(p_idx, p_id, p_starting_site, p_ending_site, p_capacity, p_speed), + m_cost((std::numeric_limits::max)()), + m_orders_in_vehicle(), + m_feasible_orders(), + m_orders(p_orders), + m_stops(p_stops) {} + /** * * @param [in] order order to be pushed back @@ -186,9 +202,9 @@ Vehicle_pickDeliver::set_initial_solution( if (m_stops.empty()) return; std::vector stops; #if 1 - msg().log << "\n******\n" << this->id() << "\t stops(o_id) -> "; + log << "\n******\n" << this->id() << "\t stops(o_id) -> "; for (const auto &s : m_stops) { - msg().log << s << ", "; + log << s << ", "; } #endif @@ -236,9 +252,9 @@ Vehicle_pickDeliver::set_initial_solution( set_unmovable(execution_date); #if 1 - msg().log << "\n" << this->id() << "\t (idx,id) -> "; + log << "\n" << this->id() << "\t (idx,id) -> "; for (const auto &s : stops) { - msg().log << "(" << s << ", " << orders[s].id() << ")"; + log << "(" << s << ", " << orders[s].id() << ")"; } #endif @@ -246,13 +262,13 @@ Vehicle_pickDeliver::set_initial_solution( * Can not ignore user error when giving an initial solution */ if (!is_feasible()) { - msg().log << "\n**********************************Vehicle is not feasible with initial orders"; - msg().log << "twvTot " << this->twvTot() << "\tm_user_twv" << this->m_user_twv << "\n"; - msg().log << "cvTot " << this->cvTot() << "\tm_user_cv" << this->m_user_cv << "\n"; - msg().log << "\nVehicle: " << this->id() << "Orders: "; - for (const auto &s : m_stops) msg().log << s << ","; - msg().log << "\n"; - msg().log << "\n" << *this; + log << "\n**********************************Vehicle is not feasible with initial orders"; + log << "twvTot " << this->twvTot() << "\tm_user_twv" << this->m_user_twv << "\n"; + log << "cvTot " << this->cvTot() << "\tm_user_cv" << this->m_user_cv << "\n"; + log << "\nVehicle: " << this->id() << "Orders: "; + for (const auto &s : m_stops) log << s << ","; + log << "\n"; + log << "\n" << *this; @@ -277,7 +293,7 @@ Vehicle_pickDeliver::set_initial_solution( * check post conditions */ pgassert(is_feasible()); - msg().log << "\n" << this->tau(); + log << "\n" << this->tau(); } /** @@ -291,7 +307,7 @@ Vehicle_pickDeliver::set_initial_solution( void Vehicle_pickDeliver::set_unmovable(TTimestamp execution_date) { Identifiers unmovable; - msg().log << "\nVehicle: " << this->id() << "unmovable: {"; + log << "\nVehicle: " << this->id() << "unmovable: {"; for (const auto &o : m_orders_in_vehicle) { for (const auto &s : *this) { auto order = this->orders()[o]; @@ -299,13 +315,13 @@ Vehicle_pickDeliver::set_unmovable(TTimestamp execution_date) { if (s.order() == order.id() && s.is_pickup()) { if (s.opens() < execution_date) { unmovable += o; - msg().log << order.id() << ","; + log << order.id() << ","; } } } } - msg().log << "}"; + log << "}"; /** * For the optimizer is like the order does not exist @@ -313,11 +329,15 @@ Vehicle_pickDeliver::set_unmovable(TTimestamp execution_date) { m_orders_in_vehicle -= unmovable; } +Order Vehicle_pickDeliver::get_first_order() const { + pgassert(!empty()); + return orders()[at(1).idx()]; +} + /** * @returns 0 when the Vehicle is phony * @returns the value of the objective function */ - double Vehicle_pickDeliver::objective() const { return is_phony()? 0 : @@ -329,7 +349,6 @@ double Vehicle_pickDeliver::objective() const { * @param [in] order to be tested * @pre vehicle is empty */ - bool Vehicle_pickDeliver::is_order_feasible(const Order &order) const { auto test_truck = *this; @@ -540,6 +559,30 @@ Vehicle_pickDeliver::hillClimb(const Order &order) { return true; } +const Orders& Vehicle_pickDeliver::orders() const { + pgassert(m_orders.size() != 0); + return m_orders; +} + +/** + * @returns The vehicle's information on the log + * @param [in,out] log place to store the vehicle's information + * @param [in] v the vehicle to work with + */ +std::ostream& operator<< (std::ostream &log, const Vehicle_pickDeliver &v) { + int i(0); + log << "\n\n****************** " << v.idx() << "th VEHICLE*************\n"; + log << "id = " << v.id() + << "\tcapacity = " << v.capacity() << "\n"; + + for (const auto &path_stop : v) { + log << "Path_stop" << ++i << "\n"; + log << path_stop << "\n"; + } + + log << v.feasible_orders() << "\n"; + return log; +} } // namespace problem } // namespace vrprouting diff --git a/src/problem/vroom.cpp b/src/problem/vroom.cpp index ba7d301ff..1389d8c85 100644 --- a/src/problem/vroom.cpp +++ b/src/problem/vroom.cpp @@ -297,7 +297,7 @@ Vroom::add_matrix(const vrprouting::vroom::Matrix &matrix) { } void -Vroom::get_amount(::vroom::Amount vroom_amount, Amount **amount) { +Vroom::get_amount(const ::vroom::Amount &vroom_amount, Amount **amount) { size_t amount_size = vroom_amount.size(); for (size_t i = 0; i < amount_size; i++) { *((*amount) + i) = vroom_amount[i]; @@ -305,7 +305,7 @@ Vroom::get_amount(::vroom::Amount vroom_amount, Amount **amount) { } StepType -Vroom::get_job_step_type(::vroom::JOB_TYPE vroom_job_type) { +Vroom::get_job_step_type(const ::vroom::JOB_TYPE &vroom_job_type) { StepType step_type; switch (vroom_job_type) { case ::vroom::JOB_TYPE::SINGLE: @@ -322,7 +322,7 @@ Vroom::get_job_step_type(::vroom::JOB_TYPE vroom_job_type) { } StepType -Vroom::get_step_type(::vroom::Step step) { +Vroom::get_step_type(const ::vroom::Step &step) { StepType step_type = 0; switch (step.step_type) { case ::vroom::STEP_TYPE::START: @@ -342,7 +342,7 @@ Vroom::get_step_type(::vroom::Step step) { } std::vector -Vroom::get_results(::vroom::Solution solution) { +Vroom::get_results(const ::vroom::Solution &solution) { std::vector results; auto routes = solution.routes; Idx vehicle_seq = 1; @@ -508,7 +508,7 @@ Vroom::solve( static_cast(exploration_level), threads); results = get_results(solution); } else { - int timeout_ms = (loading_time <= timeout * 1000) ? (timeout * 1000 - loading_time) : 0; + auto timeout_ms = (loading_time <= timeout * 1000) ? (timeout * 1000 - loading_time) : 0; auto solution = problem_instance.solve( static_cast(exploration_level), threads, timeout_ms); results = get_results(solution);