Skip to content

Feature/memetic - #658

Open
luishpmendes wants to merge 4 commits into
esa:masterfrom
luishpmendes:feature/memetic
Open

luishpmendes wants to merge 4 commits into
esa:masterfrom
luishpmendes:feature/memetic

Conversation

@luishpmendes

Copy link
Copy Markdown
Contributor

Summary

This PR introduces optional in-place modification of decision vectors during fitness evaluation, enabling memetic optimization techniques such as BRKGA-style chromosome rewriting.

Changes

  • Introduce fitness_rewrite() and has_fitness_rewrite() in the problem interface.
  • Support chromosome rewriting in population management and batch fitness evaluators.
  • Update compatible optimization algorithms to preserve rewritten chromosomes and their corresponding fitness values.
  • Add regression tests, documentation, and an example demonstrating chromosome rewriting in a multiobjective optimization problem.

Compatibility

The feature is optional and preserves existing behavior for problems that do not implement chromosome rewriting. Existing fitness() interfaces remain unchanged.

Motivation

Memetic algorithms often improve chromosomes during decoding through local search. This enhancement allows these improvements to be preserved in the population and inherited by subsequent generations.

luishpmendes and others added 3 commits October 18, 2026 15:56
…ators

- Implemented a snapping mechanism for decision vectors in `snap_udp` and `snap_udp_batch` to align with a grid, enhancing fitness evaluation.
- Added tests for fitness rewriting capabilities in `population`, `problem`, and `thread_bfe` to ensure correctness and thread safety.
- Introduced a new tutorial demonstrating the use of a rewriting decoder for a bi-objective traveling salesman problem using random keys.
- Enhanced type traits to check for fitness rewriting capabilities in user-defined problems.
…_adaptive

- nlopt and ipopt now rewrite the final solution they find (via
  problem::fitness_rewrite()) before comparing it with the selected
  individual; the points evaluated during the local optimisation are
  still plain evaluations. For rewriting problems, ipopt first projects
  its final point into the bounds, since Ipopt may relax them.
- The penalized problem used internally by cstrs_self_adaptive now
  implements fitness_rewrite() and has_fitness_rewrite(), forwarding the
  rewriting to the original problem and caching the rewritten decision
  vectors, so that its inner algorithm stores them.
- Document that cmaes and xnes deliberately never rewrite the decision
  vectors they sample, and how nlopt, ipopt and cstrs_self_adaptive
  handle rewriting.
- Add regression tests: cstrs_self_adaptive forwarding and caching,
  nlopt/ipopt rewriting exactly the final solution, and cmaes/xnes
  never calling fitness_rewrite().

Problems which do not rewrite are not affected, and the archive formats
are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the scout bee phase, the abandoned food source was replaced (and the
population updated consistently), but the internal fitness array kept
the fitness of the abandoned source. The subsequent comparisons and
onlooker selection probabilities thus used a stale value. This changes
the results of seeded bee_colony runs whenever a scout bee is triggered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 21:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

The fitness_rewrite() and has_fitness_rewrite() methods of prob_inner_base
and bfe_inner_base are not pure virtual, so that the specialisations of
prob_inner and bfe_inner written outside pagmo (e.g., by pygmo) keep
compiling. Test them via such specialisations: a binding written before
the introduction of fitness_rewrite() does not rewrite and behaves as
before, while a binding which advertises the rewriting capability without
implementing it gets a not_implemented_error, with the decision vectors
and the fevals counter left untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@darioizzo

Copy link
Copy Markdown
Member

memetic algorithm can be implemented also in the current code as meta-problems though. The fitness of the meta-problem would call life long learning on the chromosome, returning a fitness that associated to the untouched chromosome.

This branch has not been deployed

No deployments
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.

3 participants