Skip to content

feat(problems): binary and combinatorial problems, batch 12, each with its own example - #421

Merged
tachsin merged 7 commits into
mainfrom
feat/problems-batch-12
Oct 2, 2026
Merged

tachsin merged 7 commits into
mainfrom
feat/problems-batch-12

Conversation

@tachsin

@tachsin tachsin commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Batch 12 of docs/problems-plan.md (#260): binary and combinatorial problems, in a new problems::binary module and gx.problems.binary. Each problem has its own example page, and each example's main method reaches the known optimum.

Problem Source read Example (main method, success over seeds)
OneMax Droste, Jansen and Wegener 2002, Def. 9, Lemma 10 one_max, now on the problem: 100/100
LeadingOnes Droste et al. 2002, Def. 16, Thm. 17 (Rudolph's example, as they credit) leading_ones: the (1+1) EA, 100/100, between n²/6 and e·n² steps
Deceptive trap Deb and Goldberg 1993 (FOGA 2), eq. 1, Thm. 1, ineq. 16 deceptive_trap: a GA with two-point crossover, 20/20; contrasts: uniform crossover 0/20, hill climbing
Royal road R1 Mitchell, Holland and Forrest 1994 (NIPS 6), Fig. 1, Table 1 royal_road_r1: random-mutation hill climbing 200/200, mean 6,793 evaluations (paper 6,179)
Royal road R2 Mitchell, Forrest and Holland 1992 (ECAL), Fig. 1 royal_road_r2: the paper's GA, 50/50, median 478 generations (paper 542)
NK landscapes Kauffman and Weinberger 1989, eq. 1, Tables 1-2 nk_landscape, N = 20, K = 4: iterated local search reaches the exhaustive optimum 20/20 per landscape
0/1 knapsack, Pisinger's 11 instance classes Pisinger 2005, sections 3 and 3.3, eq. 5 knapsack, now on a generated instance: 20/20 to the DP optimum; contrast: strongly correlated, 2/20

Reproducible: 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:

  • NK: dynamic programming over the circle, or exhaustive Gray-code search.
  • Knapsack: Bellman's DP.
  • Both are tested against brute force.

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:

  • odd K in NK;
  • keeping p ≥ 1 in the weakly correlated class;
  • rounding the circle class's profits;
  • the concatenated trap's form.

…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
tachsin force-pushed the feat/problems-batch-12 branch from 99cb099 to 6fdfb43 Compare October 2, 2026 16:57
@tachsin
tachsin merged commit 8f50416 into main Oct 2, 2026
22 checks passed
@tachsin
tachsin deleted the feat/problems-batch-12 branch October 2, 2026 17:39
@tachsin tachsin mentioned this pull request Oct 2, 2026
18 tasks done
@github-actions github-actions Bot mentioned this pull request Oct 2, 2026
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>
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.

1 participant