Example #1
0
 public final String[] asClauses() {
   Set<Variable> vars = new HashSet<>();
   String atom = ((Atom) scheme.generalises(vars)).toString();
   String types = scheme.getTypes().length > 0 ? " :" + String.join(",", scheme.getTypes()) : "";
   String list = scheme.getTypes().length > 0 ? "," + String.join(",", scheme.getTypes()) : "";
   String[] result = new String[5];
   result[0] = String.format("%% %s", toString());
   result[1] = String.format("%d { abduced_%s%s } %d.", lower, atom, types, upper);
   // result[2] = String.format("#minimize[ abduced_%s =%d @%d%s ].", atom, weight, priority,
   // types);
   result[2] =
       String.format(
           ":~ abduced_%s %s. [%d@%d,abduced_%s]", atom, list, weight, priority + BASEPRIO, atom);
   result[3] = String.format("%s:-abduced_%s%s.", atom, atom, list);
   result[4] =
       String.format("number_abduced(%d,V) :- V = #count { abduced_%s%s }.", id, atom, types);
   return result;
 }
Example #2
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + lower;
   result = prime * result + priority;
   result = prime * result + ((scheme == null) ? 0 : scheme.hashCode());
   result = prime * result + upper;
   result = prime * result + weight;
   return result;
 }
Example #3
0
 @Override
 public String toString() {
   String result = KEYWORD;
   result += " " + scheme.toString();
   if (lower != 0 || upper != Integer.MAX_VALUE)
     result += " " + CONSTRAINT_OP + lower + SEPARATOR_OP + upper;
   if (weight != 1) result += " " + WEIGHT_OP + weight;
   if (priority != 1) result += " " + PRIORITY_OP + priority;
   result += ".";
   return result;
 }
Example #4
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ModeH other = (ModeH) obj;
   if (lower != other.lower) return false;
   if (priority != other.priority) return false;
   if (scheme == null) {
     if (other.scheme != null) return false;
   } else if (!scheme.equals(other.scheme)) return false;
   if (upper != other.upper) return false;
   if (weight != other.weight) return false;
   return true;
 }