evolution 0.1.1
evolution: ^0.1.1 copied to clipboard
Simulated evolution. An evolutionary algorithm library for Dart. It will be used to optimize next trials in adaptive experimentation and can become part of flutter or web projects.
example/main.dart
import 'dart:math' as math;
import "package:evolution/evolution.dart";
/// Example
void main() {
math.Random r = math.Random();
PopD p = PopD.fromSizeAndLength(5, 5);
for (int i = 0; i < 10000; i++) {
double std = (1000.0) / (i == 0 ? i + 1.0 : i).toDouble();
PopD p2 = PopD.fromMutationFull(p, std, r);
PopD p3 = PopD.fromCrossoverFull(p2);
List<AgentD> p4 = p + p3;
PopD p5 = PopD.fromList(p4);
PopD p6 = PopD.fromBestInt(p5, 10);
p = p6;
}
/// Print the best solution candidate.
PopD end = p.sorted();
print("Ergebnis: " +
end.first.toString() +
" fitness: " +
end.fitness(end.first).toString());
}