Skip to content

Commit

Permalink
Additional info on leaf features
Browse files Browse the repository at this point in the history
  • Loading branch information
manleviet committed Apr 28, 2024
1 parent dcf8065 commit 52e8429
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ build/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

*.log
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The tool analysis and prints out the following statistics of given knowledge bas
2. **Statistics for feature model**
- The CTC ratio
- The number of features
- The number of leaf features
- The number of relationships
- The number of cross-tree constraints
- The number of MANDATORY relationships
Expand Down
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

<groupId>at.tugraz.ist.ase.hiconfit</groupId>
<artifactId>kbstatistics</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<artifact.version>0.1.1-alpha-04</artifact.version>
<kb.version>1.0.1-alpha-32</kb.version>
</properties>

<profiles>
Expand All @@ -42,13 +42,13 @@
<dependency>
<groupId>at.tugraz.ist.ase.hiconfit</groupId>
<artifactId>kb</artifactId>
<version>${artifact.version}</version>
<version>${kb.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.6</version>
<version>1.4.12</version>
<scope>test</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
Expand All @@ -57,6 +57,13 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/at/tugraz/ist/ase/hiconfit/KBStatistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private void saveFMStatistics(BufferedWriter writer, int counter, KB kb,
writer.newLine();
writer.write("CTC ratio: " + ctc); writer.newLine();
writer.write("#features: " + fm.getNumOfFeatures()); writer.newLine();
writer.write("#leaf features: " + fm.getNumOfLeaf()); writer.newLine();
writer.write("#relationships: " + fm.getNumOfRelationships()); writer.newLine();
writer.write("#constraints: " + fm.getNumOfConstraints()); writer.newLine();
writer.write("#MANDATORY: " + fm.getNumOfRelationships(MandatoryRelationship.class)); writer.newLine();
Expand Down
57 changes: 57 additions & 0 deletions src/test/java/at/tugraz/ist/ase/hiconfit/KBStatisticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void testOneFM() {
CTC ratio: 0.4
#features: 12
#leaf features: 9
#relationships: 6
#constraints: 4
#MANDATORY: 2
Expand All @@ -153,6 +154,48 @@ void testOneFM() {
assertEquals(expected, content.get());
}

@Test
void testOneFM_2() {
String[] args = new String[]{"-fm", "./src/test/resources/fms/bamboobike.fm4conf"};

KBStatistics_CmdLineOptions options = new KBStatistics_CmdLineOptions(null, programTitle, null, usage);
options.parseArgument(args);

KBStatistics kbStatistics = new KBStatistics(options);

assertDoesNotThrow(kbStatistics::calculate);

File file = new File("statistics.txt");
assertTrue(file.exists());

// read the content from file
AtomicReference<String> content = new AtomicReference<>("");
assertDoesNotThrow(() -> content.set(String.join("\n", Files.readAllLines(file.toPath()))));

String expected = """
1
Name: bamboobike.fm4conf
Source: SPLOT
#variables: 11
#constraints: 8
#Choco variables: 26
#Choco constraints: 20
Consistency: true
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
#OPTIONAL: 2
#ALTERNATIVE: 1
#OR: 1
#REQUIRES: 1
#EXCLUDES: 1""";
assertEquals(expected, content.get());
}

@Test
void testManyFMs() {
String[] args = new String[]{"-fm-dir", "./src/test/resources/fms"};
Expand Down Expand Up @@ -183,6 +226,7 @@ void testManyFMs() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -202,6 +246,7 @@ void testManyFMs() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -221,6 +266,7 @@ void testManyFMs() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -240,6 +286,7 @@ void testManyFMs() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -259,6 +306,7 @@ void testManyFMs() {
CTC ratio: 0.3218390804597701
#features: 263
#leaf features: 160
#relationships: 177
#constraints: 84
#MANDATORY: 67
Expand All @@ -278,6 +326,7 @@ void testManyFMs() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -297,6 +346,7 @@ void testManyFMs() {
CTC ratio: 0.4
#features: 12
#leaf features: 9
#relationships: 6
#constraints: 4
#MANDATORY: 2
Expand Down Expand Up @@ -346,6 +396,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -365,6 +416,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -384,6 +436,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -403,6 +456,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -422,6 +476,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.3218390804597701
#features: 263
#leaf features: 160
#relationships: 177
#constraints: 84
#MANDATORY: 67
Expand All @@ -441,6 +496,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.25
#features: 11
#leaf features: 8
#relationships: 6
#constraints: 2
#MANDATORY: 2
Expand All @@ -460,6 +516,7 @@ void testManyFMsAndKB() {
CTC ratio: 0.4
#features: 12
#leaf features: 9
#relationships: 6
#constraints: 4
#MANDATORY: 2
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/fms/bamboobike.fm4conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Back-pedal
RELATIONSHIPS:
mandatory(Bamboo Bike, Frame),
mandatory(Bamboo Bike, Brake),
optional(Engine, Bamboo Bike),
optional(Drop Handlebar, Bamboo Bike),
optional(Bamboo Bike, Engine),
optional(Bamboo Bike, Drop Handlebar),
alternative(Frame, Female, Male, Step-through),
or(Brake, Front, Rear, Back-pedal)
CONSTRAINTS:
Expand Down

0 comments on commit 52e8429

Please sign in to comment.