Giter Club home page Giter Club logo

pony-pso's Introduction

Pony package for Particle Swarm Optimization

An implementation of the Particle Swarm Optimization algorithm[1] in Pony, with support for dissipative variations[2] and inertia weight strategies[3]. PSO is a population based global stochastic optimization technique inspired by social behavior of bird flocking or fish schooling.

Building

This software depends on the development version of ponyc, the Pony language compiler. You should build and install the compiler from ponyc's source repository.

Execute ./build.sh -e to compile all the examples. You will find the executables in the bin/ folder.

Usage

use "pso"

actor Main
  new create(env: Env) =>

    let params = recover val
        let p = SwarmParams(2)
        p.max = [5000, 5000]
        p.min = [-5000, -5000]
        consume p
    end

    let sw = Swarm(params,
        SwarmLog(env),
        object is FitnessFunc
            fun apply(x: Array[F64]): F64 ? =>
                (x(0) - 200).abs() + (x(1) - 200).abs()
        end)

    sw.solve()

Supported Parameters

c1 : Cognitive factor. Usually c1 equals to c2 and ranges from [0, 4].

c2 : Social factor.

cv : Chaos velocity factor, in the range [0, 1].

cl : Chaos location factor, in the range [0, 1].

max : Maximum values of the search space.

min : Minimum values of the search space.

vmax : Maximum velocity.

particles : Number of particles. Typical range is [20, 40]. Actually for most of the problems 10 particles is large enough to get good results. For some difficult or special problems, one can try 100 or 200 particles as well.

precision : Number of decimal figures per dimension.

inertia : Inertia weight function.

stagnation : Maximum iterations without a global fit. Termination condition.

target : Target cost value for the optimization problem. Termination condition.

iterations : Maximum number of iterations. Termination condition.

Examples

Take a look to the source code in the examples/ folder; v.g., running bin/sphere solves the sphere problem for 60 dimensions and prints an output close to this:

PSO Sphere function
f(x) = sum(x[]^2)

Execution Results
----------------
Best            0
X1:             0
X2:             0
X3:             0
X4:             0
...
X60:            0
Epoch:          328
Reason:         Target

References

[1] J. Kennedy and R. C. Eberhart. “Particle swarm optimization,” Proc. IEEE Int. Conf. on Neural Networks, pp. 1942-1948, 1995.

[2] Xiao-Feng Xie, Wen-Jun Zhang and Zhi-Lian Yang. “Dissipative particle swarm optimization,” in Evolutionary Computation, 2002. CEC '02. Proceedings of the 2002 Congress on , vol.2, no., pp.1456-1461, 2002

[3] Bansal, J.C., Singh, P.K., Saraswat, M., Verma, A., Jadon, S.S. and Abraham, A. “Inertia Weight strategies in Particle Swarm Optimization,” in Nature and Biologically Inspired Computing (NaBIC), 2011 Third World Congress on , vol., no., pp.633-640, 19-21 Oct. 2011

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.