public GeneticAlgorithm CreateGpArtificialAntSample() { GeneticAlgorithm ga = new GeneticAlgorithm(); #region Problem Configuration Problem antProblem = new Problem(); antProblem.BestKnownQuality = 89; antProblem.Encoding.TreeDepth = 10; antProblem.Encoding.TreeLength = 100; antProblem.Encoding.FunctionDefinitions = 3; antProblem.Encoding.FunctionArguments = 3; antProblem.MaxTimeSteps.Value = 600; #endregion #region Algorithm Configuration ga.Name = "Genetic Programming - Artificial Ant"; ga.Description = "A standard genetic programming algorithm to solve the artificial ant problem (Santa-Fe trail)"; ga.Problem = antProblem; SamplesUtils.ConfigureGeneticAlgorithmParameters<TournamentSelector, SubtreeCrossover, MultiSymbolicExpressionTreeArchitectureManipulator>( ga, 1000, 1, 50, 0.15, 5); var mutator = (MultiSymbolicExpressionTreeArchitectureManipulator)ga.Mutator; mutator.Operators.SetItemCheckedState(mutator.Operators .OfType<FullTreeShaker>() .Single(), false); mutator.Operators.SetItemCheckedState(mutator.Operators .OfType<OnePointShaker>() .Single(), false); mutator.Operators.SetItemCheckedState(mutator.Operators .OfType<ArgumentDeleter>() .Single(), false); mutator.Operators.SetItemCheckedState(mutator.Operators .OfType<SubroutineDeleter>() .Single(), false); #endregion return ga; }
public GEArtificialAntProblem() : base() { wrappedAntProblem = new HeuristicLab.Problems.GeneticProgramming.ArtificialAnt.Problem(); Parameters.Add(new ValueParameter <BoolMatrix>("World", "The world for the artificial ant with scattered food items.", wrappedAntProblem.World)); Parameters.Add(new FixedValueParameter <IntValue>("MaximumTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600))); Parameters.Add(new ValueParameter <IGenotypeToPhenotypeMapper>("GenotypeToPhenotypeMapper", "Maps the genotype (an integer vector) to the phenotype (a symbolic expression tree).", new DepthFirstMapper())); Encoding = new IntegerVectorEncoding(30) { Bounds = new IntMatrix(new int[, ] { { 0, 100 } }) }; BestKnownQuality = wrappedAntProblem.BestKnownQuality; }
private GEArtificialAntProblem(GEArtificialAntProblem original, Cloner cloner) : base(original, cloner) { this.wrappedAntProblem = cloner.Clone(original.wrappedAntProblem); }
// cloning private Problem(Problem original, Cloner cloner) : base(original, cloner) { }