/** * Checks whether this theory contains the given attack. * @param att some attack * @return "true" iff this theory contains the given attack. */ public boolean containsAttack(Attack att) { if(this.parents.get(att.getAttacked()) == null) return false; return this.parents.get(att.getAttacked()).contains(att.getAttacker()); }
/** * Removes the given attack from this Dung theory. * @param attack an attack * @return "true" if the set of attacks has been modified. */ public boolean remove(Attack attack){ boolean result = false; if(parents.containsKey(attack.getAttacked())) result |= parents.get(attack.getAttacked()).remove(attack.getAttacker()); if(children.containsKey(attack.getAttacker())) result |= children.get(attack.getAttacker()).remove(attack.getAttacked()); return result; }
public boolean equals(Object o){ if(!o.getClass().equals(this.getClass())) return false; if(!this.getAttacker().equals(((Attack)o).getAttacker())) return false; if(!this.getAttacked().equals(((Attack)o).getAttacked())) return false; return true; }
@Override public void write(DungTheory aaf, File f) throws IOException { PrintWriter writer = new PrintWriter(f, "UTF-8"); writer.println("p af " + aaf.size() + " " + aaf.getAttacks().size()); Map<Argument,Integer> map = new HashMap<Argument,Integer>(); int idx = 1; for(Argument arg: aaf) map.put(arg, idx++); for(Attack att: aaf.getAttacks()) writer.println(map.get(att.getAttacker()) + " -" + map.get(att.getAttacked()) + " 0"); writer.close(); } }
@Override public void write(DungTheory aaf, File f) throws IOException { PrintWriter writer = new PrintWriter(f, "UTF-8"); for(Argument a: aaf) writer.println(a.getName()); writer.println("#"); for(Attack att: aaf.getAttacks()) writer.println(att.getAttacker().getName() + " " + att.getAttacked().getName()); writer.close(); }
/** * Adds the given attack to this dung theory. * @param attack an attack * @return "true" if the set of attacks has been modified. */ public boolean add(Attack attack){ return this.addAttack(attack.getAttacker(), attack.getAttacked()); }
/** * returns true if one arguments in <source>arguments</source> attacks another within this attack relation. * @param arguments a list of arguments * @return returns true if one arguments in <source>arguments</source> attacks another. */ public boolean isConflictFree(Collection<? extends Argument> arguments){ Iterator<? extends Argument> it = arguments.iterator(); while(it.hasNext()){ Argument arg = (Argument) it.next(); if(arg.equals(this.getAttacker())){ Iterator<? extends Argument> it2 = arguments.iterator(); while(it2.hasNext()){ Argument arg2 = (Argument) it2.next(); if(arg2.equals(this.getAttacked())) return false; } } } return true; }
@Override public void write(DungTheory aaf, File f) throws IOException { PrintWriter writer = new PrintWriter(f, "UTF-8"); for(Argument a: aaf) writer.println("arg(" + a.getName() + ")."); for(Attack att: aaf.getAttacks()) writer.println("att(" + att.getAttacker().getName() + "," + att.getAttacked().getName() + ")."); writer.close(); }
@Override public Graph<Argument> getRestriction(Collection<Argument> arguments) { DungTheory theory = new DungTheory(); theory.addAll(arguments); for (Attack attack: this.getAttacks()) if(arguments.contains(attack.getAttacked()) && arguments.contains(attack.getAttacker())) theory.add(attack); return theory; }
/** * Return true if the given argument is in this attack relation. * @param argument some argument * @return true if the given argument is in this attack relation. */ public boolean contains(Argument argument){ return this.getAttacked().equals(argument) || this.getAttacker().equals(argument); }
public String toString(){ return "("+this.getAttacker().toString()+","+this.getAttacked().toString()+")"; }
public int hashCode(){ return this.getAttacked().hashCode() + 7 * this.getAttacker().hashCode(); }
public Signature getSignature(){ DungSignature sig = new DungSignature(); sig.add(this.getAttacked()); sig.add(this.getAttacker()); return sig; }
@Override public LdoFormula getLdoFormula() { return new LdoRelation(this.getAttacker().getLdoFormula(), new LdoNegation(this.getAttacked().getLdoFormula())); }
@Override public void update(DialogueTrace<Argument,Extension> trace) { this.getKnownArguments().addAll(trace.getElements()); for(Argument a: trace.getElements()) if(this.rec.get(a) != null) this.virtualArguments.removeAll(this.rec.get(a)); Set<Attack> newVirtualAttacks = new HashSet<Attack>(); for(Attack a: this.virtualAttacks) if(this.virtualArguments.contains(a.getAttacker()) || this.virtualArguments.contains(a.getAttacked())) newVirtualAttacks.add(a); this.virtualAttacks = newVirtualAttacks; ProbabilityFunction<T3BeliefState> newProb = new ProbabilityFunction<T3BeliefState>(); for(T3BeliefState state: this.prob.keySet()){ Probability p = this.prob.get(state); state.update(trace); if(newProb.keySet().contains(state)) newProb.put(state, newProb.get(state).add(p)); else newProb.put(state, p); } this.prob = newProb; }
if(t.contains(a.getAttacked()) && t.contains(a.getAttacker())){ if(!t.areAdjacent(a.getAttacker(), a.getAttacked())){ complete = false; break;