Skip to content

Commit 92a2400

Browse files
committed
Fix experiment running environment including upgrading gradle
1 parent 46e8132 commit 92a2400

File tree

9 files changed

+97
-37
lines changed

9 files changed

+97
-37
lines changed

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ apply plugin: 'eclipse'
1515
repositories {
1616
mavenLocal()
1717
ivy {
18-
layout 'pattern' , {
18+
name 'ivyPromReleases'
19+
patternLayout{
1920
artifact '[organisation]/Releases/Packages/[module]/[revision]/[artifact]-[revision].[ext]'
2021
ivy '[organisation]/Releases/Packages/[module]/[revision]/ivy.xml'
2122
}
@@ -25,7 +26,8 @@ repositories {
2526
}
2627
}
2728
ivy {
28-
layout 'pattern' , {
29+
name 'ivyPromLibraries'
30+
patternLayout{
2931
artifact '[module]/[revision]/[artifact]-[revision].[ext]'
3032
ivy '[module]/[revision]/ivy.xml'
3133
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

scripts/tpminer.bat

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
echo off
2+
echo on
33

44
set lg1=%1
55
set md=%2
@@ -12,8 +12,14 @@ for %%a in ("%~dp0.") do @set TPHOME=%%~dpa
1212

1313
echo "Preparing event log ..."
1414

15-
REM echo "TPHOME" %TPHOME%
16-
REM echo "OUTD" %OUTD%
15+
echo "TPHOME" %TPHOME%
16+
echo "OUTD" %OUTD%
17+
18+
set VDIR=%TPHOME%tpvenv\scripts
19+
set PYTHON_HOME=%VDIR%
20+
21+
echo %VDIR%\activate.bat
22+
REM %VDIR%\activate.bat
1723

1824
%PYTHON_HOME%\python %TPHOME%scripts\xesdcdt.py --outfile %OUTD%\%lg%.dcdt %lg1%
1925

src/main/java/qut/pm/spm/PetrinetSource.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package qut.pm.spm;
22

3-
import org.processmining.acceptingpetrinet.models.AcceptingPetriNet;
43
import org.processmining.models.graphbased.directed.petrinet.Petrinet;
54

65
public class PetrinetSource {
76

8-
private AcceptingPetriNet net;
7+
private AcceptingStochasticNet net;
98
private String sourceId; // eg a filename
109

11-
public PetrinetSource(AcceptingPetriNet source, String sourceId) {
10+
public PetrinetSource(AcceptingStochasticNet source, String sourceId) {
1211
super();
1312
this.net = source;
1413
this.sourceId = sourceId;
@@ -22,7 +21,7 @@ public String getSourceId() {
2221
return sourceId;
2322
}
2423

25-
public AcceptingPetriNet getAcceptingPetriNet() {
24+
public AcceptingStochasticNet getAcceptingPetriNet() {
2625
return net;
2726
}
2827

src/main/java/qut/pm/spm/RunStats.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class RunStats {
4848
protected String outputModelFileName;
4949

5050
@Attribute
51-
protected String miner;
51+
protected String artifactCreator;
5252

5353
@Attribute
5454
protected String machineName;
@@ -71,24 +71,24 @@ public class RunStats {
7171
@Element
7272
private RunState runState = RunState.INITIALIZING;
7373

74-
public RunStats(String inputLogFileName, String outputModelFileName, String miner)
74+
public RunStats(String inputLogFileName, String outputModelFileName, String artifactCreator)
7575
{
7676
this.inputLogFileName = inputLogFileName;
7777
this.outputModelFileName = outputModelFileName;
78-
this.miner = miner;
78+
this.artifactCreator = artifactCreator;
7979
this.runDate = ClockUtil.currentTime();
8080
try {
8181
this.machineName = InetAddress.getLocalHost().getHostName();
8282
}catch (Exception e){
83-
this.machineName = "Unkown (" + e.getMessage() + ")";
83+
this.machineName = "Unknown (" + e.getMessage() + ")";
8484
}
8585
runnerVersion = BUILD_VERSION;
8686
}
8787

8888
protected RunStats(RunStats other) {
8989
this.inputLogFileName = other.inputLogFileName;
9090
this.outputModelFileName = other.outputModelFileName;
91-
this.miner = other.miner;
91+
this.artifactCreator = other.artifactCreator;
9292
this.runDate = other.runDate;
9393
this.runState = other.runState;
9494
this.machineName = other.machineName;
@@ -144,7 +144,7 @@ public Map<Measure,Number> getAllMeasures(){
144144
}
145145

146146
public String getArtifactCreator() {
147-
return miner;
147+
return artifactCreator;
148148
}
149149

150150
public String formatStats() {

src/main/java/qut/pm/spm/conformance/EarthMoversTunedCalculator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void calculate(PluginContext context, AcceptingStochasticNet net, XLog lo
3535
LOGGER.info("Computing earth-movers' distance (SL) with mass coverage: " + MASS_COVERAGE);
3636
EMSCParametersLogModelDefault parameters = new EMSCParametersLogModelDefault();
3737
parameters.setComputeStochasticTraceAlignments(false);
38-
parameters.setDebug(false);
38+
parameters.setDebug(true);
3939
parameters.setLogClassifier(classifier);
4040
LanguageGenerationStrategyFromModelAbstract terminationStrategy = new LanguageGenerationStrategyFromModelDefault();
4141
terminationStrategy.setMaxMassCovered(MASS_COVERAGE);

src/main/java/qut/pm/spm/miner/ToothpasteMinerHP.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void run(PluginContext uipc, XLog log, XEventClassifier classifier, File
4848
throws Exception
4949
{
5050
File logFileObj = new File(logFile);
51-
LOGGER.info("Invoking Toothpaste miner prototype out of process on {}", logFile);
51+
LOGGER.info("Invoking Toothpaste miner out of process on {}", logFile);
5252
callToothpasteMinerHP( logFileObj, outputModelFile );
5353
Serializer serializer = new Persister();
5454
PNMLRoot pnml = serializer.read(PNMLRoot.class, outputModelFile);

src/main/java/qut/pm/spm/reports/SPNDiscoverReporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public int compare(ReportStats o1, ReportStats other) {
4545
result = o1.artifactCreatorId.compareTo(other.artifactCreatorId);
4646
if (result != 0)
4747
return result;
48-
result = o1.miner.compareTo(other.miner);
48+
result = o1.artifactCreator.compareTo(other.artifactCreator);
4949
return result;
5050
}
5151

@@ -93,7 +93,7 @@ public int compareTo(ReportStats other) {
9393
result = artifactCreatorId.compareTo(other.artifactCreatorId);
9494
if (result != 0)
9595
return result;
96-
result = this.miner.compareTo(other.miner);
96+
result = this.artifactCreator.compareTo(other.artifactCreator);
9797
return result;
9898
}
9999

src/main/java/qut/pm/toothpaste/ModelRunner.java

Lines changed: 70 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.IOException;
88
import java.util.ArrayList;
99
import java.util.Arrays;
10+
import java.util.Collections;
1011
import java.util.List;
1112
import java.util.Properties;
1213

@@ -16,8 +17,6 @@
1617
import org.deckfour.xes.classification.XEventNameClassifier;
1718
import org.deckfour.xes.info.XLogInfoFactory;
1819
import org.deckfour.xes.model.XLog;
19-
import org.processmining.acceptingpetrinet.models.AcceptingPetriNet;
20-
import org.processmining.acceptingpetrinet.models.impl.AcceptingPetriNetImpl;
2120
import org.processmining.contexts.uitopia.UIPluginContext;
2221
import org.processmining.framework.plugin.PluginContext;
2322
import org.processmining.models.connections.GraphLayoutConnection;
@@ -37,6 +36,7 @@
3736
import qut.pm.prom.helpers.HeadlessUIPluginContext;
3837
import qut.pm.prom.helpers.PetrinetExportUtils;
3938
import qut.pm.spm.AcceptingStochasticNet;
39+
import qut.pm.spm.AcceptingStochasticNetImpl;
4040
import qut.pm.spm.Measure;
4141
import qut.pm.spm.PetrinetSource;
4242
import qut.pm.spm.RunState;
@@ -89,6 +89,7 @@ private static enum Classifier{
8989
private boolean exportDOT = false;
9090
private int kfoldLogs = 1;
9191
private int kfoldLogsStart = 1;
92+
// private String modelInputFileName = "";
9293
private List<StochasticNetLogMiner> miners;
9394
private List<PetrinetSource> models;
9495
private List<SPNQualityCalculator> calculators;
@@ -140,26 +141,26 @@ private void configureModels(Properties cfg) throws Exception{
140141
for (String modelFile: modelFiles) {
141142
String fname = modelPath + File.separator + modelFile.trim();
142143
LOGGER.info("Loading model from {}",fname);
143-
AcceptingPetriNet net = loadNet(new File(fname));
144-
String shortName = modelFile.replace("omodel_", "");
145-
shortName = shortName.substring(0, shortName.indexOf("_") );
146-
LOGGER.info("Short name {}",shortName);
147-
models.add( new PetrinetSource(net,shortName) );
144+
AcceptingStochasticNet net = loadNet(new File(fname));
145+
models.add( new PetrinetSource(net,net.getId()) );
148146
}
149147
}
150148

151-
private static AcceptingPetriNet loadNet(File file) throws Exception {
152-
PluginContext context =
153-
new HeadlessDefinitelyNotUIPluginContext(new ConsoleUIPluginContext(), "modelrunner_loadnet");
149+
private AcceptingStochasticNet loadNet(File file) throws Exception {
150+
PluginContext context = new HeadlessDefinitelyNotUIPluginContext(new ConsoleUIPluginContext(),
151+
"modelrunner_loadnet");
152+
String shortName = file.getName().replace("osmodel_", "");
153+
shortName = shortName.substring(0, shortName.indexOf("_") );
154+
LOGGER.info("Short name {}",shortName);
154155
Serializer serializer = new Persister();
155156
PNMLRoot pnml = serializer.read(PNMLRoot.class, file);
156157
StochasticNetDeserializer converter = new StochasticNetDeserializer();
157158
Object[] objs = converter.convertToNet(context, pnml, file.getName(), true);
158-
AcceptingPetriNet apn = new AcceptingPetriNetImpl((StochasticNet) objs[0],
159-
(Marking)objs[1],(Marking)objs[2]);
159+
AcceptingStochasticNet apn = new AcceptingStochasticNetImpl(shortName, (StochasticNet) objs[0],
160+
(Marking) objs[1], Collections.singleton((Marking) objs[2]));
160161
return apn;
161162
}
162-
163+
163164

164165
private void configureMiners(Properties cfg) {
165166
miners = new ArrayList<>();
@@ -241,17 +242,17 @@ private void runSingleMinerRun(StochasticNetLogMiner miner, String inputLogName,
241242
throws Exception
242243
{
243244
UIPluginContext uipc =
244-
new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "spmrunner_logparser");
245+
new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "tp_runnerlogparser");
245246
final String SEP = " -- ";
246247
noteRunStart(miner, inputLogName, SEP);
247248
String inputLogPrefix = logPrefix(inputLogName);
248-
String outputModelName = nameFile(inputLogPrefix,miner.getShortID(),"omodel",PNML);
249+
String outputModelName = nameFile(inputLogPrefix,miner.getShortID(),"osmodel",PNML);
249250
RunStats runStats = new RunStats(inputLogName,outputModelName, miner.getReadableID());
250251
TaskStats stats = new TaskStats("spmlogparser");
251252
stats.markRunning();
252253
try {
253254
XLog log = loadLog(uipc, inputLogName, stats);
254-
uipc = new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "spmrunner_mining");
255+
uipc = new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "tp_runnermining");
255256
stats = closeTaskAndMakeNew(runStats, stats, "miner");
256257
LOGGER.debug(stats.formatStats());
257258
File modelFile = new File(outputModelName);
@@ -265,7 +266,7 @@ private void runSingleMinerRun(StochasticNetLogMiner miner, String inputLogName,
265266
stats = makeNewTask("visualize");
266267
exportVisualization(miner,inputLogPrefix);
267268
stats.markEnd();
268-
uipc = new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "spmrunner_postrun");
269+
uipc = new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "tp_runnerpostrun");
269270
if (miner.isStochasticNetProducer()) {
270271
TaskStats compStats = new TaskStats("complog");
271272
// note these log count stats in compStats currently unused
@@ -407,14 +408,66 @@ private void noteRunEnd(StochasticNetLogMiner artifactRun, String inputLogPrefix
407408
}
408409
}
409410

411+
private TaskStats makeNewTask(RunStats runStats, String newTaskName) {
412+
TaskStats newTaskStats = new TaskStats(newTaskName);
413+
newTaskStats.markRunning();
414+
runStats.addTask(newTaskStats);
415+
return newTaskStats;
416+
}
417+
418+
419+
private void calculatePostStats(PluginContext context, String inputLogPrefix,
420+
PetrinetSource model, XLog log, RunStats runStats)
421+
throws Exception
422+
{
423+
TaskStats stats = null;
424+
for (SPNQualityCalculator calc: calculators) {
425+
stats = makeNewTask("calculate " + calc.getReadableId());
426+
calc.calculate(context, model.getAcceptingPetriNet(), log,
427+
classifierFor(log), stats);
428+
closeTask(runStats,stats);
429+
// Conservatively export stats after every run
430+
LOGGER.info(runStats.formatStats());
431+
exportRun(model.getSourceId(), inputLogPrefix, runStats);
432+
}
433+
}
434+
435+
436+
public void runPredefinedModelVsLog(PetrinetSource model, String inputLogName ) throws Exception{
437+
UIPluginContext uipc =
438+
new HeadlessUIPluginContext(new ConsoleUIPluginContext(), "tp_runnermvl");
439+
RunStats runStats = new RunStats(inputLogName,model.getNet().getLabel(), model.getSourceId());
440+
String df = logPrefix(inputLogName);
441+
// RunStats runStats = initPredefRunStats(model, "predef");
442+
TaskStats stats = makeNewTask(runStats, "tpmlogparser");
443+
try {
444+
XLog log = loadLog(uipc, inputLogName, stats);
445+
calculatePostStats(uipc, df, model, log, runStats);
446+
} catch (Exception e) {
447+
exportRun(model.getSourceId(), df, runStats);
448+
throw new RuntimeException(e);
449+
}
450+
}
451+
410452

453+
454+
public void runPredefinedModelCollectionVsLog() throws Exception{
455+
for (String df: dataFiles) {
456+
for (PetrinetSource model : models) {
457+
runPredefinedModelVsLog(model,df);
458+
}
459+
}
460+
}
411461

412462
public void runAll() throws Exception{
413463
for (String df: dataFiles) {
414464
// Basic sanity checks happen already at config load time
415465
if (!miners.isEmpty()) {
416466
runAllMiners(df);
417467
}
468+
if (miners.isEmpty() && !models.isEmpty()) {
469+
runPredefinedModelCollectionVsLog();
470+
}
418471
}
419472
}
420473

0 commit comments

Comments
 (0)