Skip to content

Wrong evaluation in ReverseTwoOpt #1271

@jcoupey

Description

@jcoupey

While working on #1267 I came across a situation where the new way of computing gain does not match the old one in ReverseTwoOpt::compute_gain for a test instance. At first I suspected a flaw in the new gain computing logic, but upon debugging on that specific instance it turns out there is a problem in the original code.

I've narrowed it down to a MWE: wrong_reverse_two_opt_source_eval.json which is a sub-instance of the original one. Additionally I'm forcing initial routes in such a way that the operator is applied first thing, but with the wrong evaluation. As a result running v1.14 in debug mode hits an assert after applying the move:

$ vroom_v1.14_debug -i wrong_reverse_two_opt_source_eval.json
vroom_v1.14_debug: algorithms/local_search/local_search.cpp:1861: void vroom::ls::LocalSearch<Route, UnassignedExchange, CrossExchange, MixedExchange, TwoOpt, ReverseTwoOpt, Relocate, OrOpt, IntraExchange, IntraCrossExchange, IntraMixedExchange, IntraRelocate, IntraOrOpt, IntraTwoOpt, PDShift, RouteExchange, SwapStar, RouteSplit, PriorityReplace, TSPFix>::run_ls_step() [with Route = vroom::RawRoute; UnassignedExchange = vroom::cvrp::UnassignedExchange; CrossExchange = vroom::cvrp::CrossExchange; MixedExchange = vroom::cvrp::MixedExchange; TwoOpt = vroom::cvrp::TwoOpt; ReverseTwoOpt = vroom::cvrp::ReverseTwoOpt; Relocate = vroom::cvrp::Relocate; OrOpt = vroom::cvrp::OrOpt; IntraExchange = vroom::cvrp::IntraExchange; IntraCrossExchange = vroom::cvrp::IntraCrossExchange; IntraMixedExchange = vroom::cvrp::IntraMixedExchange; IntraRelocate = vroom::cvrp::IntraRelocate; IntraOrOpt = vroom::cvrp::IntraOrOpt; IntraTwoOpt = vroom::cvrp::IntraTwoOpt; PDShift = vroom::cvrp::PDShift; RouteExchange = vroom::cvrp::RouteExchange; SwapStar = vroom::cvrp::SwapStar; RouteSplit = vroom::cvrp::RouteSplit; PriorityReplace = vroom::cvrp::PriorityReplace; TSPFix = vroom::cvrp::TSPFix]: Assertion `new_eval + best_gain == previous_eval' failed.
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions