Commit Graph

80 Commits

Author SHA1 Message Date
Manuel Raimann 5fe0a75f78 feat: add serde serialization support behind serde feature flag
Add Serialize/Deserialize derives to all public data types (ParamValue,
Distribution, Direction, TrialState, ParamId, AttrValue, CompletedTrial)
gated behind a `serde` feature flag. Introduce StudySnapshot struct and
Study::save()/Study::load() for persisting and restoring study state as
human-readable JSON.
2026-02-11 17:33:48 +01:00
Manuel Raimann dcf3403261 feat: add Study::summary() and Display impl
Add a human-readable summary method and Display trait for Study<V>
where V: Display. The summary shows optimization direction, trial
counts (with complete/pruned breakdown), best value, and best
parameters with their labels.

Also derive PartialOrd + Ord on ParamId for deterministic parameter
ordering in summary output.
2026-02-11 17:27:43 +01:00
Manuel Raimann bb79d98027 chore: release v0.6.0 v0.6.0 2026-02-11 17:24:10 +01:00
Manuel Raimann f4b0631178 feat: add enqueue_trial() for pre-specified parameter evaluation
Add Study::enqueue() to push specific parameter configurations onto a
FIFO queue. The next call to ask()/create_trial() or the next iteration
in optimize() pops the front entry and injects it into the trial so
that suggest_param() returns the pre-filled value instead of sampling.

Parameters missing from an enqueued map fall back to normal sampling,
and once the queue is drained regular sampler-driven trials resume.
2026-02-11 17:23:25 +01:00
Manuel Raimann 52f3c074dc feat: add trial user attributes for logging and analysis
Add AttrValue enum (Float, Int, String, Bool) with From impls and
set_user_attr/user_attr/user_attrs methods on both Trial and
CompletedTrial. Attributes set during optimization are propagated
through complete_trial and prune_trial. AttrValue is re-exported
at crate root and in the prelude.
2026-02-11 17:18:17 +01:00
Manuel Raimann f67188e3a7 feat: add ask() and tell() methods for ask-and-tell interface 2026-02-11 17:11:38 +01:00
Manuel Raimann 72da883add feat: add Study::top_trials(n) for retrieving best N trials
Returns the top N completed trials sorted by objective value,
respecting the study's optimization direction. Pruned and failed
trials are excluded.
2026-02-11 17:08:10 +01:00
Manuel Raimann bc278d83a3 feat: add timeout-based optimization methods (optimize_until)
Add duration-based variants of all optimization methods that run trials
until a wall-clock deadline rather than for a fixed trial count:

- optimize_until(duration, objective)
- optimize_until_with_callback(duration, objective, callback)
- optimize_until_async(duration, objective)
- optimize_until_parallel(duration, concurrency, objective)
2026-02-11 17:06:08 +01:00
Manuel Raimann c586650df4 feat: add From<RangeInclusive> for FloatParam and IntParam 2026-02-11 17:02:18 +01:00
Manuel Raimann cc78a92ed6 feat: add Study::minimize() and Study::maximize() constructor shortcuts 2026-02-11 17:00:35 +01:00
Manuel Raimann 12c35e7cb4 feat: add WilcoxonPruner for statistics-based trial pruning 2026-02-11 16:59:05 +01:00
Manuel Raimann a885d10436 feat: add HyperbandPruner for multi-bracket trial pruning 2026-02-11 16:52:59 +01:00
Manuel Raimann 41150057d6 feat: add SuccessiveHalvingPruner for SHA-based trial pruning 2026-02-11 16:47:57 +01:00
Manuel Raimann a522fb2f34 feat: add PatientPruner for patience-based trial pruning
Wraps any inner Pruner and requires it to recommend pruning for N
consecutive steps before actually pruning. Useful for noisy
intermediate values where a single bad step shouldn't trigger pruning.
2026-02-11 16:40:00 +01:00
Manuel Raimann ec04757740 feat: add PercentilePruner for configurable percentile-based trial pruning
Generalizes MedianPruner with a configurable percentile threshold.
MedianPruner now reuses the shared compute_percentile function at 50%.
2026-02-11 16:36:57 +01:00
Manuel Raimann 432c74b927 feat: add MedianPruner for statistics-based trial pruning
Prunes trials whose intermediate values are worse than the median
of completed trials at the same step. Supports configurable warmup
steps and minimum trial count before pruning activates.
2026-02-11 16:32:03 +01:00
Manuel Raimann 8199ba6b43 feat: add ThresholdPruner for fixed-bound trial pruning 2026-02-11 16:28:22 +01:00
Manuel Raimann abe15bdd7b feat: add TrialPruned error variant and Pruned trial state
- Add `Pruned` variant to `TrialState`
- Add `Error::TrialPruned` variant and standalone `TrialPruned` struct
  with `From<TrialPruned> for Error` for ergonomic `?` usage
- Add `state` field to `CompletedTrial` (defaults to `Complete`)
- Add `Study::prune_trial()` and `Study::n_pruned_trials()`
- `optimize()` and `optimize_with_callback()` detect `TrialPruned`
  errors via Any downcasting and record pruned trials instead of
  failing them
