pso 1.0.3
pso: ^1.0.3 copied to clipboard
Particle Swarm Optimization tool for Dart. The implementation supposes the objective function is a maximation and optimization parameters are customizable.
example/pso_example.dart
import 'dart:math' as _math;
import 'package:pso/pso.dart';
double f(List<double> x) {
var s = 0.0;
s = _math.pow(x[0] - 3.14159265, 2.0) + _math.pow(x[1] - 2.71828, 2.0)
as double;
return -s;
}
void main() {
var mins = <double>[-10, -10];
var maxs = <double>[10, 10];
var pso = PSO(f, 100, mins, maxs);
pso.iterateN(500);
var result = pso.findGBest();
print(result);
}