<commit_before>#ifndef OR_TOOLS_TUTORIALS_CPLUSPLUS_TSPTW_DATA_DT_H
#define OR_TOOLS_TUTORIALS_CPLUSPLUS_TSPTW_DATA_DT_H

#include <ostream>
#include <iomanip>
#include <vector>

#include "constraint_solver/routing.h"
#include "base/filelinereader.h"
#include "base/split.h"
#include "base/strtoint.h"


#include "ortools_vrp.pb.h"
#include "routing_common/routing_common.h"

#define CUSTOM_MAX_INT (int64)std::pow(2,31)

enum RelationType { MeetUp = 6, Shipment = 5, MaximumDayLapse = 4, MinimumDayLapse = 3, SameRoute = 2, Order = 1, Sequence = 0 };

namespace operations_research {

class TSPTWDataDT {
public:
  explicit TSPTWDataDT(std::string filename) {
    LoadInstance(filename);
  }
  void LoadInstance(const std::string & filename);

  //  Helper function
  int64& SetMatrix(int i, int j) {
    return distances_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64& SetTimeMatrix(int i, int j) {
    return times_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64& SetValueMatrix(int i, int j) {
    return values_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64 BuildTimeMatrix(ortools_vrp::Matrix matrix) {
    int64 max_time_ = 0;
    int32 size_matrix = sqrt(matrix.time_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
        max_time_ = std::max(max_time_, static_cast<int64>(matrix.time(i * size_matrix + j) + 0.5));
        SetTimeMatrix(i, j) = static_cast<int64>(matrix.time(i * size_matrix + j) + 0.5);
      }
    }
    return max_time_;
  }

  int64 BuildDistanceMatrix(ortools_vrp::Matrix matrix) {
    int64 max_distance_ = 0;
    int32 size_matrix = sqrt(matrix.distance_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
          max_distance_ = std::max(max_distance_, static_cast<int64>(matrix.distance(i * size_matrix + j)));
          SetMatrix(i, j) = static_cast<int64>(matrix.distance(i * size_matrix + j));
      }
    }
    return max_distance_;
  }

  int64 BuildValueMatrix(ortools_vrp::Matrix matrix) {
    int64 max_value_ = 0;
    int32 size_matrix = sqrt(matrix.value_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
          max_value_ = std::max(max_value_, static_cast<int64>(matrix.value(i * size_matrix + j)));
          SetValueMatrix(i, j) = static_cast<int64>(matrix.value(i * size_matrix + j));
      }
    }
    return max_value_;
  }

  int64 Horizon() const {
    return horizon_;
  }

  int64 MatrixIndex(RoutingModel::NodeIndex i) const {
    return tsptw_clients_[i.value()].matrix_index;<commit_msg>ignore max int for exclusion cost<commit_after>#ifndef OR_TOOLS_TUTORIALS_CPLUSPLUS_TSPTW_DATA_DT_H
#define OR_TOOLS_TUTORIALS_CPLUSPLUS_TSPTW_DATA_DT_H

#include <ostream>
#include <iomanip>
#include <vector>

#include "constraint_solver/routing.h"
#include "base/filelinereader.h"
#include "base/split.h"
#include "base/strtoint.h"


#include "ortools_vrp.pb.h"
#include "routing_common/routing_common.h"

#define CUSTOM_MAX_INT (int64)std::pow(2,31)

enum RelationType { MeetUp = 6, Shipment = 5, MaximumDayLapse = 4, MinimumDayLapse = 3, SameRoute = 2, Order = 1, Sequence = 0 };

namespace operations_research {

class TSPTWDataDT {
public:
  explicit TSPTWDataDT(std::string filename) {
    LoadInstance(filename);
  }
  void LoadInstance(const std::string & filename);

  //  Helper function
  int64& SetMatrix(int i, int j) {
    return distances_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64& SetTimeMatrix(int i, int j) {
    return times_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64& SetValueMatrix(int i, int j) {
    return values_matrices_.back()->Cost(RoutingModel::NodeIndex(i), RoutingModel::NodeIndex(j));
  }

  int64 BuildTimeMatrix(ortools_vrp::Matrix matrix) {
    int64 max_time_ = 0;
    int32 size_matrix = sqrt(matrix.time_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
        if (static_cast<int64>(matrix.time(i * size_matrix + j)) < CUSTOM_MAX_INT)
          max_time_ = std::max(max_time_, static_cast<int64>(matrix.time(i * size_matrix + j) + 0.5));
        SetTimeMatrix(i, j) = static_cast<int64>(matrix.time(i * size_matrix + j) + 0.5);
      }
    }
    return max_time_;
  }

  int64 BuildDistanceMatrix(ortools_vrp::Matrix matrix) {
    int64 max_distance_ = 0;
    int32 size_matrix = sqrt(matrix.distance_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
          if (static_cast<int64>(matrix.distance(i * size_matrix + j)) < CUSTOM_MAX_INT)
            max_distance_ = std::max(max_distance_, static_cast<int64>(matrix.distance(i * size_matrix + j)));
          SetMatrix(i, j) = static_cast<int64>(matrix.distance(i * size_matrix + j));
      }
    }
    return max_distance_;
  }

  int64 BuildValueMatrix(ortools_vrp::Matrix matrix) {
    int64 max_value_ = 0;
    int32 size_matrix = sqrt(matrix.value_size());
    for (int64 i = 0; i < size_matrix; ++i) {
      for (int64 j = 0; j < size_matrix; ++j) {
          if (static_cast<int64>(matrix.value(i * size_matrix + j)) < CUSTOM_MAX_INT)
            max_value_ = std::max(max_value_, static_cast<int64>(matrix.value(i * size_matrix + j)));
          SetValueMatrix(i, j) = static_cast<int64>(matrix.value(i * size_matrix + j));
      }
    }
    return max_value_;
  }

  int64 Horizon() const {
    return horizon_;
  }

  int64 MatrixIndex(RoutingModel::NodeIndex i) const {
    return tsptw_clients_[i.value()].matrix_index;
{'fraction_non_alphanumeric': 0.13637937002422984, 'fraction_numerical': 0.027691242644513673, 'mean_word_length': 4.029590948651001, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5582978', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2098, 'n_words': 415}