mccga

Crates.iomccga
lib.rsmccga
version0.1.5
sourcesrc
created_at2023-08-15 20:04:56.475206
updated_at2023-09-28 16:45:50.581111
descriptionImplements the machine-coded compact genetic algorithm (MCCGA)
homepage
repositoryhttps://github.com/jbytecode/mccga.rs
max_upload_size
id945268
size20,445
Mehmet Hakan Satman (jbytecode)

documentation

README

mccga.rs

Machine-coded compact genetic algorithm in Rust

In-short

The package implements the Machine-coded compact genetic algorithm defined in

Satman, M. H. & Akadal, E. (2020). Machine Coded Compact Genetic Algorithms for Real Parameter Optimization Problems . Alphanumeric Journal , 8 (1) , 43-58 . DOI: 10.17093/alphanumeric.576919 Link

Example

Suppose that the objective function is to minimize

fn f(x: &Vec<f64>) -> f64 {
    return (x[0] - 3.14159265).powf(2.0) + (x[1] - 2.71828).powf(2.0);
}

so the package allows to type

let mins: Vec<f64> = vec![-10000.0_f64; 2];
let maxs: Vec<f64> = vec![10000.0_f64; 2];

let result = mccga(f, &mins, &maxs, 0.001, 100000);

to minimize the objective function where result is a 2-element vector. One can test the result using

assert!(isequal(&result[0], 3.14159265, 0.001));
assert!(isequal(&result[1], 2.71828, 0.001)); 

Other implementations

Commit count: 17

cargo fmt