| Crates.io | dsmga2 |
| lib.rs | dsmga2 |
| version | 0.1.0 |
| created_at | 2025-12-28 21:16:56.390907+00 |
| updated_at | 2025-12-28 21:16:56.390907+00 |
| description | Dependency Structure Matrix Genetic Algorithm II with two-edge graphical linkage model |
| homepage | https://github.com/PoHsuanLai/dsmga2 |
| repository | https://github.com/PoHsuanLai/dsmga2 |
| max_upload_size | |
| id | 2009398 |
| size | 138,127 |
A genetic algorithm that learns problem structure. 75-91% fewer evaluations than standard GAs on hard problems.
pip install dsmga2
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()
DSMGA2 automatically discovers which variables interact, allowing it to solve problems more efficiently than standard genetic algorithms.
Benchmark: MAX-SAT (NP-complete problem)

| 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.
use dsmga2::{Dsmga2, fitness::OneMax};
let mut ga = Dsmga2::new(100, &OneMax)
.population_size(200)
.build();
ga.run();
println!("Best: {}", ga.best_fitness());
MIT OR Apache-2.0