CAOpt 3.0.7

dotnet add package CAOpt --version 3.0.7
                    
NuGet\Install-Package CAOpt -Version 3.0.7
                    
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="CAOpt" Version="3.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CAOpt" Version="3.0.7" />
                    
Directory.Packages.props
<PackageReference Include="CAOpt" />
                    
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 CAOpt --version 3.0.7
                    
#r "nuget: CAOpt, 3.0.7"
                    
#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.
#addin nuget:?package=CAOpt&version=3.0.7
                    
Install CAOpt as a Cake Addin
#tool nuget:?package=CAOpt&version=3.0.7
                    
Install CAOpt as a Cake Tool

FSharp Script Example

#r "nuget: CAOpt"
open CA

let n = 5.
let A = 10.
let twoPi = 2. * System.Math.PI
let An = n * A

//objective function to be minimized
let rastrigin (xs:float[]) =
    let sum = xs |> Array.map(fun x -> x*x - A*cos(twoPi * x))  |> Array.sum
    An + sum

//define parameters (and associated ranges) that will be searched for optimality
let parms = [|for _ in 1 .. int n -> F(4.,-5.12,5.12) |] 

//Note: 'F' is for float parameters and 'I' (not shown) for integer parameters

//initialize
let mutable step = CALib.API.initCA(parms, rastrigin, Minimize)

//step through till termination criteria is met
//here it is the number of generations (steps)
//you can define your own
for i in 0 .. 15000 do 
    step <- CALib.API.Step step

step.Best.[0].MParms     //best solution parameter values
step.Best.[0].MFitness   //best solution fitness value

//rastrigin [|for _ in 1 .. int n -> 0.0|]      //true solution

//Note: A globally optimum solution is not guaranteed in evolutionary optimization methods. Usually such methods find good approximate solutions
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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
3.0.7 152 4/24/2025
3.0.6 143 4/24/2025
2.0.0 177 3/28/2024
1.0.1 256 4/16/2023
1.0.0 514 4/2/2022
0.9.1 561 5/16/2020
0.9.0 495 5/1/2020

Breaking. Added maxParallelism option to step call. Can be used to reduce resource consumption if fitness function is resource intensive