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

Short-circuit evaluation in validity checks #293

Closed
jcoupey opened this issue Jan 29, 2020 · 1 comment · Fixed by #294
Closed

Short-circuit evaluation in validity checks #293

jcoupey opened this issue Jan 29, 2020 · 1 comment · Fixed by #294
Assignees
Milestone

Comments

@jcoupey
Copy link
Collaborator

jcoupey commented Jan 29, 2020

In numerous situations, deciding if a local search move is valid is the result of calling several functions in a row to check validity with regard to skills, capacity, time windows etc.

The current code-base usually uses something along the lines of:

bool valid = first_check();
valid &= another_check();
...
return valid;

This code does generate unnecessary checks because another_check it still called even if first_check returned false.

We should use operator&& instead to get the intended short-circuit evaluation behaviour.

@jcoupey jcoupey added this to the v1.6.0 milestone Jan 29, 2020
@jcoupey jcoupey self-assigned this Jan 29, 2020
@jcoupey
Copy link
Collaborator Author

jcoupey commented Jan 29, 2020

From the tests I've been running based on #294, reduction in total solving time is somewhere around 5%, depending on problem type, number of threads and exploration level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant