feat(problems): binary and combinatorial problems, batch 12, each with its own example - #421
Merged
Merged
Conversation
…s, the deceptive trap, the royal roads, NK landscapes and the 0/1 knapsack problems::binary holds six problems on Binary genomes, all maximized, each a FitnessFunction of Bits and a Problem with its optimum: - OneMax and LeadingOnes (Droste, Jansen and Wegener 2002, Definitions 9 and 16); - Trap: concatenated blocks of Deb and Goldberg's (1993) trap function, a = k - 1, b = k and z = k - 1 by default (fully deceptive for k >= 3), any a, b and z with with_values; - RoyalRoad: R1 (Mitchell, Holland and Forrest 1994) and R2 (Mitchell, Forrest and Holland 1992), and both forms for other sizes; - NkLandscape: Kauffman and Weinberger's model with adjacent or random neighborhoods, drawn from a seed with StreamRng; contributions are odd multiples of 2^-53 added up as integers, so the fitness is exact and the same everywhere; the optimum by dynamic programming over the circle (adjacent) or exhaustive search in Gray code order; - Knapsack: Pisinger's (2005) generated classes (uncorrelated, weakly, strongly, inverse strongly and almost strongly correlated, subset sum, similar weights, spanner, multiple strongly correlated, profit ceiling, circle) with eq. 5's capacity, fitness (profit, violation), and the optimum by Bellman's recursion. Tests check the definitions on hand-worked cases, full deception by enumerating the schemas, the optima against brute force, the generators' fixed values to the bit, and the errors.
…ms evaluated in Rust OneMax, LeadingOnes, Trap, RoyalRoad (r1, r2), NkLandscape and Knapsack (Pisinger's classes, by name or with Spanner, MultipleStronglyCorrelated, ProfitCeiling and Circle for their parameters), and KnapsackItems for given items. Each is a Problem[Binary], maximized; runs evaluate it in Rust and check that the genome is a Binary of its bits and the objective "maximize". The optimum of the NK landscapes and the knapsack is computed once, when first asked for (problem_optimum, without the GIL); NkLandscape gives its neighbors and contributions and the knapsacks their weights, profits and capacity, the same as in Rust to the bit. NK landscapes take more than 2^30 steps to solve no longer: their optimum is None beyond.
…n the new problems New examples, each in Rust and Python with the same output, a README, output.txt and a trace for the page's plot: - leading_ones: the (1+1) evolutionary algorithm on 100 bits, 100 of 100 seeds at the optimum; - deceptive_trap: 10 fully deceptive blocks of 4 bits, a GA with two-point crossover (20 of 20 seeds), against uniform crossover and hill climbing, which don't reach it; - royal_road_r1: random-mutation hill climbing (200 of 200 runs, mean 6793 evaluations, against the paper's 6179 and its expected 6549) and a GA with the paper's settings; - royal_road_r2: the GA of the 1992 paper's settings (50 of 50 seeds, median 478 generations, against its 542), and hill climbing, which takes the same steps as on R1; - nk_landscape: iterated local search on N = 20, K = 4, checked against exhaustive search, 20 of 20 seeds on each of 5 landscapes, with a GA as a contrast. one_max runs on problems::binary::OneMax, with the same output. knapsack runs on an instance of Pisinger's uncorrelated class (20 of 20 seeds at the dynamic-programming optimum), with a strongly correlated instance as a contrast. The royal roads share a family on the site.
…s, the Python README and the problems plan (batch 12 done) AGENTS.md's test-problem list and docs/features.md name problems::binary; the Python README shows gx.problems.binary with a knapsack. The plan marks batch 12 done, its problems verified in their originals, with a "Checked in batch 12" note of what was read: Droste, Jansen and Wegener (2002), Ackley (1987), Deb and Goldberg (1993, whose "fully deceptive only for l < 7" holds for 3 and 4 bits only by its own inequality 16), Mitchell, Forrest and Holland (1992), Mitchell, Holland and Forrest (1994), Kauffman and Weinberger (1989) and Pisinger (2005). DOIs checked with Crossref.
tachsin
force-pushed
the
feat/problems-batch-12
branch
from
October 2, 2026 16:57
99cb099 to
6fdfb43
Compare
18 tasks done
Merged
tachsin
pushed a commit
that referenced
this pull request
Oct 2, 2026
## 🤖 New release * `genoxide`: 0.13.0 -> 0.13.1 (✓ API compatible changes) * `genoxide-python`: 0.13.0 -> 0.13.1 <details><summary><i><b>Changelog</b></i></summary><p> ## `genoxide` <blockquote> ## [0.13.1](v0.13.0...v0.13.1) - 2026-10-02 ### <!-- 0 -->Added - shift and rotation wrappers and seventeen CEC- and BBOB-style functions, each with its own example ([#409](#409)) - *(moead)* MOEA/D-DE, differential evolution in place of the crossover (Li and Zhang 2009) ([#418](#418)) - the constrained DTLZ8 and DTLZ9, the DC-DTLZ and the DAS-CMOP problems, each with its own example ([#414](#414)) - *(problems)* gradients for batch 10b's functions, and gradients and constraint values through Shifted and Rotated ([#420](#420)) - *(problems)* binary and combinatorial problems, batch 12, each with its own example ([#421](#421)) ### <!-- 4 -->Documentation - *(ctp)* CTP1-CTP8 checked against the published paper and Deb's 2001 book ([#419](#419)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch 12 of docs/problems-plan.md (#260): binary and combinatorial problems, in a new
problems::binarymodule andgx.problems.binary. Each problem has its own example page, and each example's main method reaches the known optimum.one_max, now on the problem: 100/100leading_ones: the (1+1) EA, 100/100, between n²/6 and e·n² stepsdeceptive_trap: a GA with two-point crossover, 20/20; contrasts: uniform crossover 0/20, hill climbingroyal_road_r1: random-mutation hill climbing 200/200, mean 6,793 evaluations (paper 6,179)royal_road_r2: the paper's GA, 50/50, median 478 generations (paper 542)nk_landscape, N = 20, K = 4: iterated local search reaches the exhaustive optimum 20/20 per landscapeknapsack, now on a generated instance: 20/20 to the DP optimum; contrast: strongly correlated, 2/20Reproducible: NK tables and knapsack instances are drawn with genoxide's portable RNG. NK contributions are summed as integers in units of 2⁻⁵³, so values are identical to the bit everywhere. Fixed-value tests in Rust and Python.
Exact optima:
Erratum: Deb and Goldberg write that Ackley's traps are fully deceptive "only for ℓ < 7". By their own inequality 16, and by enumerating every schema, only ℓ = 3 and 4 are. A test records it.
Documented choices where the sources are silent: