51 get_distance(std::pair<Coordinate, Coordinate> p1 , std::pair<Coordinate, Coordinate> p2) {
52 auto dx = p1.first - p2.first;
53 auto dy = p1.second - p2.second;
54 return std::sqrt(dx * dx + dy * dy);
91 for (
const auto &cost : data) {
95 node_ids += cost.from_vid;
96 node_ids += cost.to_vid;
130 auto pos = std::lower_bound(
m_ids.cbegin(),
m_ids.cend(),
id);
135 return pos !=
m_ids.end() && *pos == id;
165 auto pos = std::lower_bound(
m_ids.begin(),
m_ids.end(),
id);
166 if (pos ==
m_ids.end()) {
167 std::ostringstream msg;
168 msg << *
this <<
"\nNot found" << id;
170 throw std::make_pair(std::string(
"(INTERNAL) Base_Matrix: Unable to find node on matrix"), msg.str());
177 return static_cast<Idx>(pos -
m_ids.begin());
207 if (index >=
m_ids.size()) {
208 std::ostringstream msg;
209 msg << *
this <<
"\nOut of range" << index;
211 throw std::make_pair(std::string(
"(INTERNAL) Base_Matrix: The given index is out of range"), msg.str());
218 return static_cast<Id>(
m_ids[index]);
249 std::vector<TInterval>(
254 (std::numeric_limits<TInterval>::max)()));
260 for (
size_t i = 0; i < size_matrix; ++i) {
261 auto data = data_costs[i];
265 if (!(
has_id(data.from_vid) &&
has_id(data.to_vid)))
continue;
317 std::vector<TInterval>(
m_ids.size(),
321 (std::numeric_limits<TInterval>::max)()));
324 std::vector<TravelCost>(
m_ids.size(), (std::numeric_limits<TravelCost>::max)()));
330 for (
size_t i = 0; i < total_matrix_rows; ++i) {
331 auto cell = matrix_rows[i];
335 if (!(
has_id(cell.start_id) &&
has_id(cell.end_id)))
continue;
341 static_cast<Duration>(std::round(cell.duration / scaling_factor));
349 (std::numeric_limits<TInterval>::max)()) {
354 (std::numeric_limits<TravelCost>::max)()) {
373 m_ids.reserve(euclidean_data.size());
374 for (
const auto &e : euclidean_data) {
375 m_ids.push_back(e.second);
379 std::vector<TInterval>(
381 (std::numeric_limits<TInterval>::max)()));
383 for (
const auto &from : euclidean_data) {
384 for (
const auto &to : euclidean_data) {
403 vroom::Matrix<vroom::Duration>
405 size_t matrix_size =
m_ids.size();
406 vroom::Matrix<vroom::Cost> vroom_matrix(matrix_size);
407 for (
size_t i = 0; i < matrix_size; i++) {
408 for (
size_t j = 0; j < matrix_size; j++) {
420 vroom::Matrix<vroom::Cost>
422 size_t matrix_size =
m_ids.size();
423 vroom::Matrix<vroom::Cost> vroom_matrix(matrix_size);
424 for (
size_t i = 0; i < matrix_size; i++) {
425 for (
size_t j = 0; j < matrix_size; j++) {
426 vroom_matrix[i][j] =
static_cast<vroom::Cost
>(
m_cost_matrix[i][j]);
464 for (
const auto &val : row) {
470 if (val == (std::numeric_limits<TInterval>::max)())
return false;
528 std::ostringstream log;
571 for (
const auto id : matrix.
m_ids) {
582 for (
const auto cost : row) {
586 log <<
"Internal(" << i <<
"," << j <<
")"
587 <<
"\tOriginal(" << matrix.
m_ids[i] <<
"," << matrix.
m_ids[j] <<
")"