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

Add HillClimb selector evaluate methods #119

Merged
merged 3 commits into from
Feb 8, 2025

Conversation

dbalcomb
Copy link
Contributor

@dbalcomb dbalcomb commented Feb 8, 2025

This adds a new evaluate method to the HillClimb selector.

The HillClimb selector is a composition of a selector and a mutator that simply returns the best individual within a set of iterations. The implementation relies on the mutated individuals being correctly evaluated so that the best fitness individual can be chosen. This requires users to call evaluate on the mutator passed in. It may also require users to call evaluate on the selected individual but this depends on whether the selected individual has previously been evaluated. Calling evaluate on the HillClimb type itself is almost never what you want as it would result in the selected individual being evaluated which should already happen within the selector.

This change introduces new evaluate_iterations and evaluate_mutations methods on the HillClimb selector that transform the inner operators. The former adapts both the selector and mutator with the given evaluator, requiring the Clone bound, whereas the latter adapts just the inner mutator with the given evaluator.

These methods are an alternative to chaining on the selector and/or mutator directly but otherwise provide no new functionality. The original plan was to override the evaluate method but it is possible that users will want to hill climb with a separate evaluator and then evaluate again. The evaluate_iterations method ensures that both the selected and mutated individuals are evaluated consistently whereas the evaluate_mutations method assumes that the selected individual has already been evaluated.

@dbalcomb dbalcomb added package: brace-ec Affects the `brace-ec` package change: feature A new feature labels Feb 8, 2025
@dbalcomb dbalcomb changed the title Add HillClimb::evaluate method Add HillClimb selector evaluate methods Feb 8, 2025
@dbalcomb dbalcomb merged commit 22bcc17 into main Feb 8, 2025
5 checks passed
@dbalcomb dbalcomb deleted the feature/add-hill-climb-evaluate branch February 8, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change: feature A new feature package: brace-ec Affects the `brace-ec` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant