ParticleSwarm<T> constructor

ParticleSwarm<T>({
  1. required List<T> initParticles(),
  2. required List<double> toVector(
    1. T
    ),
  3. required T fromVector(
    1. List<double>
    ),
  4. required double fitness(
    1. T
    ),
  5. required int dim,
  6. int swarmSize = 30,
  7. double inertia = 0.7,
  8. double cognitive = 1.4,
  9. double social = 1.4,
  10. int? seed,
})

Implementation

ParticleSwarm({
  required this.initParticles,
  required this.toVector,
  required this.fromVector,
  required this.fitness,
  required this.dim,
  this.swarmSize = 30,
  this.inertia = 0.7,
  this.cognitive = 1.4,
  this.social = 1.4,
  int? seed,
}) : _rand = seed != null ? Random(seed) : Random() {
  if (dim <= 0) throw ArgumentError('dim > 0');
  if (swarmSize <= 0) throw ArgumentError('swarmSize > 0');
}