de 1.0.3 copy "de: ^1.0.3" to clipboard
de: ^1.0.3 copied to clipboard

Differential Evolution Optimization tool for Dart. The implementation supposes the objective function is a maximation and optimization parameters are customizable.

example/de_example.dart

import 'package:de/de.dart';
import 'package:de/src/Solution.dart';

void main() {
  List<double> vals = [
    1.0,
    2.0,
    3.0,
    4.0,
    5.0,
    6.0,
    700.0,
    800.0,
    900.0,
    100.0
  ];
  double f(List<double> x) {
    double s = 0.0;
    for (int i = 0; i < vals.length; i++) {
      s += (vals[i] - x[0]).abs().toDouble();
    }
    return -s;
  }

  DE de = DE(f, [-100.0], [100.0], cr: 0.99, F: 1.50, popsize: 300);
  de.iterateN(10000);
  de.calculateFitnessForAll();
  Solution best = de.getBest();

  print(best);
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Differential Evolution Optimization tool for Dart. The implementation supposes the objective function is a maximation and optimization parameters are customizable.

Homepage

License

unknown (LICENSE)

Dependencies

pso

More

Packages that depend on de