| 99 | } |
| 100 | |
| 101 | SwapStar::InsertPoint SwapStar::bestInsertPoint( |
| 102 | Route::Node *U, Route::Node *V, CostEvaluator const &costEvaluator) |
| 103 | { |
| 104 | auto *route = V->route(); |
| 105 | |
| 106 | if (!isCached(route->idx(), U->client())) |
| 107 | updateInsertPoints(route, U, costEvaluator); |
| 108 | |
| 109 | for (auto [cost, where] : insertCache(route->idx(), U->client())) |
| 110 | if (where && where != V && n(where) != V && V->trip() == where->trip()) |
| 111 | // Only if V is not adjacent. We also require that V is in the same |
| 112 | // trip as the node we plan to remove, because we cannot currently |
| 113 | // evaluate segments with intermediate reloads in them. |
| 114 | return std::make_pair(cost, where); |
| 115 | |
| 116 | // As a fallback option, we consider inserting in the place of V. |
| 117 | Cost deltaCost = 0; |
| 118 | costEvaluator.deltaCost<true, true>( |
| 119 | deltaCost, |
| 120 | Route::Proposal(route->before(V->idx() - 1), |
| 121 | U->route()->at(U->idx()), |
| 122 | route->after(V->idx() + 1))); |
| 123 | |
| 124 | return std::make_pair(deltaCost, p(V)); |
| 125 | } |
| 126 | |
| 127 | Cost SwapStar::evaluateMove(Route::Node const *U, |
| 128 | Route::Node const *V, |