Package org.encog.ml.prg

Examples of org.encog.ml.prg.EncogProgram


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


    expression.getVariables().setVariable("a",5);
    Assert.assertEquals(5,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void testNegAssignment() {
    EncogProgram expression = new EncogProgram("-a");
    expression.getVariables().setVariable("a",5);
    Assert.assertEquals(-5,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    expression.getVariables().setVariable("a",5);
    Assert.assertEquals(-5,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void test2NegAssignment() {
    EncogProgram expression = new EncogProgram("--a");
    expression.getVariables().setVariable("a",5);
    Assert.assertEquals(5,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    expression.getVariables().setVariable("a",5);
    Assert.assertEquals(5,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void testAssignment2() {
    EncogProgram expression = new EncogProgram("cccc*(aa+bbb)");
    expression.getVariables().setVariable("aa",1);
    expression.getVariables().setVariable("bbb",2);
    expression.getVariables().setVariable("cccc",3);
    Assert.assertEquals(9,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
View Full Code Here

    expression.getVariables().setVariable("cccc",3);
    Assert.assertEquals(9,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void testAssignment3() {
    EncogProgram expression = new EncogProgram("v1+v2+v3");
    expression.getVariables().setVariable("v1",1);
    expression.getVariables().setVariable("v2",2);
    expression.getVariables().setVariable("v3",3);
    Assert.assertEquals(6,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
View Full Code Here

    expression.getVariables().setVariable("v3",3);
    Assert.assertEquals(6,expression.evaluate().toFloatValue(),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void testVarComplex() {
    EncogProgram expression = new EncogProgram("(x^((1+((x^-8)-(4^x)))^(((-7/2)-(0--5.8))/x)))");
    expression.getVariables().setVariable("x",10);
    Assert.assertTrue(Double.isNaN(expression.evaluate().toFloatValue()));
  }
View Full Code Here

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

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

import org.encog.ml.prg.EncogProgram;

public class TestRenderCommon extends TestCase {
 
  public void testRenderBasic() {
    EncogProgram expression = new EncogProgram("(2+6)");
    RenderCommonExpression render = new RenderCommonExpression();
    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)");
    RenderCommonExpression render = new RenderCommonExpression();
    String result = render.render(expression);
    Assert.assertEquals("((((a+25)^3)/25)-(((a*3)^4)/250))", result);
  }
View Full Code Here

    String result = render.render(expression);
    Assert.assertEquals("((((a+25)^3)/25)-(((a*3)^4)/250))", result);
  }
 
  public void testRenderFunction() {
    EncogProgram expression = new EncogProgram("(sin(x)+cos(x))/2");
    RenderCommonExpression render = new RenderCommonExpression();
    String result = render.render(expression);   
    Assert.assertEquals("((sin(x)+cos(x))/2)", 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.