public static void Main() { var engine = Engine.Engine .Builder( Fitness, Codecs.OfScalar(DoubleRange.Of(0.0, 2.0 * Math.PI))) .PopulationSize(500) .Optimize(Optimize.Minimum) .Alterers( new Mutator <DoubleGene, double>(0.03), new MeanAlterer <DoubleGene, double>(0.6)) .Build(); var statistics = EvolutionStatistics.OfNumber <double>(); var best = engine.Stream() .TakeWhile(BySteadyFitness <DoubleGene, double>(7)) .Take(100) .Peek(statistics.Accept) .ToBestPhenotype(); Console.WriteLine(statistics); Console.WriteLine(best); }
public static void Main() { var engine = Engine.Engine .Builder(Area, Codecs.OfScalar(NextDimension)) .Build(); var pt = engine.Stream() .Take(50) .ToBestPhenotype(); Console.WriteLine(pt); }
public static void Main() { const int μ = 5; const int λ = 20; const double p = 0.2; var codec = Codecs.OfScalar(DoubleRange.Of(0, 1)); var engine = Engine.Engine .Builder(Fitness, codec) .PopulationSize(λ) .SurvivorsSize(0) .OffspringSelector(new TruncationSelector <DoubleGene, double>(μ)) .Alterers(new Mutator <DoubleGene, double>(p)) .Build(); Console.WriteLine( codec.Decode( engine.Stream() .Take(100) .ToBestGenotype() ) ); }