Skip to content

Commit 52e8429

Browse files
committed
Additional info on leaf features
1 parent dcf8065 commit 52e8429

6 files changed

Lines changed: 75 additions & 7 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ build/
3434
.vscode/
3535

3636
### Mac OS ###
37-
.DS_Store
37+
.DS_Store
38+
39+
*.log

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ The tool analysis and prints out the following statistics of given knowledge bas
2222
2. **Statistics for feature model**
2323
- The CTC ratio
2424
- The number of features
25+
- The number of leaf features
2526
- The number of relationships
2627
- The number of cross-tree constraints
2728
- The number of MANDATORY relationships

pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
<groupId>at.tugraz.ist.ase.hiconfit</groupId>
1616
<artifactId>kbstatistics</artifactId>
17-
<version>1.3.1</version>
17+
<version>1.3.2</version>
1818
<packaging>jar</packaging>
1919

2020
<properties>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2323
<maven.compiler.source>20</maven.compiler.source>
2424
<maven.compiler.target>20</maven.compiler.target>
25-
<artifact.version>0.1.1-alpha-04</artifact.version>
25+
<kb.version>1.0.1-alpha-32</kb.version>
2626
</properties>
2727

2828
<profiles>
@@ -42,13 +42,13 @@
4242
<dependency>
4343
<groupId>at.tugraz.ist.ase.hiconfit</groupId>
4444
<artifactId>kb</artifactId>
45-
<version>${artifact.version}</version>
45+
<version>${kb.version}</version>
4646
</dependency>
4747

4848
<dependency>
4949
<groupId>ch.qos.logback</groupId>
5050
<artifactId>logback-classic</artifactId>
51-
<version>1.4.6</version>
51+
<version>1.4.12</version>
5252
<scope>test</scope>
5353
<exclusions>
5454
<exclusion> <!-- declare the exclusion here -->
@@ -57,6 +57,13 @@
5757
</exclusion>
5858
</exclusions>
5959
</dependency>
60+
61+
<dependency>
62+
<groupId>org.junit.jupiter</groupId>
63+
<artifactId>junit-jupiter</artifactId>
64+
<version>5.10.2</version>
65+
<scope>test</scope>
66+
</dependency>
6067
</dependencies>
6168

6269
<build>

