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

Merge Fitness traits with Individual #97

Merged
merged 4 commits into from
Jan 29, 2025

Conversation

dbalcomb
Copy link
Contributor

This merges the Fitness and FitnessMut traits with Individual.

The original intent of having a separate Fitness trait is that some types, such as vectors and arrays, have no obvious fitness value without adding new restrictive trait bounds to infer it from the items. The FitnessMut trait was intended to allow the fitness to be mutated without requiring all individuals allow fitness mutation. However, after #94 the API was changed to return a reference and so by ruling out computed fitness values there is less need for FitnessMut. The only concern there would be allowing the fitness of a primitive to be mutated as that would alter the individual itself and by extension the genome.

This change merges the Fitness and FitnessMut traits into the Individual trait and renames the associated Value to Fitness. This simplifies the API at the cost of allowing the scoring of a primitive such as an integer to alter the individual itself and not just the score.

This includes a new Nil fitness value for individuals that do not have an actual fitness. This makes use of an empty array to construct a static reference to a value that works with both shared and exclusive references. This could be improved with unsafe or perhaps an external crate to construct a ZST but at the moment it only works for empty arrays and slices.

@dbalcomb dbalcomb added package: brace-ec Affects the `brace-ec` package change: feature A new feature labels Jan 29, 2025
@dbalcomb dbalcomb merged commit cd37379 into main Jan 29, 2025
5 checks passed
@dbalcomb dbalcomb deleted the feature/redesign-individual-fitness branch January 29, 2025 21:36
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