- `best_trial()` / `best_value()` now filter to only `Complete` trials
- Re-export `TrialPruned` from crate root and prelude
2026-02-11 16:24:57 +01:00
Manuel Raimann 4d8af3242b feat: add intermediate values and pruner integration to Trial
- Add report(step, value) and should_prune() methods to Trial
- Store intermediate_values in Trial, copied to CompletedTrial on completion
- Pass pruner through trial factory so trials can consult it
- Rebuild trial factory when pruner is changed via set_pruner()
2026-02-11 16:08:25 +01:00
Manuel Raimann 2651e61b2c feat: add Pruner trait and NopPruner default implementation
Introduce the pruning extension point for the trial pruning system.
The Pruner trait allows deciding whether to stop a trial early based
on intermediate values. NopPruner (never prunes) is the default.
2026-02-11 15:46:56 +01:00
Manuel Raimann d88280c152 chore: release v0.5.1 v0.5.1 2026-02-10 09:30:58 +01:00
Manuel Raimann 0e8fc82201 refactor: update random number generation to use rand::make_rng() and upgrade rand to version 0.10 2026-02-10 09:30:39 +01:00
Manuel Raimann d7ad3f60db chore: release v0.5.0 v0.5.0 2026-02-06 18:55:06 +01:00
Manuel Raimann 5dc81fa0ab Implement Parameters API
- Add `.name()` builder method on all 5 parameter types for custom labels
- Add `CompletedTrial::get(&param)` for typed parameter access
- Add `Display` impl on `ParamValue`
- Add prelude module at `optimizer::prelude::*`
- Shadow `_with_sampler` methods on `Study<f64>` so `optimize()` auto-uses
  the configured sampler; deprecate `_with_sampler` variants
- Use runtime `Any` downcasting with `trial_factory` to avoid E0592
- Update all examples and tests to use the new API

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 18:54:55 +01:00
Manuel Raimann 55e50e6afb Implement Parameters API 2026-02-06 17:15:47 +01:00
Manuel Raimann 2fef1ab3c3 docs: add missing derive feature flag to README
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:51:13 +01:00
Manuel Raimann aa1718fed7 docs: update quick start example to use typed Parameter API
The old example used the removed string-based trial.suggest_float()
API. Updated to use FloatParam::new() with param.suggest(trial).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:50:59 +01:00
Manuel Raimann f9227df96e docs: update features list with boolean, enum, and derive support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:50:43 +01:00
Manuel Raimann 02ec9498c4 refactor: reorganize sampler module and update imports 2026-02-04 13:14:22 +01:00
Manuel Raimann 183a78c09e chore: remove log dependency from Cargo.toml 2026-02-02 17:33:03 +01:00
Manuel Raimann ce817c1f38 feat: add 'consts' to default extended words in typos configuration 2026-02-02 17:32:20 +01:00
Manuel Raimann b9f8844e60 chore: release v0.4.0 v0.4.0 2026-02-02 17:31:35 +01:00
Manuel Raimann d1c8925fc3 refactor: remove warn_independent_sampling option from MultivariateTpeSampler 2026-02-02 17:31:25 +01:00
Manuel Raimann 4ce4311c68 Implement Multivariant TPE 2026-02-02 17:25:50 +01:00
Manuel Raimann 293b992e75 feat: implement gamma strategies for TPE sampler with examples 2026-02-02 13:40:33 +01:00
Manuel Raimann af8a9f7638 feat: add examples for async API parameter optimization and ML hyperparameter tuning 2026-01-31 11:56:50 +01:00
Manuel Raimann b9a90ebec3 Format 2026-01-31 11:56:37 +01:00
Manuel Raimann 24e921b7b9 style: format suggest method for improved readability 2026-01-31 11:45:58 +01:00
Manuel Raimann 6363540269 fix: handle end value in suggest method to avoid panic on underflow 2026-01-31 11:44:33 +01:00
Manuel Raimann 9f3c0f0d3b chore: release v0.3.1 2026-01-31 11:34:36 +01:00
Manuel Raimann 747e1928b9 feat: add tests for suggest_bool and suggest_range methods 2026-01-31 11:34:36 +01:00
Manuel Raimann 15a43d9485 feat: add SuggestableRange trait and suggest_range method for parameter suggestion from ranges 2026-01-31 11:34:36 +01:00
Manuel Raimann 1091429697 feat: add suggest_bool method for boolean parameter suggestion 2026-01-31 11:34:36 +01:00
Manuel Raimann b482d56e89 Implement grid search 2026-01-30 22:01:44 +01:00
Manuel Raimann 90bf73a39f feat: add documentation, keywords, categories, and readme to Cargo.toml 2026-01-30 19:57:21 +01:00
Manuel Raimann 473b973408 feat: add permissions for read access to contents in CI and scheduled workflows 2026-01-30 19:28:47 +01:00
Manuel Raimann d8ef4352c3 refactor: replace TpeError with Error in the optimizer library 2026-01-30 19:24:58 +01:00
Manuel Raimann eb57519506 feat: allow publishing with dirty workspace in CI 2026-01-30 19:23:32 +01:00
Manuel Raimann cb5ecf33f0 chore: release v0.3.0 2026-01-30 19:21:54 +01:00
Manuel Raimann 3898136341 Refactor 2026-01-30 19:21:54 +01:00