/// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner = theOwner;
     foreach (var obj in _components.Contents)
     {
         obj.obj.Init(theOwner);
     }
 }
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner = theOwner;
     foreach (var obj in _components.Contents)
     {
         obj.obj.Init(theOwner);
     }
 }
예제 #3
0
 UsingEvaluation <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IFitness <TIndividual, TGeneStructure, TGene> fitness)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable
 {
     algo.Fitness = fitness;
     return(algo);
 }
예제 #4
0
 UsingStatistics <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IEvolutionaryStatistics <TIndividual, TGeneStructure, TGene> statistics)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable
 {
     algo.Statistics = statistics;
     return(algo);
 }
예제 #5
0
 UsingPopulation <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IPopulation <TIndividual, TGeneStructure, TGene> initialPopulation)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable
 {
     algo.Population = initialPopulation;
     return(algo);
 }
예제 #6
0
 UsingParameters <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IParameters parameters)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable
 {
     algo.Parameters = parameters;
     return(algo);
 }
예제 #7
0
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner = theOwner;
     foreach (ObjectHolder <IEvolutionaryOperator> obj in _components
              .ObjList)
     {
         obj.Obj.Init(theOwner);
     }
 }
예제 #8
0
 UsingHeuristic <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IHyperHeuristic <TIndividual, TGeneStructure, TGene> heuristic)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable
 {
     algo.HyperHeuristic = heuristic;
     return(algo);
 }
예제 #9
0
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner = theOwner;
     foreach (ObjectHolder<IEvolutionaryOperator> obj in _components
             .ObjList)
     {
         obj.Obj.Init(theOwner);
     }
 }
 public void ResetTraining()
 {
     Substrate substrate = SubstrateFactory.factorSandwichSubstrate(11, 11);
     BoxesScore score = new BoxesScore(11);
     pop = new NEATPopulation(substrate, 500);
     pop.ActivationCycles = 4;
     pop.Reset();
     train = NEATUtil.ConstructNEATTrainer(pop, score);
     OriginalNEATSpeciation speciation = new OriginalNEATSpeciation();
     train.Speciation = new OriginalNEATSpeciation();
 }
예제 #11
0
        private void Validate(NEATPopulation pop)
        {
            Assert.AreEqual(10, pop.PopulationSize);
            Assert.AreEqual(0.2, pop.SurvivalRate);

            // see if the population can actually be used to train
            IMLDataSet             trainingSet = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);
            ICalculateScore        score       = new TrainingSetScore(trainingSet);
            IEvolutionaryAlgorithm train       = NEATUtil.ConstructNEATTrainer(pop, score);

            train.Iteration();
        }
예제 #12
0
 UsingHeuristic <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     Func <IMutator <TIndividual, TGeneStructure, TGene>, IMutator <TIndividual, TGeneStructure, TGene> >
     applyMutations,
     IGenerationFilter <TIndividual, TGeneStructure, TGene> filter)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable =>
 algo.UsingHeuristic(new GenerationGenerator <TIndividual, TGeneStructure, TGene>
 {
     Mutator = applyMutations(new Mutator <TIndividual, TGeneStructure, TGene>()),
     Filter  = filter
 });
예제 #13
0
        public void ResetTraining()
        {
            Substrate  substrate = SubstrateFactory.factorSandwichSubstrate(11, 11);
            BoxesScore score     = new BoxesScore(11);

            pop = new NEATPopulation(substrate, 500);
            pop.ActivationCycles = 4;
            pop.Reset();
            train = NEATUtil.ConstructNEATTrainer(pop, score);
            OriginalNEATSpeciation speciation = new OriginalNEATSpeciation();

            train.Speciation = new OriginalNEATSpeciation();
        }
예제 #14
0
        private NEATPopulation Generate()
        {
            IMLDataSet trainingSet = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal);

            ICalculateScore score = new TrainingSetScore(trainingSet);
            // train the neural network
            ActivationStep step = new ActivationStep();

            step.Center = 0.5;

            IEvolutionaryAlgorithm train = NEATUtil.ConstructNEATTrainer(
                score, 2, 1, 10);

            return((NEATPopulation)train.Population);
        }
예제 #15
0
        public StatisticsView(IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> algorithm,
                              SimpleGraph graph)
        {
            var statistics = algorithm.Statistics;

            Parameters         = (IParameters)algorithm.Parameters.Clone();
            StartTime          = statistics.StartTime;
            EndTime            = statistics.EndTime ?? DateTime.Now;
            Best               = statistics.Best == null ? null : new IndividualViewView(statistics.Best);
            Current            = statistics.Best == null ? null : new IndividualViewView(statistics.Current);
            Previous           = statistics.Best == null ? null : new IndividualViewView(statistics.Previous);
            StagnantGeneration = statistics.StagnantGeneration;
            Generations        = statistics.Generations;

            foreach (var m in algorithm.HyperHeuristic.States.SelectMany(g => g.Mutator.Mutations))
            {
                if (m is AsymmetricMutation mutation)
                {
                    R0 = mutation.ZeroFocus;
                    R1 = mutation.OneFocus;
                }
            }

            if (algorithm.HyperHeuristic is StagnationDetectionHyperHeuristic heuristic)
            {
                InStagnation       = heuristic.InStagnationDetection;
                StagnationProgress = heuristic.At / heuristic.Limit;
            }

            if (graph != null && Current != null)
            {
                Edges = graph.Edges
                        .Where(t => Current.Genes[t.Id])
                        .Select(t => new ViewEdge(t))
                        .ToList();
            }
        }
