Skip to content

feat(problems): gradients for batch 10b's functions, and gradients and constraint values through Shifted and Rotated - #420

Merged
tachsin merged 4 commits into
mainfrom
feat/problem-gradients
Oct 2, 2026
Merged

tachsin merged 4 commits into
mainfrom
feat/problem-gradients

Conversation

@tachsin

@tachsin tachsin commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Closes #416.

Analytic gradients for 14 of batch 10b's functions (FitnessFunction::provides, evaluate_with):

  • sum of different powers, the noiseless quartic, Penalized 1 and 2;
  • the high-conditioned elliptic, bent cigar, discus, different powers;
  • Büche-Rastrigin, Weierstrass, HappyCat, HGBat, Schaffer F7 and the rotated hyper-ellipsoid.

How they behave at the awkward points:

  • Kinks follow Ackley's convention: where a term has a kink on a set of measure zero, its gradient there is 0. The kinks of different powers, HappyCat, HGBat and Schaffer F7 lie at their minima, so the gradient there is exactly 0.
  • Weierstrass computes its phase from x, using sin(2πbᵏ(x + 0.5)) = −sin(2πbᵏx) for odd bᵏ. That makes its gradient exactly 0 at the minimum, where the naive formula leaves about 0.05 from rounding.
  • The value always comes from evaluate, so it is identical to the bit.

No gradient, each with its reason in the docs:

  • Step and the non-continuous Rastrigin (flat steps);
  • Katsuura (kinks 2⁻³³ apart);
  • the noisy quartic, whose noise makes it jump between any two genomes. It gives the gradient only when built without noise.

Wrappers:

  • Shifted passes the wrapped problem's extras through unchanged.
  • Rotated returns Mᵀ∇f(y) and J·M for the constraint Jacobian, at y = c + M(x − c).
  • provides() reflects the wrapped problem's, so a shifted or rotated G06 keeps its constraint values, for Bayesian optimization.
  • The Python adapter behind the wrappers passed on only the fitness; it now passes the gradient and constraint values too.

Tests:

  • gradient::check at 200 random points per function, within 5e-8 beyond the differences' own rounding.
  • Büche-Rastrigin by Richardson extrapolation.
  • Weierstrass through its partial sums, since rounding in its top terms' phases defeats finite differences on the full sum.
  • The wrappers' gradients and Jacobians against central differences, with the value bits unchanged.
  • L-BFGS-B with supplied gradients on a rotated, shifted elliptic, to 6e-22.
  • Python: gx.Lbfgsb, and gx.Bo with a wrapped G24.

Fourteen of batch 10b's functions now provide their gradient through
`FitnessFunction::provides` and `evaluate_with`: the sum of different
powers, the quartic without noise, the two penalized functions, the
high-conditioned elliptic, the bent cigar, the discus, BBOB's different
powers, Büche-Rastrigin, Weierstrass, HappyCat, HGBat, Schaffer F7 and
the rotated hyper-ellipsoid. At a kink of measure 0 (the cones and cusps
of different powers, HappyCat, HGBat and Schaffer F7), the kinked term's
gradient is 0, as Ackley's at its cone.

No gradient for the step function and the non-continuous Rastrigin
(flat steps), Katsuura (kinks 2^-33 apart) and the noisy quartic, whose
genome-seeded noise jumps between any two genomes.

Each is checked with `gradient::check` at random points; Büche-Rastrigin
with Richardson's extrapolation at finer steps, and Weierstrass on its
partial sums, whose highest terms no differences resolve.
…otated

`Shifted<P>` and `Rotated<P>` now provide what the wrapped problem
provides. A shift passes the extras of `x - o` through unchanged; a
rotation evaluates at `c + M (x - c)` and turns the gradient back by the
chain rule, `M^T grad f`, and each row of the constraints' Jacobian
likewise (`J M`). A shifted or rotated G06 keeps its constraint values
for MMA and Bayesian optimization.

The `problems` docs now say which functions supply gradients, and what
the wrappers pass on.
… Rust

`gx.problems.Shifted` and `gx.problems.Rotated` wrap their problem in an
adapter that forwarded only the fitness, so the wrappers lost its
gradient and constraint values. It now forwards `provides` and
`evaluate_with`: `gx.Lbfgsb(..., gradients="supplied")` runs on a shifted
and rotated elliptic with its analytic gradient, and `gx.Bo` sees a
shifted or rotated G24's constraints as its own. The problems' docs say
which functions have a gradient, and what the wrappers pass on.
…ted pass on

AGENTS.md, docs/features.md and the plan no longer say that the CEC- and
BBOB-style functions and the wrappers have no gradient: they list the
seven functions without one and the wrappers' chain rule. The wrapper
docs say that a constrained problem's values reach `Bo`, and `Mma` only
with their Jacobian, which MMA requires.
@tachsin
tachsin merged commit 147d5c8 into main Oct 2, 2026
22 checks passed
@tachsin
tachsin deleted the feat/problem-gradients branch October 2, 2026 16:20
@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.

feat(problems): gradients for batch 10b's functions, and gradients and constraint values through Shifted and Rotated

1 participant