Package org.encog.ml.ea.train.basic

Examples of org.encog.ml.ea.train.basic.TrainEA


   */
  public MLTrain create(final MLMethod method,
      final MLDataSet training, final String argsStr) {

    final CalculateScore score = new TrainingSetScore(training);   
    final TrainEA train = NEATUtil.constructNEATTrainer((NEATPopulation)method, score);

    return train;
  }
View Full Code Here


   * @param calculateScore The score function.
   * @return The NEAT EA trainer.
   */
  public static TrainEA constructNEATTrainer(final NEATPopulation population,
      final CalculateScore calculateScore) {
    final TrainEA result = new TrainEA(population, calculateScore);
    result.setSpeciation(new OriginalNEATSpeciation());

    result.setSelection(new TruncationSelection(result, 0.3));
    final CompoundOperator weightMutation = new CompoundOperator();
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(1),
            new MutatePerturbLinkWeight(0.02)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(2),
            new MutatePerturbLinkWeight(0.02)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(3),
            new MutatePerturbLinkWeight(0.02)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectProportion(0.02),
            new MutatePerturbLinkWeight(0.02)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(1),
            new MutatePerturbLinkWeight(1)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(2),
            new MutatePerturbLinkWeight(1)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectFixed(3),
            new MutatePerturbLinkWeight(1)));
    weightMutation.getComponents().add(
        0.1125,
        new NEATMutateWeights(new SelectProportion(0.02),
            new MutatePerturbLinkWeight(1)));
    weightMutation.getComponents().add(
        0.03,
        new NEATMutateWeights(new SelectFixed(1),
            new MutateResetLinkWeight()));
    weightMutation.getComponents().add(
        0.03,
        new NEATMutateWeights(new SelectFixed(2),
            new MutateResetLinkWeight()));
    weightMutation.getComponents().add(
        0.03,
        new NEATMutateWeights(new SelectFixed(3),
            new MutateResetLinkWeight()));
    weightMutation.getComponents().add(
        0.01,
        new NEATMutateWeights(new SelectProportion(0.02),
            new MutateResetLinkWeight()));
    weightMutation.getComponents().finalizeStructure();

    result.setChampMutation(weightMutation);
    result.addOperation(0.5, new NEATCrossover());
    result.addOperation(0.494, weightMutation);
    result.addOperation(0.0005, new NEATMutateAddNode());
    result.addOperation(0.005, new NEATMutateAddLink());
    result.addOperation(0.0005, new NEATMutateRemoveLink());
    result.getOperators().finalizeStructure();

    if (population.isHyperNEAT()) {
      result.setCODEC(new HyperNEATCODEC());
    } else {
      result.setCODEC(new NEATCODEC());
    }

    return result;
  }
View Full Code Here

      final MLDataSet training, final String argsStr) {
   
    PrgPopulation pop = (PrgPopulation)method;
   
    final CalculateScore score = new TrainingSetScore(training);   
    TrainEA train = new TrainEA(pop, score);
    train.getRules().addRewriteRule(new RewriteConstants());
    train.getRules().addRewriteRule(new RewriteAlgebraic());
    train.setCODEC(new PrgCODEC());
    train.addOperation(0.8, new SubtreeCrossover());
    train.addOperation(0.1, new SubtreeMutation(pop.getContext(),4));
    train.addOperation(0.1, new ConstMutation(pop.getContext(),0.5,1.0));
    train.addScoreAdjuster(new ComplexityAdjustedScore());
    train.setSpeciation(new PrgSpeciation());
    return train;
  }
View Full Code Here

    EncogProgramContext context = new EncogProgramContext();
    StandardExtensions.createNumericOperators(context);
    PrgPopulation pop = new PrgPopulation(context,1);
    CalculateScore score = new ZeroEvalScoreFunction();

    TrainEA genetic = new TrainEA(pop, score);
    genetic.setValidationMode(true);
    genetic.setCODEC(new PrgCODEC());
    genetic.addOperation(0.95, new SubtreeCrossover());
    genetic.addOperation(0.05, new SubtreeMutation(context,4));
    genetic.addScoreAdjuster(new ComplexityAdjustedScore());
    genetic.getRules().addRewriteRule(new RewriteConstants());
    genetic.getRules().addRewriteRule(new RewriteAlgebraic());

    EncogProgram expression = new EncogProgram(context);
    expression.compileExpression(start);
    RenderCommonExpression render = new RenderCommonExpression();
    genetic.getRules().rewrite(expression);
    Assert.assertEquals(expect, render.render(expression));
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.ea.train.basic.TrainEA

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.