Skip to content

Commit bd8af6b

Browse files
author
“jklein94”
committed
Added missing javadoc EAFAgreementReasonerExample.java
1 parent 60fdacd commit bd8af6b

File tree

1 file changed

+79
-60
lines changed

1 file changed

+79
-60
lines changed

org-tweetyproject-arg-eaf/src/main/java/org/tweetyproject/arg/eaf/examples/EAFAgreementReasonerExample.java

Lines changed: 79 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,68 +26,87 @@
2626
import org.tweetyproject.commons.InferenceMode;
2727

2828
/**
29-
*
29+
* Demonstrates the usage of the {@link EAFAgreementReasoner} to reason over multiple
30+
* Epistemic Argumentation Frameworks (EAFs) that share the same underlying Dung theory.
31+
*
32+
* <p>This example illustrates how agents with different epistemic constraints can express beliefs
33+
* about arguments, and how the agreement reasoner can:
34+
* <ul>
35+
* <li>Query whether arguments are (credulously/skeptically) accepted under a given semantics</li>
36+
* <li>Track multiple EAFs and compare their constraints</li>
37+
* <li>Handle updates to agents’ beliefs</li>
38+
* <li>Perform majority voting on argument acceptance</li>
39+
* </ul>
40+
*
41+
* <p>The scenario includes two mutually attacking arguments {@code a} and {@code r}, and shows how
42+
* different constraints influence reasoning outcomes.
3043
*/
3144
public class EAFAgreementReasonerExample {
3245

33-
/**
34-
* @param args
35-
* @throws Exception
36-
*/
37-
public static void main(String[] args) throws Exception {
38-
Argument a = new Argument("a");
39-
Argument r = new Argument("r");
40-
41-
DungTheory af = new DungTheory();
42-
43-
af.add(a);
44-
af.add(r);
45-
46-
af.addAttack(a,r);
47-
af.addAttack(r,a);
48-
49-
50-
String constEAF1 = "[](in(a))";
51-
String constEAF2 = "[](und(a))";
52-
53-
54-
EpistemicArgumentationFramework eaf1 = new EpistemicArgumentationFramework(af, constEAF1);
55-
EpistemicArgumentationFramework eaf2 = new EpistemicArgumentationFramework(af, constEAF2);
56-
57-
58-
EAFAgreementReasoner agreementReasoner = new EAFAgreementReasoner(eaf1);
59-
60-
//add second EAF with the same constraint
61-
System.out.println("The agreement Reasoner can identify wether multiple agents with the same underlying AF agree on the labeling status of an argument.");
62-
agreementReasoner.addEAF(constEAF1);
63-
System.out.println("\nFor the following AF:");
64-
System.out.println(af.prettyPrint());
65-
System.out.print("Two agents with the same underlying believe: ");
66-
System.out.println(eaf1.getConstraint());
67-
System.out.print("Believe that argument a should be credulously labelled in under complete semantics: ");
68-
System.out.println(agreementReasoner.query("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
69-
70-
System.out.println("\nThe Agreement Reasoner can list all EAFs that it contains:");
71-
agreementReasoner.listEAFs();
72-
System.out.println("EAFs can be added, deleted or changed.");
73-
agreementReasoner.changeEAF(1, eaf2);
74-
System.out.print("If one agent changes its believe to: ");
75-
System.out.println(eaf2.getConstraint());
76-
System.out.print("Believe that argument a should be credulously labelled in under complete semantics: ");
77-
System.out.println(agreementReasoner.query("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
78-
79-
//Majority Voting
80-
System.out.println("\nThe Agreement Reasoner supports majority voting");
81-
String constEAF3 = "[](!und(a))";
82-
agreementReasoner.addEAF(constEAF3);
83-
System.out.println("Given the following EAFs");
84-
agreementReasoner.listEAFs();
85-
System.out.print("Would the majority vote that a should be credulously labelled in under complete semantics: ");
86-
System.out.println(agreementReasoner.majorityVote("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
87-
System.out.print("Would the majority also vote that a should be skeptically labelled in under complete semantics: ");
88-
System.out.println(agreementReasoner.majorityVote("in(a)", InferenceMode.SKEPTICAL, Semantics.CO));
89-
90-
91-
}
46+
/**
47+
* Entry point of the program demonstrating the use of {@link EAFAgreementReasoner}
48+
* with multiple epistemic argumentation frameworks.
49+
*
50+
* <p>The method creates a simple Dung theory with two arguments that attack each other,
51+
* and evaluates whether the argument {@code a} is accepted based on agents' constraints
52+
* using credulous and skeptical reasoning under complete semantics.</p>
53+
*
54+
* @param args command-line arguments (not used).
55+
* @throws Exception if reasoning fails or an invalid constraint is provided.
56+
*/
57+
public static void main(String[] args) throws Exception {
58+
Argument a = new Argument("a");
59+
Argument r = new Argument("r");
9260

61+
DungTheory af = new DungTheory();
62+
af.add(a);
63+
af.add(r);
64+
af.addAttack(a, r);
65+
af.addAttack(r, a);
66+
67+
String constEAF1 = "[](in(a))";
68+
String constEAF2 = "[](und(a))";
69+
70+
EpistemicArgumentationFramework eaf1 = new EpistemicArgumentationFramework(af, constEAF1);
71+
EpistemicArgumentationFramework eaf2 = new EpistemicArgumentationFramework(af, constEAF2);
72+
73+
EAFAgreementReasoner agreementReasoner = new EAFAgreementReasoner(eaf1);
74+
75+
System.out.println("The agreement Reasoner can identify whether multiple agents with the same underlying AF agree on the labeling status of an argument.");
76+
agreementReasoner.addEAF(constEAF1);
77+
78+
System.out.println("\nFor the following AF:");
79+
System.out.println(af.prettyPrint());
80+
81+
System.out.print("Two agents with the same underlying belief: ");
82+
System.out.println(eaf1.getConstraint());
83+
System.out.print("Believe that argument a should be credulously labelled under complete semantics: ");
84+
System.out.println(agreementReasoner.query("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
85+
86+
System.out.println("\nThe Agreement Reasoner can list all EAFs that it contains:");
87+
agreementReasoner.listEAFs();
88+
89+
System.out.println("EAFs can be added, deleted or changed.");
90+
agreementReasoner.changeEAF(1, eaf2);
91+
92+
System.out.print("If one agent changes its belief to: ");
93+
System.out.println(eaf2.getConstraint());
94+
System.out.print("Then belief that argument a should be credulously labelled under complete semantics: ");
95+
System.out.println(agreementReasoner.query("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
96+
97+
// Majority voting
98+
System.out.println("\nThe Agreement Reasoner supports majority voting");
99+
String constEAF3 = "[](!und(a))";
100+
agreementReasoner.addEAF(constEAF3);
101+
102+
System.out.println("Given the following EAFs:");
103+
agreementReasoner.listEAFs();
104+
105+
System.out.print("Would the majority vote that a should be credulously labelled under complete semantics: ");
106+
System.out.println(agreementReasoner.majorityVote("in(a)", InferenceMode.CREDULOUS, Semantics.CO));
107+
108+
System.out.print("Would the majority also vote that a should be skeptically labelled under complete semantics: ");
109+
System.out.println(agreementReasoner.majorityVote("in(a)", InferenceMode.SKEPTICAL, Semantics.CO));
110+
}
93111
}
112+

0 commit comments

Comments
 (0)