Package org.encog.ml.prg

Examples of org.encog.ml.prg.EncogProgram


    String result = render.render(expression);   
    Assert.assertEquals("((sin(x)+cos(x))/2)", result);   
  }
 
  public void testKnownConst() {
    EncogProgram expression = new EncogProgram("x*2*PI");
    RenderCommonExpression render = new RenderCommonExpression();
    String result = render.render(expression);   
    Assert.assertEquals("((x*2)*PI)", result);   
  }
View Full Code Here


    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

  {
    EncogProgramContext context = new EncogProgramContext();
    context.defineVariable("x");
    StandardExtensions.createAll(context);
    PrgPopulation pop = new PrgPopulation(context,10);
    EncogProgram prg1 = new EncogProgram(context);
    EncogProgram prg2 = new EncogProgram(context);
    prg1.compileExpression("x+1");
    prg2.compileExpression("(x+5)/2");
   
    Species defaultSpecies = pop.createSpecies();
    defaultSpecies.add(prg1);
    defaultSpecies.add(prg2);
    return pop;
View Full Code Here

  private void validate(PrgPopulation pop)
  {
    List<Genome> list = pop.flatten();
    Assert.assertEquals(2, list.size());
   
    EncogProgram prg1 = (EncogProgram)list.get(0);
    EncogProgram prg2 = (EncogProgram)list.get(1);
   
    RenderCommonExpression render = new RenderCommonExpression();
    Assert.assertEquals("(x+1)", render.render(prg1));
    Assert.assertEquals("((x+5)/2)", render.render(prg2));
  }
View Full Code Here

    context.defineVariable("x");
   
    StandardExtensions.createAll(context);
   
    PrgGrowGenerator rnd = new PrgGrowGenerator(context,2);
    EncogProgram prg = rnd.generate(new Random());
    RenderCommonExpression render = new RenderCommonExpression();
    String str = render.render(prg);
    System.out.println(str);
  }
View Full Code Here

import org.encog.parse.expression.common.RenderCommonExpression;

public class TestSubtreeCrossover extends TestCase {
  public void testCrossoverOperation() {
    RenderCommonExpression render = new RenderCommonExpression();
    EncogProgram prg = new EncogProgram("1+2");
    EncogProgram prg2 = new EncogProgram("4+5");
    ProgramNode node = prg.findNode(2);
    prg.replaceNode(node, prg2.getRootNode());
    Assert.assertEquals("(1+(4+5))",render.render(prg));
  }
View Full Code Here

import org.encog.ml.prg.EncogProgram;

public class TestCompareEncogProgram extends TestCase {
 
  public double eval(String prg1, String prg2) {
    EncogProgram expression1 = new EncogProgram(prg1);
    EncogProgram expression2 = new EncogProgram(prg2);
    CompareEncogProgram comp = new CompareEncogProgram();
    return comp.compare(expression1, expression2);
  }
View Full Code Here

import org.encog.ml.prg.EncogProgram;

public class TestRenderRPN extends TestCase {
 
  public void testRenderBasic() {
    EncogProgram expression = new EncogProgram("(2+6)");
    RenderRPN render = new RenderRPN();
    String result = render.render(expression);
    Assert.assertEquals("2 6 [+]", result);
  }
View Full Code Here

    String result = render.render(expression);
    Assert.assertEquals("2 6 [+]", result);
  }
 
  public void testRenderComplex() {
    EncogProgram expression = new EncogProgram("((a+25)^3/25)-((a*3)^4/250)");
    RenderRPN render = new RenderRPN();
    String result = render.render(expression);
    Assert.assertEquals("a 25 [+] 3 [^] 25 [/] a 3 [*] 4 [^] 250 [/] [-]", result);
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.prg.EncogProgram

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.