DotNetNelderMead 1.0.0

dotnet add package DotNetNelderMead --version 1.0.0
                    
NuGet\Install-Package DotNetNelderMead -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetNelderMead" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetNelderMead" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DotNetNelderMead" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetNelderMead --version 1.0.0
                    
#r "nuget: DotNetNelderMead, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetNelderMead@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetNelderMead&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DotNetNelderMead&version=1.0.0
                    
Install as a Cake Tool

DotNetNelderMead

NuGet Downloads CI .NET License: MIT

Introduction

DotNetNelderMead is a .NET implementation of the Nelder–Mead simplex method — a derivative-free local optimizer for continuous functions. It is a sibling of DotNetDifferentialEvolution: both share the DotNetOptimization.Abstractions contracts, so a single objective implementation drives either optimizer, and the two compose into a hybrid (memetic) pipeline.

All objectives are minimized (lower fitness is better).

Features

  • Standard and adaptive coefficients — classic Nelder–Mead (1965), or the dimension-adaptive set of Gao & Han (2012) for better behavior in higher dimensions.
  • Automatic restarts — reinitialize the simplex around the best vertex on convergence to escape premature collapse.
  • Bounded domains — box constraints handled by projecting candidates into range.
  • Parallel multi-start — run many independent simplices across processors and keep the best.
  • Composable termination — built-in convergence / iteration / evaluation / stagnation limits, plus a pluggable ITerminationStrategy.
  • Hybrid with Differential Evolution — a sequential DE→Nelder–Mead handoff and an in-pipeline memetic refiner (DotNetNelderMead.DifferentialEvolution).

Installation

Requires the .NET SDK 8.0 or higher.

dotnet add package DotNetNelderMead

Usage

Implement the shared objective contract (IFitnessFunctionEvaluator from DotNetOptimization.Abstractions):

using DotNetOptimization.Abstractions;

public sealed class RosenbrockEvaluator : IFitnessFunctionEvaluator
{
    public double Evaluate(ReadOnlySpan<double> g)
        => Math.Pow(1.0 - g[0], 2) + 100.0 * Math.Pow(g[1] - g[0] * g[0], 2);

    public double Evaluate(int workerIndex, ReadOnlySpan<double> g) => Evaluate(g);
}

Then build and run the optimizer:

using DotNetNelderMead;

var result = NelderMeadBuilder
    .ForFunction(new RosenbrockEvaluator())
    .StartingFrom(new[] { -1.2, 1.0 })
    .WithAdaptiveCoefficients()          // or WithStandardCoefficients() (default)
    .WithConvergence(domainTolerance: 1e-10, functionTolerance: 1e-10)
    .Build()
    .Run();                              // or await ...RunAsync()

Console.WriteLine($"f = {result.Best.FitnessFunctionValue} after {result.IterationCount} iters");

result.Best is an ISolution (Genes + FitnessFunctionValue); result also reports IterationCount, EvaluationCount, RestartCount, Converged, and TerminationReason.

Bounds, restarts, and parallel multi-start

var result = NelderMeadBuilder
    .ForFunction(evaluator)
    .WithBounds(lowerBound, upperBound)
    .WithUniformStart()                  // sample the start within the bounds
    .WithRestarts(maxRestarts: 5)
    .WithMultiStart(16)                  // 16 independent simplices, parallel; or UseAllProcessors()
    .WithMaxEvaluations(200_000)
    .Build()
    .Run();

Hybridizing with Differential Evolution

Install the integration package:

dotnet add package DotNetNelderMead.DifferentialEvolution

Sequential handoff — polish a global-search result with a local Nelder–Mead refinement. Because the DE result is an ISolution, it seeds the simplex directly:

using DotNetNelderMead;

var de = DifferentialEvolutionBuilder.ForFunction(evaluator) /* ... */ .Build();
var deResult = await de.RunAsync();
deResult.MoveCursorToBestIndividual();

var refined = NelderMeadBuilder
    .ForFunction(evaluator)
    .WithBounds(lowerBound, upperBound)
    .StartingFrom(deResult.IndividualCursor)   // ISolution → start point
    .Build()
    .Run();

Memetic / in-pipeline — run a Nelder–Mead polish every N generations inside the DE loop, feeding the improvement straight back into the population (SHADE / L-SHADE adaptive state is preserved):

using DotNetNelderMead.DifferentialEvolution;

var de = DifferentialEvolutionBuilder
    .ForFunction(evaluator)
    .WithBounds(lowerBound, upperBound)
    .WithPopulationSize(60)
    .WithUniformPopulationSampling()
    .WithJde()
    .WithTerminationCondition(new LimitGenerationNumberTerminationStrategy(500))
    .UseAllProcessors()
    .WithNelderMeadLocalSearch(evaluator, everyNGenerations: 25)
    .Build();

var result = await de.RunAsync();

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DotNetNelderMead:

Package Downloads
DotNetNelderMead.DifferentialEvolution

Hybrid / memetic integration between DotNetNelderMead and DotNetDifferentialEvolution: a Nelder–Mead local-search refiner for the DE pipeline (run every N generations) and a sequential DE→Nelder–Mead handoff.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 89 6/3/2026