<commit_before>/*

This file is part of VROOM.

Copyright (c) 2015-2018, <NAME>.
All rights reserved (see LICENSE).

*/

#include "tsp.h"
#include "../../structures/vroom/input/input.h"

tsp::tsp(const input& input,
         std::vector<index_t> job_ranks,
         index_t vehicle_rank)
  : vrp(input),
    _vehicle_rank(vehicle_rank),
    _job_ranks(std::move(job_ranks)),
    _is_symmetric(true),
    _has_start(_input._vehicles[_vehicle_rank].has_start()),
    _has_end(_input._vehicles[_vehicle_rank].has_end()) {

  // Pick ranks to select from input matrix.
  std::vector<index_t> matrix_ranks;
  std::transform(_job_ranks.cbegin(),
                 _job_ranks.cend(),
                 std::back_inserter(matrix_ranks),
                 [&](const auto& r) {
                   return _input._jobs[r].location.index();
                 });

  if (_has_start) {
    // Add start and remember rank in _matrix.
    _start = matrix_ranks.size();
    matrix_ranks.push_back(_input._vehicles[_vehicle_rank].start.get().index());
  }
  if (_has_end) {
    // Add end and remember rank in _matrix.
    if (_has_start and (_input._vehicles[_vehicle_rank].start.get().index() ==
                        _input._vehicles[_vehicle_rank].end.get().index())) {
      // Avoiding duplicate for identical ranks.
      _end = _start;
    } else {
      _end = matrix_ranks.size();
      matrix_ranks.push_back(_input._vehicles[_vehicle_rank].end.get().index());
    }
  }

  _matrix = _input.get_sub_matrix(matrix_ranks);

  // Distances on the diagonal are never used except in the minimum
  // weight perfect matching (munkres call during the heuristic). This<commit_msg>Consistent use of job::index.<commit_after>/*

This file is part of VROOM.

Copyright (c) 2015-2018, <NAME>.
All rights reserved (see LICENSE).

*/

#include "tsp.h"
#include "../../structures/vroom/input/input.h"

tsp::tsp(const input& input,
         std::vector<index_t> job_ranks,
         index_t vehicle_rank)
  : vrp(input),
    _vehicle_rank(vehicle_rank),
    _job_ranks(std::move(job_ranks)),
    _is_symmetric(true),
    _has_start(_input._vehicles[_vehicle_rank].has_start()),
    _has_end(_input._vehicles[_vehicle_rank].has_end()) {

  // Pick ranks to select from input matrix.
  std::vector<index_t> matrix_ranks;
  std::transform(_job_ranks.cbegin(),
                 _job_ranks.cend(),
                 std::back_inserter(matrix_ranks),
                 [&](const auto& r) { return _input._jobs[r].index(); });

  if (_has_start) {
    // Add start and remember rank in _matrix.
    _start = matrix_ranks.size();
    matrix_ranks.push_back(_input._vehicles[_vehicle_rank].start.get().index());
  }
  if (_has_end) {
    // Add end and remember rank in _matrix.
    if (_has_start and (_input._vehicles[_vehicle_rank].start.get().index() ==
                        _input._vehicles[_vehicle_rank].end.get().index())) {
      // Avoiding duplicate for identical ranks.
      _end = _start;
    } else {
      _end = matrix_ranks.size();
      matrix_ranks.push_back(_input._vehicles[_vehicle_rank].end.get().index());
    }
  }

  _matrix = _input.get_sub_matrix(matrix_ranks);

  // Distances on the diagonal are never used except in the minimum
  // weight perfect matching (munkres call during the heuristic). This
{'fraction_non_alphanumeric': 0.13535660091047041, 'fraction_numerical': 0.004855842185128983, 'mean_word_length': 3.0, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6854063', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1062, 'n_words': 220}