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" />
<PackageReference Include="CAOpt" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=CAOpt&version=3.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
net9.0
- FSharp.Collections.ParallelSeq (>= 1.2.0)
- FSharp.Control.AsyncSeq (>= 3.2.1)
- FSharp.Core (>= 9.0.202)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Breaking. Added maxParallelism option to step call. Can be used to reduce resource consumption if fitness function is resource intensive