3939 * A semantics is serialisable iff it can be characterised by two functions
4040 * <br>
4141 * <ul>
42- * <li>{@link SelectionFunction} a(UA, UC, C): Return a subset of the initial sets
43- * <li>{@link TerminationFunction} b(AF, S): True, iff S is an extension
42+ * <li>{@link SelectionFunction} a(UA, UC, C): Return a subset of the initial
43+ * sets
44+ * <li>{@link TerminationFunction} b(AF, S): True, iff S is an extension
4445 * </ul>
45- * which describe a transition system where {@code a(UA,UC,C)} provides the possible transitions to new states
46- * and {@code b(AF,S)} determines whether the current state is an extension of the semantics.
46+ * which describe a transition system where {@code a(UA,UC,C)} provides the
47+ * possible transitions to new states
48+ * and {@code b(AF,S)} determines whether the current state is an extension of
49+ * the semantics.
4750 *
4851 * @see "Matthias Thimm. 'Revisiting initial sets in abstract argumentation' Argument & Computation (2022)"
4952 *
@@ -58,19 +61,23 @@ public class SerialisedExtensionReasoner extends AbstractExtensionReasoner {
5861 private final Semantics semantics ;
5962
6063 /**
61- * Initializes a serialisation reasoner with the given selection and termination functions
64+ * Initializes a serialisation reasoner with the given selection and termination
65+ * functions
66+ *
6267 * @param alpha some selection function
63- * @param beta some termination function
68+ * @param beta some termination function
6469 */
6570 public SerialisedExtensionReasoner (SelectionFunction alpha , TerminationFunction beta ) {
6671 this (alpha , beta , Semantics .diverse );
6772 }
6873
6974 /**
70- * Initializes a serialisation reasoner with the given selection and termination functions
75+ * Initializes a serialisation reasoner with the given selection and termination
76+ * functions
7177 * and sets the semantics
72- * @param alpha some selection function
73- * @param beta some termination function
78+ *
79+ * @param alpha some selection function
80+ * @param beta some termination function
7481 * @param semantics some semantics
7582 */
7683 public SerialisedExtensionReasoner (SelectionFunction alpha , TerminationFunction beta , Semantics semantics ) {
@@ -81,6 +88,7 @@ public SerialisedExtensionReasoner(SelectionFunction alpha, TerminationFunction
8188
8289 /**
8390 * Initializes a serialisation reasoner for the given semantics
91+ *
8492 * @param semantics some selection function
8593 */
8694 public SerialisedExtensionReasoner (Semantics semantics ) {
@@ -89,32 +97,39 @@ public SerialisedExtensionReasoner(Semantics semantics) {
8997 case ADM -> {
9098 selectionFunction = SelectionFunction .ADMISSIBLE ;
9199 terminationFunction = TerminationFunction .ADMISSIBLE ;
92- } case CO -> {
100+ }
101+ case CO -> {
93102 selectionFunction = SelectionFunction .ADMISSIBLE ;
94103 terminationFunction = TerminationFunction .COMPLETE ;
95- } case PR -> {
104+ }
105+ case PR -> {
96106 selectionFunction = SelectionFunction .ADMISSIBLE ;
97107 terminationFunction = TerminationFunction .PREFERRED ;
98- } case SAD -> {
108+ }
109+ case SAD -> {
99110 selectionFunction = SelectionFunction .GROUNDED ;
100111 terminationFunction = TerminationFunction .ADMISSIBLE ;
101- } case GR -> {
112+ }
113+ case GR -> {
102114 selectionFunction = SelectionFunction .GROUNDED ;
103115 terminationFunction = TerminationFunction .COMPLETE ;
104- } case UC -> {
116+ }
117+ case UC -> {
105118 selectionFunction = SelectionFunction .UNCHALLENGED ;
106119 terminationFunction = TerminationFunction .UNCHALLENGED ;
107- } case ST -> {
120+ }
121+ case ST -> {
108122 selectionFunction = SelectionFunction .ADMISSIBLE ;
109123 terminationFunction = TerminationFunction .STABLE ;
110- } default -> throw new IllegalArgumentException ("Semantics is not serialisable: " + semantics );
124+ }
125+ default -> throw new IllegalArgumentException ("Semantics is not serialisable: " + semantics );
111126 }
112127 }
113128
114129 @ Override
115130 public Collection <Extension <DungTheory >> getModels (DungTheory bbase ) {
116131 Collection <Extension <DungTheory >> result = new HashSet <>();
117- for (SerialisationSequence sequence : this .getSequences (bbase )) {
132+ for (SerialisationSequence sequence : this .getSequences (bbase )) {
118133 result .add (sequence .getExtension ());
119134 }
120135 return result ;
@@ -128,16 +143,18 @@ public Extension<DungTheory> getModel(DungTheory bbase) {
128143
129144 /**
130145 * Computes the set of serialisation sequences wrt. the semantics
146+ *
131147 * @param bbase some argumentation framework
132148 * @return the set of serialisation sequences
133149 */
134- public Collection <SerialisationSequence > getSequences (DungTheory bbase ){
150+ public Collection <SerialisationSequence > getSequences (DungTheory bbase ) {
135151 return this .getSequences (bbase , new SerialisationSequence ());
136152 }
137153
138154 /**
139155 * Recursively computes all serialisation sequences wrt. the semantics
140- * @param theory an argumentation framework
156+ *
157+ * @param theory an argumentation framework
141158 * @param parentSequence the current serialisation sequence
142159 * @return the set of serialisation sequences
143160 */
@@ -148,10 +165,13 @@ private Collection<SerialisationSequence> getSequences(DungTheory theory, Serial
148165 if (this .isTerminal (theory , parentSequence .getExtension ())) {
149166 result .add (parentSequence );
150167 }
151- Map <SimpleInitialReasoner .Initial , Collection <Extension <DungTheory >>> initialSets = SimpleInitialReasoner .partitionInitialSets (theory );
152- Collection <Extension <DungTheory >> candidateSets = this .getSelection (initialSets .get (UA ), initialSets .get (UC ), initialSets .get (C ));
153- // iterate depth-first through all initial sets (and hence their induced states) and add all found serialisation sequences
154- for (Extension <DungTheory > set : candidateSets ) {
168+ Map <SimpleInitialReasoner .Initial , Collection <Extension <DungTheory >>> initialSets = SimpleInitialReasoner
169+ .partitionInitialSets (theory );
170+ Collection <Extension <DungTheory >> candidateSets = this .getSelection (initialSets .get (UA ), initialSets .get (UC ),
171+ initialSets .get (C ));
172+ // iterate depth-first through all initial sets (and hence their induced states)
173+ // and add all found serialisation sequences
174+ for (Extension <DungTheory > set : candidateSets ) {
155175 DungTheory reduct = theory .getReduct (set );
156176
157177 SerialisationSequence newSequence = new SerialisationSequence (parentSequence );
@@ -163,10 +183,12 @@ private Collection<SerialisationSequence> getSequences(DungTheory theory, Serial
163183 }
164184
165185 /**
166- * Creates a graph, visualizing the transition states of the serialisation process, which creates all serialisable extensions
186+ * Creates a graph, visualizing the transition states of the serialisation
187+ * process, which creates all serialisable extensions
167188 * according to the specified semantics of the specified framework.
168189 *
169- * @param bbase argumentation framework, for which the extensions shall be computed
190+ * @param bbase argumentation framework, for which the extensions shall be
191+ * computed
170192 * @return Graph representing the serialisation sequences
171193 */
172194 public SerialisationGraph getSerialisationGraph (DungTheory bbase ) {
@@ -175,17 +197,43 @@ public SerialisationGraph getSerialisationGraph(DungTheory bbase) {
175197
176198 /**
177199 * Return the semantics of this reasoner
200+ *
178201 * @return the semantics
179202 */
180203 public Semantics getSemantics () {
181204 return semantics ;
182205 }
183206
184- public Collection <Extension <DungTheory >> getSelection (Collection <Extension <DungTheory >> ua , Collection <Extension <DungTheory >> uc , Collection <Extension <DungTheory >> c ) {
185- return this .selectionFunction .execute ((Set <Extension <DungTheory >>) ua , (Set <Extension <DungTheory >>) uc , (Set <Extension <DungTheory >>) c );
207+ /**
208+ * Applies a selection function to compute a collection of preferred extensions
209+ * from given sets of extensions.
210+ *
211+ * @param ua A collection of unattacked extensions of the Dung theory.
212+ * @param uc A collection of unattacked but conflicting extensions.
213+ * @param c A collection of conflicting extensions.
214+ * @return A collection of {@link Extension} objects selected based on the
215+ * applied selection function.
216+ *
217+ * @throws ClassCastException if any of the input collections cannot be cast to
218+ * {@link Set<Extension<DungTheory>>}.
219+ */
220+ public Collection <Extension <DungTheory >> getSelection (Collection <Extension <DungTheory >> ua ,
221+ Collection <Extension <DungTheory >> uc , Collection <Extension <DungTheory >> c ) {
222+ return this .selectionFunction .execute ((Set <Extension <DungTheory >>) ua , (Set <Extension <DungTheory >>) uc ,
223+ (Set <Extension <DungTheory >>) c );
186224 }
187225
226+ /**
227+ * Checks whether a given extension is terminal in the specified Dung theory.
228+ *
229+ *
230+ * @param theory The {@link DungTheory} in which the extension is evaluated.
231+ * @param extension The {@link Extension} to be checked for terminal status.
232+ * @return {@code true} if the extension is terminal in the given theory;
233+ * {@code false} otherwise.
234+ */
188235 public boolean isTerminal (DungTheory theory , Extension <DungTheory > extension ) {
189236 return this .terminationFunction .execute (theory , extension );
190237 }
238+
191239}
0 commit comments