PGROUTING  3.2
pgrouting::tsp Namespace Reference

Classes

class  Dmatrix
 
class  EuclideanDmatrix
 
class  Tour
 
class  TSP
 

Functions

double get_distance (std::pair< double, double > p1, std::pair< double, double > p2)
 
std::ostream & operator<< (std::ostream &log, const Dmatrix &matrix)
 
std::ostream & operator<< (std::ostream &log, const EuclideanDmatrix &matrix)
 
std::ostream & operator<< (std::ostream &log, const Tour &tour)
 

Function Documentation

◆ get_distance()

double pgrouting::tsp::get_distance ( std::pair< double, double >  p1,
std::pair< double, double >  p2 
)

Definition at line 127 of file Dmatrix.cpp.

127  {
128  auto dx = p1.first - p2.first;
129  auto dy = p1.second - p2.second;
130  return std::sqrt(dx * dx + dy * dy);
131 }

Referenced by pgrouting::tsp::Dmatrix::Dmatrix().

◆ operator<<() [1/3]

std::ostream& pgrouting::tsp::operator<< ( std::ostream &  log,
const Dmatrix matrix 
)

Definition at line 216 of file Dmatrix.cpp.

216  {
217  for (const auto id : matrix.ids) {
218  log << "\t" << id;
219  }
220  log << "\n";
221  size_t i = 0;
222  for (const auto &row : matrix.costs) {
223  size_t j = 0;
224  for (const auto cost : row) {
225  log << "Internal(" << i << "," << j << ")"
226  << "\tUsers(" << matrix.ids[i] << "," << matrix.ids[j] << ")"
227  << "\t = " << cost
228 #if 0
229  << "\t(" << matrix.get_index(matrix.ids[i])
230  << "," << matrix.get_index(matrix.ids[j]) << ")"
231  << "\t = " << matrix.costs[i][j]
232  << "\t = " << matrix.costs[j][i]
233  << "=inf:"
234  << (matrix.costs[i][j] ==
235  (std::numeric_limits<double>::infinity)())
236  << "=inf:"
237  << (matrix.costs[j][i] ==
238  (std::numeric_limits<double>::infinity)())
239 #endif
240  << "\n";
241  ++j;
242  }
243  ++i;
244  }
245 #if 0
246  for (size_t i = 0; i < matrix.costs.size(); ++i) {
247  for (size_t j = 0; j < matrix.costs.size(); ++j) {
248  for (size_t k = 0; k < matrix.costs.size(); ++k) {
249  log << matrix.costs[i][k] << " <= ("
250  << matrix.costs[i][j] << " + " << matrix.costs[j][k] << ")"
251  << (matrix.costs[i][k]
252  <= (matrix.costs[i][j] + matrix.costs[j][k]))
253  << "\n";
254  }
255  }
256  }
257 #endif
258  return log;
259 }

References pgrouting::tsp::Dmatrix::costs, pgrouting::tsp::Dmatrix::get_index(), and pgrouting::tsp::Dmatrix::ids.

◆ operator<<() [2/3]

std::ostream& pgrouting::tsp::operator<< ( std::ostream &  log,
const EuclideanDmatrix matrix 
)

Definition at line 157 of file euclideanDmatrix.cpp.

157  {
158  for (const auto id : matrix.ids) {
159  log << "\t" << id;
160  }
161  log << "\n";
162  for (const auto row : matrix.coordinates) {
163  log << row.id << "(" << row.x << "," << row.y << ")\n";
164  }
165  return log;
166 }

References pgrouting::tsp::EuclideanDmatrix::coordinates, and pgrouting::tsp::EuclideanDmatrix::ids.

◆ operator<<() [3/3]

std::ostream& pgrouting::tsp::operator<< ( std::ostream &  log,
const Tour tour 
)

Definition at line 36 of file tour.cpp.

38  {
39  for (const auto &city : tour.cities) {
40  log << city << ", ";
41  }
42  return log;
43 }

References pgrouting::tsp::Tour::cities.