예제 #1
0
 /**
  * Returns the input variables associated with the case
  *
  * @return the set of input variables
  */
 public Set<Template> getInputVariables() {
   Set<Template> inputVars = new HashSet<Template>();
   inputVars.addAll(condition.getInputVariables());
   for (Effect effect : getEffects()) {
     for (String inputVariable : effect.getValueSlots()) {
       inputVars.add(new Template(inputVariable));
     }
   }
   return inputVars;
 }
예제 #2
0
    /**
     * Returns the groundings associated with the rule case, given the input assignment
     *
     * @param input the input assignment
     * @return the resulting groundings
     */
    public RuleGrounding getGroundings(Assignment input) {
      RuleGrounding groundings = new RuleGrounding();
      groundings.add(condition.getGroundings(input));

      if (ruleType == RuleType.UTIL) {
        boolean actionVars = input.containsVars(output.getOutputVariables());
        for (Effect e : getEffects()) {
          if (actionVars) {
            Condition co = e.convertToCondition();
            RuleGrounding effectGrounding = co.getGroundings(input);
            groundings.add(effectGrounding);
          } else {
            Set<String> slots = e.getValueSlots();
            slots.removeAll(input.getVariables());
            groundings.add(Assignment.createOneValue(slots, ""));
          }
        }
      }
      return groundings;
    }