Skip to content

DanielSlater/ParticleSwarmOptimization

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

ParticleSwarmOptimization

This repo contains 3 implmentations of Particle Swarm Optimization

It goes with these 2 blog posts

If you are looking to use this in an application and want it to run multi-threaded parrallel 2 is the best to use.

Example usage

open ParticleSwarmOptimization_Parallel_2

let target_point = [23.0;54.0]
let loss_func (x : list<float>) =  x |> List.map2 (fun x y -> sin 1.0/x-sin 1.0/y) target_point |> List.sum |> abs
let random = new System.Random()
let initial_weights = seq{ while true do yield [random.NextDouble()*1000.0;random.NextDouble()*1000.0]};

let args = Args(inertia_weight=[0.8; 0.8], particles=10, success_threshold=0.01, iterations = 10);
let (global_best_params, global_best_loss, particles) = execute args loss_func initial_weights;;

printfn "Particles %A" particles
printfn "Best loss %A" global_best_loss

About

First Version

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages