/** * Returns the set of groundings that can be derived from the rule and the specific input * assignment. * * @param input the input assignment * @return the possible groundings for the rule */ private RuleGrounding getGroundings(Assignment input) { RuleGrounding groundings = new RuleGrounding(); for (RuleCase c : cases) { groundings.add(c.getGroundings(input)); } return groundings; }
/** * Returns the set of all possible effects in the rule. * * @return the set of all possible effects */ public Set<Effect> getEffects() { Set<Effect> effects = new HashSet<Effect>(); for (RuleCase c : cases) { effects.addAll(c.getEffects()); } return effects; }
/** * Returns the input variables (possibly underspecified, with slots to fill) for the rule * * @return the set of labels for the input variables */ public Set<Template> getInputVariables() { Set<Template> inputVars = new HashSet<Template>(); for (RuleCase c : cases) { inputVars.addAll(c.getInputVariables()); } return inputVars; }
/** * Returns the set of all parameter identifiers employed in the rule * * @return the set of parameter identifiers */ public Set<String> getParameterIds() { Set<String> params = new HashSet<String>(); for (RuleCase c : cases) { for (Effect e : c.getEffects()) { params.addAll(c.output.getParameter(e).getVariables()); } } return params; }
/** Returns a string representation for the rule */ @Override public String toString() { String str = id + ": "; for (RuleCase theCase : cases) { if (!theCase.equals(cases.get(0))) { str += "\telse "; } str += theCase.toString() + "\n"; } if (!cases.isEmpty()) { str = str.substring(0, str.length() - 1); } return str; }