Giter Club home page Giter Club logo

mo_pso_rs's Introduction

mo_pso_rs

An implementation of a multi-objective particle swarm optimization algorithm utilizing methods proposed in Strategies for finding good local guides in multi-objective particle swarm optimization (MOPSO).

This crate is mostly a Rust rewrite of the implementation of MOPSO in the PSOTS toolbox with additional support for constrained optimization with arbitrary constraints.

Currently, only two objectives are supported, but the implementation should be easily extendable to more objectives.

Constraints

This implementation supports arbitrary constraints which are handled using a "Preserving feasibility technique" as described in the paper Constraint-Handling Techniques for Particle Swarm Optimization Algorithms.

Example

use mo_pso_rs::{MoPso, MoPsoConfig, Particle, Problem};

struct TestProblem {
    radius: f64
}
impl Problem for TestProblem {
    fn objective(&self, p: &[f64]) -> [f64; 2] {
        [p[0].powi(2), -p[1].powi(2)]
    }

    fn is_feasible(&self, p: &[f64]) -> bool {
        // Only allow point outside circle with radius self.radius
        p[0].powi(2) + p[1].powi(2) >= self.radius.powi(2)
    }
}


fn main() {
    let problem = TestProblem { radius: 2.0 };
    
    let config = MoPsoConfig {
        max_iter: 100,
        c_1: 0.4, 
        c_2: 0.4,
        w_start: 0.9,
        w_end: 0.4,
        archive_size: 100,
    };

    let mut particles = Vec::new();
    for _ in 0..100 {
        particles.push(Particle::random(2));
    }

    let optimizer = MoPso::new(config, &problem, particles);
    let pareto_front = optimizer.optimize();

    for particle in pareto_front {
        println!("{:?}", particle.position);
    }
}

mo_pso_rs's People

Contributors

ichbinluka avatar

Stargazers

Jakob Hopman avatar

Watchers

 avatar

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.