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

Make heuristics usable as components #107

Merged
merged 10 commits into from
Sep 1, 2022
Merged

Make heuristics usable as components #107

merged 10 commits into from
Sep 1, 2022

Conversation

Saethox
Copy link
Collaborator

@Saethox Saethox commented Aug 17, 2022

Closes #98, Closes #97

Changes

All heuristics in the heuristics module now have a generic template function with the same name as the module (e.g., heuristics::aco::aco), which is not specific to a certain problem (parametrized over SingleObjectiveProblem). They accept a heuristics::<heuristic_name>::Parameters struct with their specific components and parameters, a termination criterion and a Logger.

The existing heuristics were converted into real_<heuristic_name> or permutation_<heuristic_name> functions etc., depending on the problem type they solve, and now use their specific template method internally. They each have their own *Parameters struct.

The heuristic templates make it possible to have heuristics nested within other heuristics, e.g., the real_iterated_local_search uses the real_local_search configuration internally.

examples/bmf.rs Outdated Show resolved Hide resolved
src/heuristics/aco.rs Show resolved Hide resolved
@Saethox Saethox changed the title WIP: Make heuristics usable as components Make heuristics usable as components Aug 29, 2022
@Saethox Saethox requested review from HeleNoir and luleyleo August 29, 2022 14:00
Copy link
Collaborator

@luleyleo luleyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice improvement. Some nits left, then we can merge this.

Comment on lines +30 to +32
pub fn into_builder(self) -> ConfigurationBuilder<P> {
ConfigurationBuilder::new().do_(self.0)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful? I can't really come up with a good use case because you could only append to the end, but not within the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this method might only be used in rather obscure cases, but I figured that an elegant way to append to existing configurations could not hurt.

src/framework/configuration.rs Outdated Show resolved Hide resolved
src/framework/configuration.rs Show resolved Hide resolved
src/framework/configuration.rs Outdated Show resolved Hide resolved
Comment on lines +155 to +156
/// Size of the initial population.
pub initial_population_size: Option<u32>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this optional?

Copy link
Collaborator Author

@Saethox Saethox Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These initialization methods implement both Initialization and Generation, either pushing a new population with initial_population_size on the stack, or regenerating an existing population with a certain size. In the latter use case, no initial_population_size is needed.

src/operators/misc.rs Show resolved Hide resolved
@Saethox Saethox requested a review from luleyleo August 30, 2022 15:33
@HeleNoir HeleNoir merged commit 8ef459e into master Sep 1, 2022
@HeleNoir HeleNoir deleted the heuristic-components branch September 1, 2022 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make existing heuristics usable as components Add Iterated Local Search
3 participants