vrpRouting  0.3
move.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: move.cpp
4 
5 Copyright (c) 2021 pgRouting developers
7 
8 Developer:
9 Copyright (c) 2021 Joseph Emile Honour Percival
10 
11 
12 ------
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 
28  ********************************************************************PGR-GNU*/
29 
30 #include "optimizers/move.h"
31 #include <iostream>
33 #include "problem/order.h"
34 
35 namespace vrprouting {
36 namespace optimizers {
37 namespace tabu {
38 
40  const problem::Order& order, double to_obj, double from_obj) :
41  m_vid1(from_v.id()),
42  m_vid2(to_v.id()),
43  m_oid1(order.id()),
44  m_oid2(0),
45  m_is_swap(false),
46  m_obj1(to_obj),
47  m_obj2(from_obj) { }
48 
50  const problem::Order& from_order, const problem::Order& to_order, double to_obj, double from_obj) :
51  m_vid1(from_v.id()),
52  m_vid2(to_v.id()),
53  m_oid1(from_order.id()),
54  m_oid2(to_order.id()),
55  m_is_swap(true),
56  m_obj1(to_obj),
57  m_obj2(from_obj) { }
58 
65 std::ostream&
66  operator << (std::ostream &log, const Move &m) {
67  log << m.m_oid1 << ":" << m.m_oid2 << ":"
68  << m.m_vid1 << ":" << m.m_vid2 << ":"
69  << m.m_is_swap;
70  return log;
71  }
72 
79 bool
80  operator==(const Move& a, const Move& b) {
81  /*
82  * possible cases are captured in TabuList::has_move and TabuList::has_swap:
83  */
84  return (
85  a.oid1() == b.oid1()
86  && a.oid2() == b.oid2()
87  && a.vid1() == b.vid1()
88  && a.vid2() == b.vid2()
89 #if 0
90  && a.to_objective() == b.to_objective()
91  && a.from_objective() == b.from_objective()
92 #endif
93  && a.is_swap() == b.is_swap());
94  }
95 
96 } // namespace tabu
97 } // namespace optimizers
98 } // namespace vrprouting
vrprouting::optimizers::tabu::Move::vid1
int64_t vid1() const
The identifier of the vehicle to move the order to.
Definition: move.h:66
vrprouting::optimizers::tabu::operator==
bool operator==(const Move &a, const Move &b)
Definition: move.cpp:80
vrprouting::optimizers::tabu::Move::vid2
int64_t vid2() const
The identifier of the vehicle to move the order to.
Definition: move.h:69
move.h
vrprouting::optimizers::tabu::Move::m_vid2
int64_t m_vid2
The identifier of the vehicle to move the order to.
Definition: move.h:91
vrprouting::optimizers::tabu::Move::oid1
int64_t oid1() const
The identifier of the order to move or swap.
Definition: move.h:60
vrprouting::optimizers::tabu::Move::oid2
int64_t oid2() const
The identifier of the order to swap.
Definition: move.h:63
vrprouting::optimizers::tabu::Move::Move
Move()=delete
empty move is not allowed
vrprouting::optimizers::tabu::Move
The Move class defines moves that are evaluated and set as tabu.
Definition: move.h:46
vrprouting::optimizers::tabu::Move::m_vid1
int64_t m_vid1
The identifier of the vehicle to move the order from.
Definition: move.h:88
vrprouting::optimizers::tabu::Move::is_swap
bool is_swap() const
is the move a swap move?
Definition: move.h:72
vrprouting::optimizers::tabu::Move::m_oid1
int64_t m_oid1
The identifier of the first moved order.
Definition: move.h:94
vrprouting::optimizers::tabu::operator<<
std::ostream & operator<<(std::ostream &log, const Move &m)
Definition: move.cpp:66
vrprouting::problem::Vehicle_pickDeliver
Definition: vehicle_pickDeliver.h:46
vrprouting::optimizers::tabu::Move::m_oid2
int64_t m_oid2
The identifier of the second moved order (valid only for swap moves)
Definition: move.h:97
vrprouting::optimizers::tabu::Move::to_objective
double to_objective() const
Objective value of the "to" vehicle.
Definition: move.h:75
vehicle_pickDeliver.h
vrprouting::optimizers::tabu::Move::m_is_swap
bool m_is_swap
flag == true when belongs to swap
Definition: move.h:100
order.h
vrprouting::problem::Order
Definition: order.h:40
vrprouting::optimizers::tabu::Move::from_objective
double from_objective() const
Objective value of the "from" vehicle.
Definition: move.h:78
vrprouting
Definition: base_matrix.cpp:46