Skip to content

Commit 138751f

Browse files
committed
Reuse in_place_delta_cost for IntraExchange::compute_gain.
1 parent a93326b commit 138751f

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

src/problems/cvrp/operators/intra_exchange.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,19 @@ IntraExchange::IntraExchange(const Input& input,
4545
}
4646

4747
void IntraExchange::compute_gain() {
48-
const Eval s_gain = std::get<0>(utils::addition_cost_delta(_input,
49-
_sol_state,
50-
source,
51-
s_rank,
52-
s_rank + 1,
53-
target,
54-
t_rank,
55-
t_rank + 1));
56-
57-
const Eval t_gain = std::get<0>(utils::addition_cost_delta(_input,
58-
_sol_state,
59-
target,
60-
t_rank,
61-
t_rank + 1,
62-
source,
63-
s_rank,
64-
s_rank + 1));
48+
s_gain = _sol_state.node_gains[s_vehicle][s_rank] -
49+
utils::in_place_delta_cost(_input,
50+
s_route[t_rank],
51+
_input.vehicles[s_vehicle],
52+
s_route,
53+
s_rank);
54+
55+
t_gain = _sol_state.node_gains[s_vehicle][t_rank] -
56+
utils::in_place_delta_cost(_input,
57+
s_route[s_rank],
58+
_input.vehicles[s_vehicle],
59+
s_route,
60+
t_rank);
6561

6662
stored_gain = s_gain + t_gain;
6763
gain_computed = true;

0 commit comments

Comments
 (0)