PGROUTING  3.2
euclideanDmatrix.h
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 
3 FILE: euclideanDmatrix.h
4 
5 Copyright (c) 2015 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  ********************************************************************PGR-GNU*/
25 
26 #ifndef INCLUDE_TSP_EUCLIDEANDMATRIX_H_
27 #define INCLUDE_TSP_EUCLIDEANDMATRIX_H_
28 #pragma once
29 
30 #include <iostream>
31 #include <vector>
32 
33 #include "c_types/coordinate_t.h"
34 
35 namespace pgrouting {
36 namespace tsp {
37 
38 class Tour;
39 
41  public:
42  EuclideanDmatrix() = default;
43  explicit EuclideanDmatrix(
44  const std::vector< Coordinate_t > &data_coordinates);
45 
46  bool has_no_infinity() const;
47  bool obeys_triangle_inequality() const;
48  bool is_symmetric() const;
49 
57  void set(size_t i, size_t j, double dist) {
58  row = i; column = j; special_distance = dist;}
59 
66  bool has_id(int64_t id) const;
67 
73  size_t get_index(int64_t id) const;
74 
80  int64_t get_id(size_t idx) const;
81 
86  size_t size() const {return ids.size();}
87 
93  double tourCost(const Tour &tour) const;
94 
101  const std::vector<double> get_row(size_t idx) const;
102 
103  double comparable_distance(size_t i, size_t j) const;
104  double distance(size_t i, size_t j) const;
105 
106  friend std::ostream& operator<<(
107  std::ostream &log,
108  const EuclideanDmatrix &matrix);
109 
110  protected:
111  void set_ids();
112  std::vector<int64_t> ids;
113 
114  private:
115  std::vector < Coordinate_t > coordinates;
116  size_t row;
117  size_t column;
119 };
120 
121 } // namespace tsp
122 } // namespace pgrouting
123 
124 #endif // INCLUDE_TSP_EUCLIDEANDMATRIX_H_
pgrouting::tsp::EuclideanDmatrix::ids
std::vector< int64_t > ids
Definition: euclideanDmatrix.h:112
pgrouting::tsp::EuclideanDmatrix::comparable_distance
double comparable_distance(size_t i, size_t j) const
Definition: euclideanDmatrix.cpp:55
pgrouting::tsp::EuclideanDmatrix::is_symmetric
bool is_symmetric() const
Definition: euclideanDmatrix.cpp:153
pgrouting::tsp::Tour
Definition: tour.h:42
pgrouting::tsp::EuclideanDmatrix::column
size_t column
Definition: euclideanDmatrix.h:117
pgrouting::tsp::EuclideanDmatrix::get_row
const std::vector< double > get_row(size_t idx) const
returns a row of distances
Definition: euclideanDmatrix.cpp:42
pgrouting::tsp::EuclideanDmatrix::distance
double distance(size_t i, size_t j) const
Definition: euclideanDmatrix.cpp:67
pgrouting::tsp::EuclideanDmatrix::operator<<
friend std::ostream & operator<<(std::ostream &log, const EuclideanDmatrix &matrix)
Definition: euclideanDmatrix.cpp:157
pgrouting::tsp::EuclideanDmatrix
Definition: euclideanDmatrix.h:40
pgrouting::tsp::EuclideanDmatrix::size
size_t size() const
|idx|
Definition: euclideanDmatrix.h:86
pgrouting::tsp::EuclideanDmatrix::get_index
size_t get_index(int64_t id) const
original id -> idx
Definition: euclideanDmatrix.cpp:104
coordinate_t.h
pgrouting::tsp::EuclideanDmatrix::get_id
int64_t get_id(size_t idx) const
idx -> original id
Definition: euclideanDmatrix.cpp:112
pgrouting::tsp::EuclideanDmatrix::coordinates
std::vector< Coordinate_t > coordinates
Definition: euclideanDmatrix.h:115
pgrouting::tsp::EuclideanDmatrix::obeys_triangle_inequality
bool obeys_triangle_inequality() const
Definition: euclideanDmatrix.cpp:148
pgrouting::tsp::EuclideanDmatrix::set
void set(size_t i, size_t j, double dist)
sets a special value for the distance(i,j)
Definition: euclideanDmatrix.h:57
pgrouting::tsp::EuclideanDmatrix::special_distance
double special_distance
Definition: euclideanDmatrix.h:118
pgrouting::tsp::EuclideanDmatrix::EuclideanDmatrix
EuclideanDmatrix()=default
pgrouting::tsp::EuclideanDmatrix::row
size_t row
Definition: euclideanDmatrix.h:116
pgrouting::tsp::EuclideanDmatrix::has_no_infinity
bool has_no_infinity() const
Definition: euclideanDmatrix.cpp:143
pgrouting::tsp::EuclideanDmatrix::set_ids
void set_ids()
Definition: euclideanDmatrix.cpp:129
pgrouting::tsp::EuclideanDmatrix::has_id
bool has_id(int64_t id) const
original id -> true
Definition: euclideanDmatrix.cpp:96
pgrouting::tsp::EuclideanDmatrix::tourCost
double tourCost(const Tour &tour) const
tour evaluation
Definition: euclideanDmatrix.cpp:78
pgrouting
Book keeping class for swapping orders between vehicles.
Definition: pgr_alphaShape.cpp:56