|
30 | 30 | import org.tweetyproject.arg.eaf.writer.EafApxWriter; |
31 | 31 |
|
32 | 32 | /** |
33 | | - * |
| 33 | + * Demonstrates the generation and export of {@link EpistemicArgumentationFramework}s (EAFs) |
| 34 | + * using various generation strategies. |
| 35 | + * |
| 36 | + * <p>The generated EAFs are written to `.apx` files using {@link EafApxWriter}. |
| 37 | + * Three approaches are shown: |
| 38 | + * <ul> |
| 39 | + * <li>Random EAF generation using {@link DefaultDungTheoryGenerator}</li> |
| 40 | + * <li>Controlled generation with specific structural and semantic properties using {@link KwtDungTheoryGenerator}</li> |
| 41 | + * <li>Generation based on a custom, user-defined {@link DungTheory}</li> |
| 42 | + * </ul> |
| 43 | + * |
| 44 | + * <p>The results are saved in separate subfolders under the user's {@code Documents/TweetyProject/EafTheoryGeneratorExample} directory. |
34 | 45 | */ |
35 | 46 | public class EafTheoryGeneratorExample { |
36 | 47 |
|
37 | | - /** Default Constructor */ |
38 | | - public EafTheoryGeneratorExample(){ |
39 | | - |
40 | | - } |
41 | | - |
42 | | - /** |
43 | | - * @param args |
44 | | - * @throws IOException |
45 | | - */ |
46 | | - public static void main(String[] args) throws IOException { |
47 | | - EafApxWriter writer = new EafApxWriter(); |
48 | | - String path = System.getProperty("user.home") |
49 | | - + File.separator + "Documents" |
50 | | - + File.separator + "TweetyProject" |
51 | | - + File.separator + "EafTheoryGeneratorExample"; |
52 | | - createDir(path); |
53 | | - |
54 | | - |
55 | | - //EAFs generated with DefaultDungTheoryGenerator and random constraint |
56 | | - EafTheoryGenerator EAFgen = new EafTheoryGenerator(); |
57 | | - |
58 | | - String pathSubFolder = path + File.separator + "default"; |
59 | | - createDir(pathSubFolder); |
60 | | - for (int i = 0; i < 20; i++) { |
61 | | - File f = new File(pathSubFolder + File.separator + "eaf_" + i + ".apx"); |
62 | | - writer.write(EAFgen.next(), f); |
63 | | - } |
64 | | - |
65 | | - //EAFs generated with the same underlying DungTheory using the KWTDungTheoryGenerator |
66 | | - |
67 | | - int num_arguments = 150; |
68 | | - int num_skept_arguments = 50; |
69 | | - int size_ideal_extension = 20; |
70 | | - int num_cred_arguments = 10; |
71 | | - int num_pref_exts = 100; |
72 | | - double p_ideal_attacked = 0.3; |
73 | | - double p_ideal_attack_back = 0.2; |
74 | | - double p_other_skept_args_attacked = 0.3; |
75 | | - double p_other_skept_args_attack_back = 0.2; |
76 | | - double p_cred_args_attacked = 0.3; |
77 | | - double p_cred_args_attack_back = 0.2; |
78 | | - double p_other_attacks = 0.2; |
79 | | - |
80 | | - |
81 | | - EAFgen = new EafTheoryGenerator(new KwtDungTheoryGenerator(num_arguments, |
82 | | - num_skept_arguments, |
83 | | - size_ideal_extension, |
84 | | - num_cred_arguments, |
85 | | - num_pref_exts, |
86 | | - p_ideal_attacked, |
87 | | - p_ideal_attack_back, |
88 | | - p_other_skept_args_attacked, |
89 | | - p_other_skept_args_attack_back, |
90 | | - p_cred_args_attacked, |
91 | | - p_cred_args_attack_back, |
92 | | - p_other_attacks)); |
93 | | - |
94 | | - pathSubFolder = path + File.separator + "kwt"; |
95 | | - createDir(pathSubFolder); |
96 | | - ArrayList<EpistemicArgumentationFramework> eafs = EAFgen.next(20); |
97 | | - |
98 | | - int index = 0; |
99 | | - for(EpistemicArgumentationFramework eaf:eafs) { |
100 | | - File f = new File(pathSubFolder + File.separator + "eaf_" + index + ".apx"); |
101 | | - writer.write(eaf, f); |
102 | | - index++; |
103 | | - } |
104 | | - |
105 | | - |
106 | | - //EAFs generated with the same underlying DungTheory by passing a DungTheory to next |
107 | | - DungTheory theory = new DungTheory(); |
108 | | - |
109 | | - Argument a = new Argument("a"); |
110 | | - Argument b = new Argument("b"); |
111 | | - Argument c = new Argument("c"); |
112 | | - Argument d = new Argument("d"); |
113 | | - Argument e = new Argument("e"); |
114 | | - Argument f = new Argument("f"); |
115 | | - |
116 | | - theory.add(a); |
117 | | - theory.add(b); |
118 | | - theory.add(c); |
119 | | - theory.add(d); |
120 | | - theory.add(e); |
121 | | - theory.add(f); |
122 | | - theory.addAttack(a,b); |
123 | | - theory.addAttack(a,c); |
124 | | - theory.addAttack(b,d); |
125 | | - theory.addAttack(c,e); |
126 | | - theory.addAttack(e,f); |
127 | | - theory.addAttack(f,e); |
128 | | - |
129 | | - pathSubFolder = path + File.separator + "givenAF"; |
130 | | - createDir(pathSubFolder); |
131 | | - eafs = EAFgen.next(theory, 20); |
132 | | - |
133 | | - index = 0; |
134 | | - for(EpistemicArgumentationFramework eaf:eafs) { |
135 | | - File f2 = new File(pathSubFolder + File.separator + "eaf_" + index + ".apx"); |
136 | | - writer.write(eaf, f2); |
137 | | - index++; |
138 | | - } |
139 | | - } |
140 | | - |
141 | | - private static void createDir(String path) { |
142 | | - File customDir = new File(path); |
143 | | - customDir.mkdirs(); |
144 | | - } |
145 | | - |
| 48 | + /** Default constructor (unused). */ |
| 49 | + public EafTheoryGeneratorExample() { |
| 50 | + } |
146 | 51 |
|
| 52 | + /** |
| 53 | + * Entry point of the program that generates multiple sets of EAFs and stores them as `.apx` files. |
| 54 | + * |
| 55 | + * <p>Three types of EAF datasets are created: |
| 56 | + * <ul> |
| 57 | + * <li>20 randomly generated EAFs using {@link DefaultDungTheoryGenerator}</li> |
| 58 | + * <li>20 structured EAFs generated using {@link KwtDungTheoryGenerator}, with controlled semantic properties</li> |
| 59 | + * <li>20 EAFs derived from a manually constructed {@link DungTheory}</li> |
| 60 | + * </ul> |
| 61 | + * |
| 62 | + * @param args command-line arguments (not used) |
| 63 | + * @throws IOException if writing any of the generated files fails |
| 64 | + */ |
| 65 | + public static void main(String[] args) throws IOException { |
| 66 | + EafApxWriter writer = new EafApxWriter(); |
| 67 | + String path = System.getProperty("user.home") |
| 68 | + + File.separator + "Documents" |
| 69 | + + File.separator + "TweetyProject" |
| 70 | + + File.separator + "EafTheoryGeneratorExample"; |
| 71 | + createDir(path); |
| 72 | + |
| 73 | + // Generate 20 EAFs using DefaultDungTheoryGenerator and random constraints |
| 74 | + EafTheoryGenerator EAFgen = new EafTheoryGenerator(); |
| 75 | + String pathSubFolder = path + File.separator + "default"; |
| 76 | + createDir(pathSubFolder); |
| 77 | + for (int i = 0; i < 20; i++) { |
| 78 | + File f = new File(pathSubFolder + File.separator + "eaf_" + i + ".apx"); |
| 79 | + writer.write(EAFgen.next(), f); |
| 80 | + } |
| 81 | + |
| 82 | + // Generate 20 EAFs using KwtDungTheoryGenerator with specific parameters |
| 83 | + int num_arguments = 150; |
| 84 | + int num_skept_arguments = 50; |
| 85 | + int size_ideal_extension = 20; |
| 86 | + int num_cred_arguments = 10; |
| 87 | + int num_pref_exts = 100; |
| 88 | + double p_ideal_attacked = 0.3; |
| 89 | + double p_ideal_attack_back = 0.2; |
| 90 | + double p_other_skept_args_attacked = 0.3; |
| 91 | + double p_other_skept_args_attack_back = 0.2; |
| 92 | + double p_cred_args_attacked = 0.3; |
| 93 | + double p_cred_args_attack_back = 0.2; |
| 94 | + double p_other_attacks = 0.2; |
| 95 | + |
| 96 | + EAFgen = new EafTheoryGenerator(new KwtDungTheoryGenerator( |
| 97 | + num_arguments, |
| 98 | + num_skept_arguments, |
| 99 | + size_ideal_extension, |
| 100 | + num_cred_arguments, |
| 101 | + num_pref_exts, |
| 102 | + p_ideal_attacked, |
| 103 | + p_ideal_attack_back, |
| 104 | + p_other_skept_args_attacked, |
| 105 | + p_other_skept_args_attack_back, |
| 106 | + p_cred_args_attacked, |
| 107 | + p_cred_args_attack_back, |
| 108 | + p_other_attacks |
| 109 | + )); |
| 110 | + |
| 111 | + pathSubFolder = path + File.separator + "kwt"; |
| 112 | + createDir(pathSubFolder); |
| 113 | + ArrayList<EpistemicArgumentationFramework> eafs = EAFgen.next(20); |
| 114 | + |
| 115 | + int index = 0; |
| 116 | + for (EpistemicArgumentationFramework eaf : eafs) { |
| 117 | + File f = new File(pathSubFolder + File.separator + "eaf_" + index + ".apx"); |
| 118 | + writer.write(eaf, f); |
| 119 | + index++; |
| 120 | + } |
| 121 | + |
| 122 | + // Generate 20 EAFs based on a fixed, custom DungTheory |
| 123 | + DungTheory theory = new DungTheory(); |
| 124 | + Argument a = new Argument("a"); |
| 125 | + Argument b = new Argument("b"); |
| 126 | + Argument c = new Argument("c"); |
| 127 | + Argument d = new Argument("d"); |
| 128 | + Argument e = new Argument("e"); |
| 129 | + Argument f = new Argument("f"); |
| 130 | + |
| 131 | + theory.add(a); |
| 132 | + theory.add(b); |
| 133 | + theory.add(c); |
| 134 | + theory.add(d); |
| 135 | + theory.add(e); |
| 136 | + theory.add(f); |
| 137 | + theory.addAttack(a, b); |
| 138 | + theory.addAttack(a, c); |
| 139 | + theory.addAttack(b, d); |
| 140 | + theory.addAttack(c, e); |
| 141 | + theory.addAttack(e, f); |
| 142 | + theory.addAttack(f, e); |
| 143 | + |
| 144 | + pathSubFolder = path + File.separator + "givenAF"; |
| 145 | + createDir(pathSubFolder); |
| 146 | + eafs = EAFgen.next(theory, 20); |
| 147 | + |
| 148 | + index = 0; |
| 149 | + for (EpistemicArgumentationFramework eaf : eafs) { |
| 150 | + File f2 = new File(pathSubFolder + File.separator + "eaf_" + index + ".apx"); |
| 151 | + writer.write(eaf, f2); |
| 152 | + index++; |
| 153 | + } |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Creates the given directory if it does not already exist. |
| 158 | + * |
| 159 | + * @param path the absolute path to the directory |
| 160 | + */ |
| 161 | + private static void createDir(String path) { |
| 162 | + File customDir = new File(path); |
| 163 | + customDir.mkdirs(); |
| 164 | + } |
147 | 165 | } |
148 | 166 |
|
149 | 167 |
|
| 168 | + |
0 commit comments