コード例 #1
0
ファイル: ComplexParameter.java プロジェクト: kod3r/opendial
  /**
   * 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);
  }