Package org.encog.parse.expression.common

Examples of org.encog.parse.expression.common.RenderCommonExpression


  /**
   * @return The string as a common "infix" expression.
   */
  public String dumpAsCommonExpression() {
    final RenderCommonExpression render = new RenderCommonExpression();
    return render.render(this);
  }
View Full Code Here


   * @param i
   *            The specified number of genomes.
   */
  public void dumpMembers(final int i) {

    final RenderCommonExpression render = new RenderCommonExpression();

    int index = 0;
    for (final Species species : getSpecies()) {
      System.out.println("** Species: " + species.toString());
      for (final Genome obj : species.getMembers()) {
        final EncogProgram prg = (EncogProgram) obj;
        System.out.println(index + ": Score " + prg.getScore() + " : "
            + render.render(prg));
        index++;
        if (index > i) {
          break;
        }
      }
View Full Code Here

public class TestRewriteConstants extends TestCase {
 
  public void eval(String start, String expect) {
    EncogProgram expression = new EncogProgram(start);
    RenderCommonExpression render = new RenderCommonExpression();
    RewriteConstants rewrite = new RewriteConstants();
    rewrite.rewrite(expression);
    Assert.assertEquals(expect, render.render(expression));
  }
View Full Code Here

    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

 
  public void testSimpleClone() {
   
    EncogProgramContext context = new EncogProgramContext();
    context.loadAllFunctions();
    RenderCommonExpression render = new RenderCommonExpression();
   
    EncogProgram prg1 = context.createProgram("1*2*3");
    EncogProgram prg2 = context.cloneProgram(prg1);
   
    Assert.assertEquals("((1*2)*3)", render.render(prg1));
    Assert.assertEquals("((1*2)*3)", render.render(prg2));
  }
View Full Code Here

  public void testCloneVar() {
   
    EncogProgramContext context = new EncogProgramContext();
    context.loadAllFunctions();
    context.defineVariable("x");
    RenderCommonExpression render = new RenderCommonExpression();
   
    EncogProgram prg1 = context.createProgram("x*2*3");
    EncogProgram prg2 = context.cloneProgram(prg1);
   
    Assert.assertEquals("((x*2)*3)", render.render(prg1));
    Assert.assertEquals("((x*2)*3)", render.render(prg2));
  }
View Full Code Here

  public void testCloneComplex() {
   
    EncogProgramContext context = new EncogProgramContext();
    context.loadAllFunctions();
    context.defineVariable("a");
    RenderCommonExpression render = new RenderCommonExpression();
   
    EncogProgram prg1 = context.createProgram("((a+25)^3/25)-((a*3)^4/250)");
    EncogProgram prg2 = context.cloneProgram(prg1);
 
    Assert.assertEquals("((((a+25)^3)/25)-(((a*3)^4)/250))", render.render(prg1));
    Assert.assertEquals("((((a+25)^3)/25)-(((a*3)^4)/250))", render.render(prg2));
  }
View Full Code Here

   
    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

    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

import org.encog.ml.prg.ProgramNode;
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

TOP

Related Classes of org.encog.parse.expression.common.RenderCommonExpression

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.