evolution 0.1.4 copy "evolution: ^0.1.4" to clipboard
evolution: ^0.1.4 copied to clipboard

outdated

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.

evolution #

A simple to use optimization library based on evolutionary algorithms.

It can be used in both dart and flutter projects.

Getting started #

Add the dependency to your pubspec.yaml file:

dependencies:
  evolution: #latest version

Add this import statement to your source files:

import 'package:evolutionSimple/evolution.dart';

Example #

Agent diff( int positions, // int sizeN, // int bestN, // int randN, // int diffN, // int seed, // int steps, // double w, // double Function(List

//Agent l(int i) => Agent(List

int z = 0; Population p0 = gp(sizeN, positions, r, fitness);

if (p0.isEmpty) throw Exception("zu kurz, aber sizeN ${sizeN}"); while (z < steps) { double wz = w / ((z == 0 ? 1 : z)).toDouble();

/*
// random survivors
Population p01 = p0.copy();
p01.shuffle(r.r);
Population rand = p01.select(randN);
*/

// best survivors
Population p02 = p0.copy();
Population p021 = p02.sorted();
Population best = p021.select(bestN);

// mutation
Population p03 = p0.copy();
Population mutated = p03.mutation(wz / 10.0);

Population differential = mutated.differential(diffN, wz * 10.0);

// combine candidate solutions
Population all = Population(
    /*rand + */ best + differential,
    r,
    fitness);
Population p8 = all.copy();
Population p9 = p8.sorted();
Population p10 = p9.select(sizeN);

p0 = p10;
z++;

} Population res = p0.sorted().select(1); //print(res); return res.first; }

To use a restricted and more performant version of the algorithm:

import 'package:evolutionSimple/evolution.dart';

void main() {
 
  10.times((int i) {

    // diff2 is a restricted version, 
    var ret =
        diff2(4, 25, 10, 10, 25, i, 10000, 10.0, sphere, 50, 150);
    print(" TD: i: ${i} - f: ${ret.fitness()} - ag: ${ret}   ");
    return ret;
  });

}

Evolutionary Algorithms #

Evolutionary algorithms [EA] optimize a problem iteratively by trying to improve a candidate solution stochastically with regard to a given measure of quality. An EA maintains a population of candidate solutions and creates new candidate solutions by mutation and recombination from existing ones keeping whichever candidate solution has the best score or fitness on the optimization problem. EAs are metaheuristics making few assumptions about the problem being optimized except for restricting the search space of candidate solutions. In this way the optimization problem is treated as a black box that merely provides a measure of quality given a candidate solution in terms of its fitness and the gradient of the problem function is therefore not needed. EAs can be used for multidimensional real-valued functions but does not use the gradient of the problem being optimized, which means they do not require the optimization problem to be differentiable, as is required by classic optimization methods such as gradient descent and quasi-newton methods. They can therefore also be used on optimization problems that are not even continuous, are noisy, change over time, etc. EAs do not guarantee an optimal solution is ever found.

1
likes
0
points
26
downloads

Publisher

verified publisherwelopment.com

Weekly Downloads

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.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

optima

More

Packages that depend on evolution