dsmga2

Crates.iodsmga2
lib.rsdsmga2
version0.1.0
created_at2025-12-28 21:16:56.390907+00
updated_at2025-12-28 21:16:56.390907+00
descriptionDependency Structure Matrix Genetic Algorithm II with two-edge graphical linkage model
homepagehttps://github.com/PoHsuanLai/dsmga2
repositoryhttps://github.com/PoHsuanLai/dsmga2
max_upload_size
id2009398
size138,127
Po-Hsuan Lai (PoHsuanLai)

documentation

https://docs.rs/dsmga2

README

DSMGA2

Crates.io Documentation PyPI License

A genetic algorithm that learns problem structure. 75-91% fewer evaluations than standard GAs on hard problems.

Installation

pip install dsmga2

Quick Start

import dsmga2

# Built-in problem
ga = dsmga2.Dsmga2(100, dsmga2.OneMax())
result = ga.run()
print(f"Fitness: {result.best_fitness}")

# Custom problem (NumPy compatible)
class MyProblem:
    def evaluate(self, solution):
        return solution.sum()

    def optimum(self, length):
        return length

ga = dsmga2.Dsmga2(100, MyProblem())
result = ga.run()

Why DSMGA2?

DSMGA2 automatically discovers which variables interact, allowing it to solve problems more efficiently than standard genetic algorithms.

Benchmark: MAX-SAT (NP-complete problem)

MAX-SAT Benchmark

Problem Size DSMGA2 PyGAD DEAP
20 variables 17K 202K 201K
30 variables 127K 500K 500K
40 variables 50K 459K 500K

Values = function evaluations to solution (lower is better)

This compares DSMGA2 against popular Python GA libraries. For academic comparisons with linkage-learning algorithms (LT-GOMEA, hBOA), see the original paper.

Rust Usage

use dsmga2::{Dsmga2, fitness::OneMax};

let mut ga = Dsmga2::new(100, &OneMax)
    .population_size(200)
    .build();

ga.run();
println!("Best: {}", ga.best_fitness());

License

MIT OR Apache-2.0

Commit count: 0

cargo fmt