12 {
13
14 std::vector<std::vector<double>> matrix(
targets_.size());
15 for (
auto& elem : matrix) elem.resize(
targets_.size());
16
17
18 std::vector<std::vector<std::vector<Segment>>> optimal_ways(
targets_.size());
19 for (
auto& elem : optimal_ways) elem.resize(
targets_.size());
20
21
23
24 for (std::size_t i = 0; i <
targets_.size(); ++i) {
25 matrix[i][i] = inf;
26 for (std::size_t j = 0; j < i; ++j) {
28 std::vector<Segment> segment_way = owc.GetTrajectoryPart();
29
30 optimal_ways[i][j] = segment_way;
31 std::reverse(segment_way.begin(), segment_way.end());
32 for (auto& seg_part : segment_way) {
33 if (seg_part.IsArc())
34 seg_part =
35 Segment(seg_part.End(), seg_part.Start(), seg_part.Center());
36 else
37 seg_part =
Segment(seg_part.End(), seg_part.Start());
38 }
39 optimal_ways[j][i] = segment_way;
40
41 matrix[i][j] = owc.GetOptimalWayLength();
42 matrix[j][i] = owc.GetOptimalWayLength();
43 }
44 }
45
47 matrix[line.first][line.second] = inf;
48 matrix[line.second][line.first] = inf;
49 }
50
51
54 std::vector<std::size_t> traj = tsp.GetTrajectory();
55
56
57 for (std::size_t i = 0; i < traj.size(); ++i) {
60 optimal_ways[traj[i]][traj[(i + 1) % traj.size()]].begin(),
61 optimal_ways[traj[i]][traj[(i + 1) % traj.size()]].end());
62 }
63}
Сегмент математический траектории
Definition segment.h:12
static AdjacencyMatrix WithExtraRowCol(const std::vector< std::vector< double > > &nums)
Создает новый экземпляр AdjacencyMatrix с добавлением строки и столбца номеров точек
Definition adjacency_matrix.cpp:9
std::vector< lib::Segment > trajectory_
Definition trajectory.h:71