예제 #16
0
 /// <summary>
 ///     Create a species comparator.
 /// </summary>
 /// <param name="theTraining">The trainer.</param>
 public SpeciesComparer(IEvolutionaryAlgorithm theTraining)
 {
     _training = theTraining;
 }
예제 #17
0
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     // TODO Auto-generated method stub
 }
예제 #18
0
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
 }
 public static IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> UsingStagnationStatistics(
     this IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> algorithm) =>
 algorithm.UsingStatistics(new StagnationStatistics());
예제 #20
0
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner       = theOwner;
     _population  = theOwner.Population;
     _sortGenomes = new SortGenomesForSpecies(_owner);
 }
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theTrainer)
 {
     _trainer = theTrainer;
 }
예제 #22
0
 /// <summary>
 ///     Construct a tournament selection.
 /// </summary>
 /// <param name="theTrainer">The trainer.</param>
 /// <param name="theRounds">The number of rounds to use.</param>
 public TournamentSelection(IEvolutionaryAlgorithm theTrainer,
                            int theRounds)
 {
     Trainer = theTrainer;
     Rounds  = theRounds;
 }
 /// <summary>
 ///     Construct a tournament selection.
 /// </summary>
 /// <param name="theTrainer">The trainer.</param>
 /// <param name="theRounds">The number of rounds to use.</param>
 public TournamentSelection(IEvolutionaryAlgorithm theTrainer,
                            int theRounds)
 {
     Trainer = theTrainer;
     Rounds = theRounds;
 }
 public bool Evaluate(IEvolutionaryAlgorithm algorithm)
 {
     throw new NotImplementedException();
 }
 public bool Evaluate(IEvolutionaryAlgorithm algorithm)
 {
     return(algorithm.ElapsedMilliseconds >= this._timeoutMilliseconds);
 }
예제 #26
0
 public IndividualStorage(IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> example)
     : this(example.Population)
 {
 }
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     // TODO Auto-generated method stub
 }
예제 #28
0
파일: Splice.cs 프로젝트: shturm/encog-prim
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     this.owner = theOwner;
 }
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
 }
예제 #30
0
 public static IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> UsingRandomPopulation(
     this IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> algorithm,
     double mutationRate = 1) =>
 algorithm.UsingPopulation(BitIndividual.FromRandom(mutationRate));
예제 #31
0
 public static IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> UsingBasicStatistics(
     this IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> algorithm) =>
 algorithm.UsingStatistics(new BasicEvolutionaryStatistics <IBitIndividual, BitArray, bool>());
예제 #32
0
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     // not needed
 }
예제 #33
0
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     // not needed
 }
예제 #34
0
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     this.owner = theOwner;
 }
 /// <inheritdoc/>
 public void Init(IEvolutionaryAlgorithm theTrainer)
 {
     _trainer = theTrainer;
 }
 /// <inheritdoc />
 public void Init(IEvolutionaryAlgorithm theOwner)
 {
     _owner = theOwner;
     _sortGenomes = new SortGenomesForSpecies(_owner);
 }
예제 #37
0
 UsingHeuristic <TIndividual, TGeneStructure, TGene>(
     this IEvolutionaryAlgorithm <TIndividual, TGeneStructure, TGene> algo,
     IGenerationGenerator <TIndividual, TGeneStructure, TGene> generator)
     where TIndividual : IIndividual <TGeneStructure, TGene>
     where TGeneStructure : ICloneable =>
 algo.UsingHeuristic(new SimpleHeuristic <TIndividual, TGeneStructure, TGene>(generator));
 /// <summary>
 /// Construct the truncation selector.
 /// </summary>
 /// <param name="theTrainer">The trainer.</param>
 /// <param name="thePercent">The top percent to select from.</param>
 public TruncationSelection(IEvolutionaryAlgorithm theTrainer,
                            double thePercent)
 {
     _trainer = theTrainer;
     _percent = thePercent;
 }
예제 #39
0
 /// <summary>
 /// Construct the truncation selector.
 /// </summary>
 /// <param name="theTrainer">The trainer.</param>
 /// <param name="thePercent">The top percent to select from.</param>
 public TruncationSelection(IEvolutionaryAlgorithm theTrainer,
                            double thePercent)
 {
     _trainer = theTrainer;
     _percent = thePercent;
 }
예제 #40
0
 /// <summary>
 ///     Construct the comparator.
 /// </summary>
 /// <param name="theTrain">The trainer.</param>
 public SortGenomesForSpecies(IEvolutionaryAlgorithm theTrain)
 {
     _train = theTrain;
 }
 public static StatisticsView MapToStatisticsView(
     this IEvolutionaryAlgorithm <IBitIndividual, BitArray, bool> algorithm, SimpleGraph graph) =>
 algorithm == null ? null : new StatisticsView(algorithm, graph);