Package jmt.engine.math.parser

Examples of jmt.engine.math.parser.Parser


   * @param meanExpression expression to be evaluated to find mean value
   */
  public synchronized void setRangeDistributionMean(Object key, String meanExpression) {
    Range tmp = ranges.get(key);
    // Calculates min value using parser and sets it into distribution
    Parser parser = new Parser(meanExpression, true);

    try {
      parser.setVariable(VAR, tmp.from);
      tmp.distribution.setMean(parser.getValue());
      // Allow range only if its value in 'from' point is assignable to
      // current distribution
      if (tmp.distribution.getMean() - parser.getValue() < 1e-5) {
        tmp.meanExpression = parser.getExpression();
      }
    } catch (ParseError e) {
      // Do nothing
    } catch (EvaluationException e) {
      // Do nothing
View Full Code Here


  public double getMeanValue(int jobs) {
    // Finds key of right range
    Object key = ranges.headMap(new Integer(jobs + 1)).lastKey();
    Range range = ranges.get(key);

    Parser parser = new Parser(range.meanExpression, true);

    try {
      parser.setVariable(VAR, jobs);
      return parser.getValue();
    } catch (ParseError e) {
      // Do nothing
    } catch (EvaluationException e) {
      // Do nothing
    }
View Full Code Here

  /* (non-Javadoc)
   * @see jmt.gui.exact.ld.eval.Evaluator#evaluate(java.lang.String, double)
   */
  public double evaluate(String expression, double x) throws ExpressionParseException {
    try {
      Parser p = new Parser(expression, true);
      p.setVariable(X, x);
      return p.getValue();
    } catch (RuntimeException ex) {
      throw new ExpressionParseException(ex.getMessage());
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see jmt.gui.exact.ld.eval.Evaluator#evaluate(java.lang.String, double[])
   */
  public double[] evaluate(String expression, double[] x) throws ExpressionParseException {
    try {
      Parser p = new Parser(expression, true);
      double[] y = new double[x.length];
      for (int i = 0; i < x.length; i++) {
        p.setVariable(X, x[i]);
        y[i] = p.getValue();
      }
      return y;
    } catch (RuntimeException ex) {
      throw new ExpressionParseException(ex.getMessage());
    }
View Full Code Here

    this.from = from.intValue();
    this.distribution = distr;
    this.parameter = parameter;
    if (function != null) {
      this.function = function.toLowerCase();
      parser = new Parser(function, true);
    }

  }
View Full Code Here

TOP

Related Classes of jmt.engine.math.parser.Parser

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.