src/main/java/at/tugraz/ist/ase/hiconfit/KBStatistics.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ private void saveFMStatistics(BufferedWriter writer, int counter, KB kb,
202202
writer.newLine();
203203
writer.write("CTC ratio: " + ctc); writer.newLine();
204204
writer.write("#features: " + fm.getNumOfFeatures()); writer.newLine();
205+
writer.write("#leaf features: " + fm.getNumOfLeaf()); writer.newLine();
205206
writer.write("#relationships: " + fm.getNumOfRelationships()); writer.newLine();
206207
writer.write("#constraints: " + fm.getNumOfConstraints()); writer.newLine();
207208
writer.write("#MANDATORY: " + fm.getNumOfRelationships(MandatoryRelationship.class)); writer.newLine();

src/test/java/at/tugraz/ist/ase/hiconfit/KBStatisticsTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void testOneFM() {
142142
143143
CTC ratio: 0.4
144144
#features: 12
145+
#leaf features: 9
145146
#relationships: 6
146147
#constraints: 4
147148
#MANDATORY: 2
@@ -153,6 +154,48 @@ void testOneFM() {
153154
assertEquals(expected, content.get());
154155
}
155156

157+
@Test
158+
void testOneFM_2() {
159+
String[] args = new String[]{"-fm", "./src/test/resources/fms/bamboobike.fm4conf"};
160+
161+
KBStatistics_CmdLineOptions options = new KBStatistics_CmdLineOptions(null, programTitle, null, usage);
162+
options.parseArgument(args);
163+
164+
KBStatistics kbStatistics = new KBStatistics(options);
165+
166+
assertDoesNotThrow(kbStatistics::calculate);
167+
168+
File file = new File("statistics.txt");
169+
assertTrue(file.exists());
170+
171+
// read the content from file
172+
AtomicReference<String> content = new AtomicReference<>("");
173+
assertDoesNotThrow(() -> content.set(String.join("\n", Files.readAllLines(file.toPath()))));
174+
175+
String expected = """
176+
1
177+
Name: bamboobike.fm4conf
178+
Source: SPLOT
179+
#variables: 11
180+
#constraints: 8
181+
#Choco variables: 26
182+
#Choco constraints: 20
183+
Consistency: true
184+
185+
CTC ratio: 0.25
186+
#features: 11
187+
#leaf features: 8
188+
#relationships: 6
189+
#constraints: 2
190+
#MANDATORY: 2
191+
#OPTIONAL: 2
192+
#ALTERNATIVE: 1
193+
#OR: 1
194+
#REQUIRES: 1
195+
#EXCLUDES: 1""";
196+
assertEquals(expected, content.get());
197+
}
198+
156199
@Test
157200
void testManyFMs() {
158201
String[] args = new String[]{"-fm-dir", "./src/test/resources/fms"};
@@ -183,6 +226,7 @@ void testManyFMs() {
183226
184227
CTC ratio: 0.25
185228
#features: 11
229+
#leaf features: 8
186230
#relationships: 6
187231
#constraints: 2
188232
#MANDATORY: 2
@@ -202,6 +246,7 @@ void testManyFMs() {
202246
203247
CTC ratio: 0.25
204248
#features: 11
249+
#leaf features: 8
205250
#relationships: 6
206251
#constraints: 2
207252
#MANDATORY: 2
@@ -221,6 +266,7 @@ void testManyFMs() {
221266
222267
CTC ratio: 0.25
223268
#features: 11
269+
#leaf features: 8
224270
#relationships: 6
225271
#constraints: 2
226272
#MANDATORY: 2
@@ -240,6 +286,7 @@ void testManyFMs() {
240286
241287
CTC ratio: 0.25
242288
#features: 11
289+
#leaf features: 8
243290
#relationships: 6
244291
#constraints: 2
245292
#MANDATORY: 2
@@ -259,6 +306,7 @@ void testManyFMs() {
259306
260307
CTC ratio: 0.3218390804597701
261308
#features: 263
309+
#leaf features: 160
262310
#relationships: 177
263311
#constraints: 84
264312
#MANDATORY: 67
@@ -278,6 +326,7 @@ void testManyFMs() {
278326
279327
CTC ratio: 0.25
280328
#features: 11
329+
#leaf features: 8
281330
#relationships: 6
282331
#constraints: 2
283332
#MANDATORY: 2
@@ -297,6 +346,7 @@ void testManyFMs() {
297346
298347
CTC ratio: 0.4
299348
#features: 12
349+
#leaf features: 9
300350
#relationships: 6
301351
#constraints: 4
302352
#MANDATORY: 2
@@ -346,6 +396,7 @@ void testManyFMsAndKB() {
346396
347397
CTC ratio: 0.25
348398
#features: 11
399+
#leaf features: 8
349400
#relationships: 6
350401
#constraints: 2
351402
#MANDATORY: 2
@@ -365,6 +416,7 @@ void testManyFMsAndKB() {
365416
366417
CTC ratio: 0.25
367418
#features: 11
419+
#leaf features: 8
368420
#relationships: 6
369421
#constraints: 2
370422
#MANDATORY: 2
@@ -384,6 +436,7 @@ void testManyFMsAndKB() {
384436
385437
CTC ratio: 0.25
386438
#features: 11
439+
#leaf features: 8
387440
#relationships: 6
388441
#constraints: 2
389442
#MANDATORY: 2
@@ -403,6 +456,7 @@ void testManyFMsAndKB() {
403456
404457
CTC ratio: 0.25
405458
#features: 11
459+
#leaf features: 8
406460
#relationships: 6
407461
#constraints: 2
408462
#MANDATORY: 2
@@ -422,6 +476,7 @@ void testManyFMsAndKB() {
422476
423477
CTC ratio: 0.3218390804597701
424478
#features: 263
479+
#leaf features: 160
425480
#relationships: 177
426481
#constraints: 84
427482
#MANDATORY: 67
@@ -441,6 +496,7 @@ void testManyFMsAndKB() {
441496
442497
CTC ratio: 0.25
443498
#features: 11
499+
#leaf features: 8
444500
#relationships: 6
445501
#constraints: 2
446502
#MANDATORY: 2
@@ -460,6 +516,7 @@ void testManyFMsAndKB() {
460516
461517
CTC ratio: 0.4
462518
#features: 12
519+
#leaf features: 9
463520
#relationships: 6
464521
#constraints: 4
465522
#MANDATORY: 2

src/test/resources/fms/bamboobike.fm4conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Back-pedal
1616
RELATIONSHIPS:
1717
mandatory(Bamboo Bike, Frame),
1818
mandatory(Bamboo Bike, Brake),
19-
optional(Engine, Bamboo Bike),
20-
optional(Drop Handlebar, Bamboo Bike),
19+
optional(Bamboo Bike, Engine),
20+
optional(Bamboo Bike, Drop Handlebar),
2121
alternative(Frame, Female, Male, Step-through),
2222
or(Brake, Front, Rear, Back-pedal)
2323
CONSTRAINTS:

0 commit comments

Comments
 (0)