Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lesson5/solver_by_2opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class TSP {
double CalcScoreFromTour(const std::vector<int>& tour) {
double result = 0;
for (int i = 1; i < N_ + 1; i++) {
// ALEXNOTE: this is called in the inner loop of OptimizeBy20pt.
// so you can probably gain much efficiency by caching the score
// data for each node, or even better if you cache for the entire tour.
result += dist_[tour[i - 1]][tour[i]];
}
return result;
Expand Down