Quipu 0.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Quipu --version 0.5.1                
NuGet\Install-Package Quipu -Version 0.5.1                
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="Quipu" Version="0.5.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Quipu --version 0.5.1                
#r "nuget: Quipu, 0.5.1"                
#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.
// Install Quipu as a Cake Addin
#addin nuget:?package=Quipu&version=0.5.1

// Install Quipu as a Cake Tool
#tool nuget:?package=Quipu&version=0.5.1                

Quipu

Quipu is a dotnet implementation of the Nelder–Mead method. It is a numerical solver used to find the minimum or maximum of a function. It is particularly useful for nonlinear optimization problems for which derivatives may not be known.

Example usage

The solver can be used from F# and C#, with similar APIs.

Let's use Quipu to find the minimum of f(x,y) = (x-1)^2 + (y-2)^2 + 42.

This function has a unique global minimum, for x=1,y=2.

Basic usage, F# pipeline

open Quipu

let f (x, y) = pown (x - 1.0) 2 + pown (y - 2.0) 2 + 42.0

let solverResult =
    NelderMead.objective f
    |> NelderMead.minimize

Expect.isTrue (solverResult.HasSolution) "should have a solution"
let solution = solverResult.Solution
Expect.isTrue (solution.Status = Status.Optimal) "should be optimal"
Expect.isWithin 0.001 solution.Candidate.Value 42.0 "minimum should be at 42"
Expect.isWithin 0.001 solution.Candidate.Arguments[0] 1.0 "x should be at 1"
Expect.isWithin 0.001 solution.Candidate.Arguments[1] 2.0 "y should be at 2"

Basic usage, C# fluent interface

using Quipu.CSharp;

Func<Double,Double,Double> f =
    (x, y) => Math.Pow(x - 1.0, 2) + Math.Pow(y - 2.0, 2) + 42.0;

var result =
    NelderMead
        .Objective(f)
        .Minimize();

Assert.True(result.HasSolution);
var solution = result.Solution;
Assert.Equal(Status.Optimal, solution.Status);

Assert.Equal(42.0, solution.Candidate.Value, 0.001);
Assert.Equal(1.0, solution.Candidate.Arguments[0], 0.001);
Assert.Equal(2.0, solution.Candidate.Arguments[1], 0.001);

Advanced usage

The solver provides more fine grained control if needed, see the test suite for more examples:

open Quipu

let f (x, y) = pown (x - 1.0) 2 + pown (y - 2.0) 2 + 42.0

let tolerance = 0.000_0001

let solverResult =
    NelderMead.objective f
    |> NelderMead.withTolerance tolerance
    |> NelderMead.startFrom (Start.around [ 100.0; 100.0])
    |> NelderMead.minimize

Expect.isTrue (solverResult.HasSolution) "should have a solution"
let solution = solverResult.Solution
Expect.isTrue (solution.Status = Status.Optimal) "should be optimal"
Expect.isWithin tolerance solution.Candidate.Value 42.0 "minimum should be at 42"
Expect.isWithin tolerance solution.Candidate.Arguments[0] 1.0 "x should be at 1"
Expect.isWithin tolerance solution.Candidate.Arguments[1] 2.0 "y should be at 2"
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.2 97 12/26/2024
0.5.1 88 12/23/2024
0.5.0 93 12/22/2024
0.4.0 85 12/14/2024
0.3.1 87 12/9/2024
0.3.0 131 12/8/2024
0.2.3 116 5/1/2024
0.2.2 156 4/19/2024
0.2.1 250 12/5/2023
0.2.0 176 11/8/2023
0.1.1 128 12/1/2023
0.1.0 191 4/16/2023