Exemple #1
0
  /**
   * Grounds the parameter by assigning the values in the assignment to the unknown variables
   *
   * @param input the grounding assignment
   * @return the grounded parameter
   */
  public Parameter ground(Assignment input) {
    if (input.containsVars(expression.getVariables())) {
      try {
        double result = expression.evaluate(input);
        return new FixedParameter(result);
      } catch (IllegalArgumentException e) {
        log.warning("cannot ground " + expression + " with " + input);
      }
    }

    String filled = expression.toString();
    for (String u : input.getVariables()) {
      filled.replaceAll(u, input.getValue(u).toString());
    }
    return new ComplexParameter(filled);
  }
Exemple #2
0
 /**
  * Returns the parameter value corresponding to the expression and the assignment of values to the
  * unknown parameters.
  */
 @Override
 public double getValue(Assignment input) {
   try {
     return expression.evaluate(input);
   } catch (IllegalArgumentException e) {
     log.warning("cannot evaluate " + this + " given " + input + ": " + e.getMessage());
     return 0.0;
   }
 }
Exemple #3
0
 /** Returns the list of unknown parameter variables */
 @Override
 public Collection<String> getVariables() {
   return expression.getVariables();
 }
Exemple #4
0
 /**
  * Returns the hashcode for the parameter
  *
  * @return the hashcode
  */
 @Override
 public int hashCode() {
   return -3 * expression.hashCode();
 }
Exemple #5
0
 /**
  * Returns the parameter template as a string
  *
  * @return the string
  */
 @Override
 public String toString() {
   return expression.toString();
 }