Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underflow in insertion regrets #831

Closed
jcoupey opened this issue Nov 21, 2022 · 1 comment · Fixed by #832
Closed

Underflow in insertion regrets #831

jcoupey opened this issue Nov 21, 2022 · 1 comment · Fixed by #832
Labels
Milestone

Comments

@jcoupey
Copy link
Collaborator

jcoupey commented Nov 21, 2022

While working on #828 I noticed a solving change related to signedness modification. Turns out that this is because we're mixing signed and unsigned values here:

auto smallest = _input.get_cost_upper_bound();
auto second_smallest = _input.get_cost_upper_bound();
std::size_t smallest_idx = std::numeric_limits<std::size_t>::max();
for (std::size_t i = 0; i < routes.size(); i) {
if (route_job_insertions[i][j].eval.cost < smallest) {
smallest_idx = i;
second_smallest = smallest;
smallest = route_job_insertions[i][j].eval.cost;
} else if (route_job_insertions[i][j].eval.cost < second_smallest) {
second_smallest = route_job_insertions[i][j].eval.cost;
}
}

The result of _input.get_cost_upper_bound() is unsigned so it's possible to have an underflow whenever route_job_insertions[i][j].eval.cost (signed value) is negative. Cost insertions should be positive in theory but in reality they may be negative whenever the triangular inequality is broken. This is quite rare but does happens in practice with real-life instances, and also with e.g. Solomon instances due to rounding precision.

There is no risk of crash, or providing a screwed solution, but we're discarding some (good) insertions options there so this piece of code does not always behave as intended.

@jcoupey jcoupey added the bug label Nov 21, 2022
@jcoupey jcoupey added this to the v1.13.0 milestone Nov 21, 2022
@jcoupey
Copy link
Collaborator Author

jcoupey commented Nov 21, 2022

The same kind of problem exists in our dynamic heuristic.

@jcoupey jcoupey mentioned this issue Nov 21, 2022
4 tasks
@jcoupey jcoupey mentioned this issue Nov 21, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant