Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Development guide

Required checks

Run formatting, linting, and tests from the repository root:

cargo fmt --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

Check the declared minimum supported Rust version separately. The locked workspace must compile with Rust 1.88:

rustup toolchain install 1.88.0
cargo +1.88.0 check --workspace --locked

Exercise the optional PyO3 API through an installed extension:

python -m venv .venv
.venv/bin/python -m pip install "maturin[patchelf]>=1.7,<2" numpy scipy pytest
env -u CONDA_PREFIX VIRTUAL_ENV="$PWD/.venv" \
  PATH="$PWD/.venv/bin:$PATH" \
  .venv/bin/maturin develop --release \
  --manifest-path crates/fcmaes-py/Cargo.toml
.venv/bin/python -m pytest

SciPy is needed only by the retry binding tests, where the extension constructs the public scipy.optimize.Bounds object passed to an optimizer callback.

Before a registry release, also run the package and clean-install checks in RELEASING.md. The Python version is derived from the workspace package version rather than duplicated in pyproject.toml.

Run git diff --check before handing off changes.

Source map

AreaSource
Public Rust exportscrates/fcmaes-core/src/lib.rs
Objective and bounds machinerycrates/fcmaes-core/src/fitness.rs
Optimizerscrates/fcmaes-core/src/{de,cmaes,crfmnes,pgpe,da,biteopt,mode}.rs
Retry coordinatorscrates/fcmaes-core/src/{retry,moretry}.rs
Quality diversitycrates/fcmaes-core/src/mapelites.rs
Python registrationcrates/fcmaes-py/src/lib.rs
Optional PyO3 surfacecrates/fcmaes-py/src/
GTOP implementationcrates/fcmaes-gtop/src/lib.rs
GTOP names and boundsexamples/src/problems.rs
CLI and DE→CMA runnerexamples/src/runner.rs
Native binary entry pointsexamples/src/bin/
Native Mazda evaluator and objectivesexamples/src/mazda.rs, examples/src/mazda_model.rs
Trading model and Yahoo cacheexamples/src/trading.rs
Factory material-flow objectiveexamples/src/material_flow_planning.rs
Combinatorial encoding reference helpersexamples/src/encoding.rs
Buckingham–Pi analysis and regressionexamples/src/buckingham.rs
Job-shop and harvesting objectivesexamples/src/{jobshop,harvesting}.rs
Harmonic and transfer-scheduling objectivesexamples/src/{tdesign,scheduling}.rs
ODE/control objectivesexamples/src/{damp,f8,lotka,integration}.rs
Standalone application tutorialstutorials/*/
Room-ventilation backend and verificationtutorials/cfd-room-ventilation/src/
SmartCore HPO protocol and probability foresttutorials/ml-hyperparameter-tuning/src/
Neural controller, rollout model, and policy-search protocoltutorials/neural-controller-policy-search/src/
Tutorial artifact rendering and link checkstutorials/python/

Generate rustdoc

RUSTDOCFLAGS="-D warnings" cargo doc -p fcmaes-core --no-deps
cargo doc --workspace --no-deps

fcmaes-core denies missing public documentation and broken intra-doc links. Add rustdoc comments to every public module, type, field, constant, function, and method when extending the API. Public solver modules should include a runnable example and cite the primary algorithm literature. Use intra-doc links such as [`De::optimize`] where the target is in the same crate. Keep this directory focused on workflows and architecture rather than duplicating every generated signature.

Rust nightly’s coverage display (or the equivalent bootstrap command used for local auditing) reports the exact documented-item ratio:

RUSTC_BOOTSTRAP=1 cargo rustdoc -p fcmaes-core --lib -- \
  -Z unstable-options --show-coverage

The 0.1.3 release reports 399/399 public items documented. The compile-time lint and CI documentation build prevent that count from silently regressing.

Build the documentation site

Install the pinned mdBook release once:

cargo install mdbook --no-default-features --features search \
  --version "^0.5.4" --locked

Then assemble and build the site from the canonical repository content:

python scripts/check_doc_consistency.py
python scripts/build_book.py
python scripts/check_book_links.py

The consistency check derives tutorial and package counts from the tree and verifies the repeated inventories, registry-pin count, MODE count, release-tag command, and workspace lockfile versions. The build writes staged input to target/mdbook-src and rendered HTML to target/book. The book/SUMMARY.md file controls navigation. Do not edit the staged files; change the corresponding README, guide, tutorial, or benchmark instead. The rendered-link check validates pages, assets, and anchors after mdBook has applied its output-path rules. The documentation workflow checks the build on pull requests and deploys main through GitHub Pages. Repository administrators need to select GitHub Actions once under Settings → Pages → Build and deployment → Source.

Testing strategy

Optimizer parity is statistical, not bit-exact across languages. Fixed-seed Rust tests should be deterministic, while cross-language acceptance should compare distributions, success rates, and budget use.

The test layers are:

  • Core unit tests beside each Rust module.
  • GTOP reference and helper tests in fcmaes-examples.
  • PyO3 compilation as part of the workspace build and Python-level integration tests under crates/fcmaes-py/python_tests/.
  • Reproducible native performance workloads in benchmarks/.
  • Standalone tutorial tests plus byte-for-byte figure and local-link checks under tutorials/.

When adding a public parameter, test its default, a non-default path, invalid input, result accounting, and stop behavior. Ask/tell interfaces also need call-order and batch-length tests.

Coverage

If cargo-llvm-cov is installed:

cargo llvm-cov --workspace --all-targets --summary-only

Coverage is a diagnostic, not a substitute for convergence and parity tests. Optimization code needs tests that exercise update behavior and result quality, not only line execution.

Adding an optimizer

  1. Implement numerics in fcmaes-core without Python dependencies.
  2. Define explicit parameter and result structs and re-export them from fcmaes-core/src/lib.rs.
  3. Add one-shot convergence tests and stateful contract tests when applicable.
  4. Add an optional PyO3 wrapper only after the core API is stable.
  5. Register that binding in crates/fcmaes-py/src/lib.rs.
  6. Add deterministic convergence and API-contract evidence.
  7. Update rustdoc and these guides.

Adding a GTOP problem or CLI option

Add objective numerics to gtop.rs, then add a named Problem with validated bounds in problems.rs. Add name aliases to by_name, reference-value tests, and catalog coverage. Shared CLI options belong in runner::Cli; both binaries should continue to use the same parser.

Progress output belongs on stderr so stdout remains usable by benchmark and automation code.

Performance checks

  • Always build with --release before timing.
  • Exclude compilation from timed samples.
  • Report workers, retries, configured budgets, and actual evaluations.
  • Distinguish retry threads from optimizer population threads.
  • Match optimizer configuration, evaluation budgets, retries, workers, stop conditions, and input data before comparing two runs.
  • Store raw samples next to the benchmark report.