simple-pso-demo-rs

Crates.iosimple-pso-demo-rs
lib.rssimple-pso-demo-rs
version0.1.2
sourcesrc
created_at2023-04-29 10:44:53.930214
updated_at2023-04-30 06:15:44.303642
descriptionA simulation of a simple application of Particle Swarm Optimization (PSO).
homepage
repositoryhttps://github.com/sslime336/simple-pso-demo-rs
max_upload_size
id851973
size683,139
ri (sslime336)

documentation

README

simple-pso-demo-rs

Crates.io

English | 简体中文

A simple application of Particle Swarm Optimization (PSO):

Calculate the most valuable goods based on PSO, implemented in Rust.

According to course requirements, part of the code was generated by ChatGPT and modified.

Problem to Solve

Simulate the selection of the relatively most valuable goods from different brands of the same type of goods and solve it using PSO.

In this project, goods are simply defined as follows:

pub struct Product {
    /// Individual fitness
    p_best: f64,

    /// There is a three-dimensional space, whose coordinate axis x, y, z's meaning
    /// is below:
    /// 
    /// x.0 (x)- restocking_price
    /// 
    /// x.1 (y)- selling_price
    /// 
    /// x.2 (z)- market_demand
    /// 
    /// Score value is 1.
    x: (f64, f64, f64),

    /// Velocity vector
    v: (i32, i32, i32),

    w1: f64,
    w2: f64,
}

The fitness (value) of a single particle (goods) is calculated using the following formula:

((purchase price - selling price) * w1) * market demand * w2

All particles (goods) are located in a two-dimensional space, and through PSO, the most valuable goods in the current space are calculated in a specified number of iterations.

The basic unit of step length for all particles is 1. When the selling price is lower than the purchase price, the particle only updates the velocity without displacement.

-- Generated by ChatGPT.
Commit count: 9

cargo fmt