-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e01250f
commit 29a6bfe
Showing
13 changed files
with
473 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jbpt.pm.log; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ActivityOps extends EventDataOps<String> { | ||
|
||
public ActivityOps(EventLog eventLog) { | ||
super(eventLog); | ||
} | ||
|
||
@Override | ||
List<String> getEventData() { | ||
return getEvents(); | ||
} | ||
|
||
private List<String> getEvents() { | ||
List<String> activities = new ArrayList<>(); | ||
|
||
for (Trace trace : this.eventLog) { | ||
activities.addAll(trace); | ||
} | ||
return activities; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.jbpt.pm.log; | ||
|
||
import org.apache.commons.math3.util.Pair; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DFRelationOps extends EventDataOps<Pair> { | ||
|
||
public DFRelationOps(EventLog eventLog) { | ||
super(eventLog); | ||
} | ||
|
||
@Override | ||
List<Pair> getEventData() { | ||
return getRelations(); | ||
} | ||
|
||
private List<Pair> getRelations() { | ||
List<Pair> relations = new ArrayList<>(); | ||
|
||
for (Trace trace : this.eventLog) { | ||
for (int i = 0; i < trace.size() - 1; i++) { | ||
String first = trace.get(i); | ||
String second = trace.get(i + 1); | ||
relations.add(new Pair<>(first, second)); | ||
} | ||
} | ||
return relations; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jbpt.pm.log; | ||
|
||
public enum EventDataEnum { | ||
TRACE, | ||
DF_RELATION, | ||
ACTIVITY | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.jbpt.pm.log; | ||
|
||
import java.util.*; | ||
|
||
public abstract class EventDataOps<Object> { | ||
|
||
final EventLog eventLog; | ||
|
||
public EventDataOps(EventLog eventLog) { | ||
this.eventLog = eventLog; | ||
} | ||
|
||
public Set<Object> getDistinctEventData() { | ||
List<Object> eventDataList = getEventData(); | ||
return new HashSet<>(eventDataList); | ||
} | ||
|
||
public int getDistinctEventDataCount() { | ||
return getDistinctEventData().size(); | ||
} | ||
|
||
public int getEventDataCount() { | ||
return getEventData().size(); | ||
} | ||
|
||
abstract List<Object> getEventData(); | ||
|
||
public List<Object> getSingletons() { | ||
Map<Integer, List<Object>> groupedEventData = groupEventData(); | ||
return groupedEventData.getOrDefault(1, new ArrayList<>()); | ||
} | ||
|
||
public List<Object> getDoubletons() { | ||
Map<Integer, List<Object>> groupedEventData = groupEventData(); | ||
return groupedEventData.getOrDefault(2, new ArrayList<>()); | ||
} | ||
|
||
public int getSingletonCount() { | ||
return getSingletons().size(); | ||
} | ||
|
||
public int getDoubletonCount() { | ||
return getDoubletons().size(); | ||
} | ||
|
||
private HashMap<Integer, List<Object>> groupEventData() { | ||
List<Object> eventDataList = getEventData(); | ||
HashMap<Object, Integer> eventDataCount = new HashMap<>(); | ||
|
||
// Create a HashMap to count the occurrences of each distinct event data | ||
for (Object eventData : eventDataList) { | ||
eventDataCount.put(eventData, eventDataCount.getOrDefault(eventData, 0) + 1); | ||
} | ||
|
||
// Create a HashMap to group strings by the count of occurrences | ||
HashMap<Integer, List<Object>> groupedEventData = new HashMap<>(); | ||
|
||
for (Object distinctEventData : eventDataCount.keySet()) { | ||
int count = eventDataCount.get(distinctEventData); | ||
groupedEventData.putIfAbsent(count, new ArrayList<>()); | ||
groupedEventData.get(count).add(distinctEventData); | ||
} | ||
|
||
return groupedEventData; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...a/org/jbpt/pm/gen/bootstrap/EventLog.java → ...c/main/java/org/jbpt/pm/log/EventLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
package org.jbpt.pm.log; | ||
|
||
import org.jbpt.pm.utils.Utils; | ||
|
||
public class EventLogCLI { | ||
|
||
private final EventLog eventLog; | ||
|
||
public EventLogCLI(EventLog eventLog) { | ||
this.eventLog = eventLog; | ||
} | ||
|
||
public void printEventLogStats(boolean bCom, boolean bCov, boolean bLRA, boolean bAct, boolean bDFR, boolean bTra, boolean bSilent) { | ||
EventLogOps eventLogOps = new EventLogOps(eventLog); | ||
if (bAct) { | ||
System.out.println("--------------------------- Activity-based Analysis ----------------------------"); | ||
ActivityOps activityOps = new ActivityOps(eventLog); | ||
System.out.println("Activities: " + activityOps.getDistinctEventData()); | ||
System.out.println("Number of distinct activities: " + activityOps.getDistinctEventDataCount()); | ||
System.out.println("Number of total activities: " + activityOps.getEventDataCount()); | ||
if (bCom) { | ||
double aCompleteness = eventLogOps.getCompleteness(EventDataEnum.ACTIVITY); | ||
System.out.println("Completeness: " + aCompleteness); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bLRA) { | ||
if (!bDFR && !bTra) { | ||
System.out.println(aCompleteness); | ||
} else { | ||
System.out.println("Completeness: " + aCompleteness); | ||
} | ||
} else { | ||
System.out.println("Activity completeness: " + aCompleteness); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bCov) { | ||
double aCoverage = eventLogOps.getCoverage(EventDataEnum.ACTIVITY); | ||
System.out.println("Coverage: " + aCoverage); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCom && !bLRA) { | ||
if (!bDFR && !bTra) { | ||
System.out.println(aCoverage); | ||
} else { | ||
System.out.println("Coverage: " + aCoverage); | ||
} | ||
} else { | ||
System.out.println("Activity coverage: " + aCoverage); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bLRA) { | ||
double ALRA = eventLogOps.getLRA(EventDataEnum.ACTIVITY); | ||
System.out.println("Log Representativeness Approximation: " + ALRA); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bCom) { | ||
if (!bDFR && !bTra) { | ||
System.out.println(ALRA); | ||
} else { | ||
System.out.println("LRA: " + ALRA); | ||
} | ||
} else { | ||
System.out.println("ALRA: " + ALRA); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
|
||
if (bDFR) { | ||
System.out.println("------------------- Directly-follows-relation-based Analysis -------------------"); | ||
DFRelationOps dfRelationOps = new DFRelationOps(eventLog); | ||
// System.out.println("Distinct DF-relations: " + dfRelationOps.getDistinctEventData()); | ||
System.out.println("Number of distinct DF-relations: " + dfRelationOps.getDistinctEventDataCount()); | ||
System.out.println("Number of total DF-relations: " + dfRelationOps.getEventDataCount()); | ||
if (bCom) { | ||
double dfCompleteness = eventLogOps.getCompleteness(EventDataEnum.DF_RELATION); | ||
System.out.println("Completeness: " + dfCompleteness); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bLRA) { | ||
if (!bAct && !bTra) { | ||
System.out.println(dfCompleteness); | ||
} else { | ||
System.out.println("Completeness: " + dfCompleteness); | ||
} | ||
} else { | ||
System.out.println("DF-relation completeness: " + dfCompleteness); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bCov) { | ||
double dfCoverage = eventLogOps.getCoverage(EventDataEnum.DF_RELATION); | ||
System.out.println("Coverage: " + dfCoverage); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCom && !bLRA) { | ||
if (!bAct && !bTra) { | ||
System.out.println(dfCoverage); | ||
} else { | ||
System.out.println("Coverage: " + dfCoverage); | ||
} | ||
} else { | ||
System.out.println("DF-relation coverage: " + dfCoverage); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bLRA) { | ||
double DLRA = eventLogOps.getLRA(EventDataEnum.DF_RELATION); | ||
System.out.println("Log Representativeness Approximation: " + DLRA); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bCom) { | ||
if (!bAct && !bTra) { | ||
System.out.println(DLRA); | ||
} else { | ||
System.out.println("LRA: " + DLRA); | ||
} | ||
} else { | ||
System.out.println("DFR-LRA: " + DLRA); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
System.out.println(); | ||
} | ||
|
||
if (bTra) { | ||
System.out.println("----------------------------- Trace-based Analysis -----------------------------"); | ||
TraceOps traceOps = new TraceOps(eventLog); | ||
// System.out.println("Distinct traces: " + traceOps.getDistinctEventData()); | ||
System.out.println("Number of distinct traces: " + traceOps.getDistinctEventDataCount()); | ||
System.out.println("Number of total traces: " + traceOps.getEventDataCount()); | ||
if (bCom) { | ||
double tCompleteness = eventLogOps.getCompleteness(EventDataEnum.TRACE); | ||
System.out.println("Completeness: " + tCompleteness); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bLRA) { | ||
if (!bDFR && !bAct) { | ||
System.out.println(tCompleteness); | ||
} else { | ||
System.out.println("Completeness: " + tCompleteness); | ||
} | ||
} else { | ||
System.out.println("Trace completeness: " + tCompleteness); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bCov) { | ||
double tCoverage = eventLogOps.getCoverage(EventDataEnum.TRACE); | ||
System.out.println("Coverage: " + tCoverage); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCom && !bLRA) { | ||
if (!bDFR && !bAct) { | ||
System.out.println(tCoverage); | ||
} else { | ||
System.out.println("Coverage: " + tCoverage); | ||
} | ||
} else { | ||
System.out.println("Trace coverage: " + tCoverage); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
if (bLRA) { | ||
double TLRA = eventLogOps.getLRA(EventDataEnum.TRACE); | ||
System.out.println("Log Representativeness Approximation: " + TLRA); | ||
if (bSilent) { | ||
Utils.forcePrinting(); | ||
if (!bCov && !bCom) { | ||
if (!bDFR && !bAct) { | ||
System.out.println(TLRA); | ||
} else { | ||
System.out.println("LRA: " + TLRA); | ||
} | ||
} else { | ||
System.out.println("TLRA: " + TLRA); | ||
} | ||
Utils.restorePrinting(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.