print("Classifying...");
importlog = System.getenv("IMPORTLOG");
importmodel = System.getenv("IMPORTMODEL");
exportlog = System.getenv("EXPORTLOG");
//---------------------------------------------------
print("");
// Use the name of the plugin (in lowercase) to open a log
print(" ");
org.deckfour.xes.model.XLog log = open_xes_log_file(importlog);
print(" ");
logname = org.deckfour.xes.extension.std.XConceptExtension.instance().extractName(log);
print(" " + logname + "");
print(" " + log.size() + "");
events = 0;
for (trace : log) {
events += trace.size();
}
print(" " + events + "");
print(" " + log.getClassifiers().size() + "");
print("");
print("");
print(" ");
res = import_petri_net_from_pnml_file(importmodel);
print(" ");
model = res[0];
marking = res[1];
print(" " + model.getLabel() + "");
print(" ");
for (transition : model.getTransitions()) {
print(" " + transition.getAttributeMap().get(org.processmining.models.graphbased.AttributeMap.LABEL) + "");
}
print(" ");
for (place : model.getPlaces()) {
print(" " + place.getAttributeMap().get(org.processmining.models.graphbased.AttributeMap.LABEL) + "");
}
print(" " + marking + "");
print("");
//---------------------------------------------------
print("");
print(" ");
// get th eintiial and final marking (assume there is a single final marking).
anet = pack_petri_net(model);
net = anet.getNet();
initialMarking = anet.getInitialMarking();
finalMarking = anet.getFinalMarkings().iterator().next();
// Initialize the replayer
eventClassifier = log.getClassifiers().isEmpty() ? new org.deckfour.xes.classification.XEventNameClassifier() : log.getClassifiers().get(0);
logs = org.processmining.log.models.impl.EventLogArrayFactory.createEventLogArray();
dummyClass = new org.deckfour.xes.classification.XEventClass("DUMMY", 99999);
mapping = nl.tue.alignment.test.BasicCodeSnippet.constructMappingBasedOnLabelEquality(net, log, dummyClass, eventClassifier);
summary = org.deckfour.xes.info.XLogInfoFactory.createLogInfo(log, eventClassifier);
classes = summary.getEventClasses();
// Setting the correct costs
costModelMove = new HashMap();
costSyncMove = new HashMap();
costLogMove = new HashMap();
for (transition : net.getTransitions()) {
costSyncMove.put(transition, 0);
costModelMove.put(transition, transition.isInvisible() ? 0 : 2);
}
for (clss : summary.getEventClasses().getClasses()) {
costLogMove.put(clss, 5);
}
costLogMove.put(dummyClass, 5);
nThreads = 6;
costUpperBound = 0;
//too low! timeoutMilliseconds = 10 * 1000;
timeoutMilliseconds = 600 * 1000;
//too high! timeoutMilliseconds = Integer.MAX_VALUE;
maximumNumberOfStates = Integer.MAX_VALUE;
//parameters = new nl.tue.alignment.ReplayerParameters.AStar(true, true, true, nThreads, true,
// nl.tue.alignment.algorithms.ReplayAlgorithm.Debug.NONE,
// timeoutMilliseconds, maximumNumberOfStates, costUpperBound, false);
parameters = new nl.tue.alignment.ReplayerParameters.IncrementalAStar(true, nThreads, false,
nl.tue.alignment.algorithms.ReplayAlgorithm.Debug.NONE, timeoutMilliseconds,
maximumNumberOfStates, costUpperBound, false, 20);
replayer = new nl.tue.alignment.Replayer(parameters, net, initialMarking, finalMarking, classes, costModelMove,
costLogMove, costSyncMove, mapping, false);
preProcessTimeNanoseconds = 0L;
// Starting the replayer
service = java.util.concurrent.Executors.newFixedThreadPool(parameters.nThreads);
futures = new java.util.concurrent.Future[log.size()];
eventWithErrors = new int[0];
for (i = 0; i < log.size(); i++) {
task = new nl.tue.alignment.TraceReplayTask(replayer, parameters, log.get(i), i, timeoutMilliseconds,
parameters.maximumNumberOfStates, preProcessTimeNanoseconds, eventWithErrors);
futures[i] = service.submit(task);
}
service.shutdown();
print(" ");
print("");
//---------------------------------------------------
print("");
pos = 0;
neg = 0;
unr = 0;
for (i = 0; i < log.size(); i++) {
isPos = false;
try {
result = futures[i].get();
if (result.getResult() == nl.tue.alignment.TraceReplayTask.TraceReplayResult.SUCCESS) {
replayResult = result.getSuccesfulResult();
exitCode = replayResult.getInfo().get(nl.tue.alignment.Replayer.TRACEEXITCODE).intValue();
if ((exitCode & nl.tue.alignment.Utils.OPTIMALALIGNMENT) == nl.tue.alignment.Utils.OPTIMALALIGNMENT) {
isPos = true;
pos++;
} else if ((exitCode & nl.tue.alignment.Utils.COSTLIMITREACHED) == nl.tue.alignment.Utils.COSTLIMITREACHED) {
neg++;
} else if ((exitCode & nl.tue.alignment.Utils.FINALMARKINGUNREACHABLE) == nl.tue.alignment.Utils.FINALMARKINGUNREACHABLE) {
neg++;
} else {
print("Trace '" + log.get(i).getAttributes().get("concept:name") + "': exit code " + exitCode);
unr++;
}
} else {
unr++;
}
} catch (Exception e) {
throw new RuntimeException("Error while executing replayer in ExecutorService. Interrupted maybe?", e);
}
log.get(i).getAttributes().put("pdc:costs", org.deckfour.xes.factory.XFactoryRegistry.instance().currentDefault().createAttributeBoolean("pdc:isPos", isPos, null));
}
print(" " + pos + "");
print(" " + neg + "");
print(" " + unr + "");
print("");
//---------------------------------------------------
print("");
exportfile = new java.io.File(exportlog);
print(" ");
org.processmining.plugins.log.exporting.ExportLogXes.export(log, exportfile);
print(" ");
print(" " + exportfile.length() + "");
print("");
exit();