OptunaSharp 1.0.0
dotnet add package OptunaSharp --version 1.0.0
NuGet\Install-Package OptunaSharp -Version 1.0.0
<PackageReference Include="OptunaSharp" Version="1.0.0" />
<PackageVersion Include="OptunaSharp" Version="1.0.0" />
<PackageReference Include="OptunaSharp" />
paket add OptunaSharp --version 1.0.0
#r "nuget: OptunaSharp, 1.0.0"
#:package OptunaSharp@1.0.0
#addin nuget:?package=OptunaSharp&version=1.0.0
#tool nuget:?package=OptunaSharp&version=1.0.0
OptunaSharp
Optuna for .NET: a C#/F# port of Optuna, the define-by-run hyperparameter optimization framework, built on NumSharp.
Install
dotnet add package OptunaSharp
The package targets .NET 8 and .NET 10.
Quick start
using OptunaSharp;
var study = Optuna.CreateStudy(direction: StudyDirection.Minimize);
study.Optimize(trial =>
{
double x = trial.SuggestFloat("x", -10, 10);
return (x - 2) * (x - 2);
}, nTrials: 100);
Console.WriteLine(study.BestValue); // ~0
Console.WriteLine(study.BestParams["x"]); // ~2
What this package contains
- Studies and trials:
Optuna.CreateStudy/LoadStudy,Optimize, ask-and-tell, multi-objective directions, constraints, user and system attributes, callbacks. - Distributions and search spaces: float, int and categorical distributions, plus search-space inference for dynamic (define-by-run) spaces.
- Samplers: TPE, CMA-ES, GP, Random, Grid, QMC, BruteForce, PartialFixed, NSGA-II and NSGA-III. It also ships samplers Optuna does not have, among them AGE-MOEA-2, SMS-EMOA, MOEA/D, RVEA, LM-CMA, VkD-CMA, differential evolution, PSO, the natural evolution strategies (OpenAI-ES, SNES, xNES), TuRBO, REMBO, SAASBO and JANUS.
- Pruners: Median, Percentile, SuccessiveHalving, Hyperband, Threshold, Patient, Wilcoxon and Nop.
- Storages: in-memory and journal-file storage, heartbeats and
RetryFailedTrialCallback. - Analysis: parameter importance (fANOVA, mean decrease impurity, PED-ANOVA, SHAP), terminators,
the data layer behind every
plot_*function, and a scikit-learn-styleOptunaSearchCV. - Artifacts: a file-system artifact store.
Companion packages
Anything that needs a foreign runtime or a heavy client library ships separately, so this package
depends only on NumSharp, its OpenBLAS backend and Microsoft.Extensions.DependencyInjection.Abstractions.
| Package | What it adds |
|---|---|
OptunaSharp.Storage.Sqlite |
SQLite RDBStorage, database-compatible with Python Optuna |
OptunaSharp.Storage.EFCore |
PostgreSQL and MySQL RDBStorage over Entity Framework Core |
OptunaSharp.Storage.Grpc |
the gRPC storage proxy, client and server |
OptunaSharp.Storage.StackExchange.Redis, .NRedisStack, .ServiceStack.Redis |
Redis journal backends, one per Redis client, over the shared OptunaSharp.Storage.Redis |
OptunaSharp.Artifacts.S3, .Gcs, .AzureBlob, .R2 |
cloud artifact stores |
OptunaSharp.Visualization.Plotly |
interactive figures for every plot_* function |
OptunaSharp.Integration.LightGbm, .ML.NET |
LightGBMTuner, pruning callbacks and ML.NET-backed importance evaluators |
OptunaSharp.Interop.pythonnet, .BoTorch, .PyCma, .Pymoo |
bridges that drive OptunaHub, BoTorch, pycma and pymoo in-process |
OptunaSharp.Cli |
the optunasharp command-line tool (dotnet tool install -g OptunaSharp.Cli) |
Compatibility target
OptunaSharp tracks Optuna 5.x as its behavioral source of truth: names, defaults, edge cases and error messages follow Optuna. Where OptunaSharp and Optuna differ, Optuna is treated as correct and OptunaSharp is aligned to it. The test suite checks OptunaSharp against live Python Optuna, including seeded runs that must reproduce the values Optuna samples exactly.
Links
- Documentation: https://scisharp.github.io/OptunaSharp
- Source and issues: https://github.com/SciSharp/OptunaSharp
License
MIT. OptunaSharp is a derivative of Optuna (© Preferred Networks, Inc.) and retains its notice —
see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- NumSharp (>= 0.80.0)
- NumSharp.Interop.OpenBLAS (>= 0.80.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- NumSharp (>= 0.80.0)
- NumSharp.Interop.OpenBLAS (>= 0.80.0)
NuGet packages (17)
Showing the top 5 NuGet packages that depend on OptunaSharp:
| Package | Downloads |
|---|---|
|
OptunaSharp.Storage.Redis
Shared, client-agnostic primitives for the OptunaSharp Redis journal backends: the redis:// URL parser (RedisEndpoint / RedisUrl), the Redis key layout, and the atomic append Lua script (RedisJournalProtocol). No Redis client dependency of its own — the StackExchange / NRedisStack / ServiceStack backend packages build on this. Part of the SciSharp STACK. |
|
|
OptunaSharp.Interop.pythonnet
OptunaSharp's bridge to the live Python Optuna ecosystem via Python.NET (pythonnet), most importantly OptunaHub (https://hub.optuna.org/). OptunaHub.LoadModule("samplers/auto_sampler") / ("benchmarks/bbob") mirrors optunahub.load_module, and the loaded contributor packages are wrapped so an OptunaSharp Study can drive them directly: a hub SimpleBaseSampler becomes an OptunaSharp BaseSampler (over a synchronized shadow study), and a hub BaseProblem becomes an OptunaSharp objective (search space + directions + evaluate). The .NET analog of NumSharp.Interop.pythonnet. Requires a discoverable CPython with `pip install optuna optunahub`. Part of the SciSharp STACK. |
|
|
OptunaSharp.Interop.PyCma
PyCmaSampler for OptunaSharp — a native OptunaSharp BaseSampler that drives the real pycma (Nikolaus Hansen's `cma` package: cma.CMAEvolutionStrategy + cma.BoundTransform) library in-process via Python.NET (pythonnet). A faithful C# port of optuna_integration's PyCmaSampler glue (the sampler protocol + the parameter/cma-space transforms + the ask/tell generation replay) whose CMA-ES numerics are direct pycma calls, so it is byte-exact with pycma. Distinct from OptunaSharp's native CmaEsSampler, which ports the separate `cmaes` package — this mirrors Optuna's own optuna.integration.PyCmaSampler vs optuna.samplers.CmaEsSampler split. Does NOT require the Python optuna_integration package — install only `cma`. The .NET analog of using optuna_integration.PyCmaSampler, built on OptunaSharp.Interop.pythonnet. Part of the SciSharp STACK. |
|
|
OptunaSharp.Visualization.Plotly
The plotly visualization backend for OptunaSharp — a raw-C# port of optuna.visualization (the 12 plot_* functions) built on Plotly.NET, over OptunaSharp's Phase 3.1 visualization data layer. Renders interactive plotly.js figures (optimization history, EDF, intermediate values, hypervolume history, parameter importances, slice, Pareto front, contour, rank, parallel coordinate, timeline, terminator improvement) whose figure spec matches live Optuna's. Pure managed (Plotly.NET only — no native dependency). Part of the SciSharp STACK. |
|
|
OptunaSharp.Storage.NRedisStack
Redis journal-log backend for OptunaSharp on NRedisStack — Redis's official .NET client. NRedisStackJournalRedisBackend persists an Optuna study's operation log to a Redis server (standalone or cluster), byte-compatible with Python Optuna and the sibling StackExchange/ServiceStack backends. NRedisStack layers the Redis Stack modules on StackExchange.Redis; a journal needs only plain GET/SET/INCR/EVAL, served via the underlying IDatabase. Part of the SciSharp STACK. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 211 | 11/8/2026 |