de.uni.freiburg.iig.telematik.sepia.replay.Replay Maven / Gradle / Ivy
Show all versions of SEPIA Show documentation
package de.uni.freiburg.iig.telematik.sepia.replay;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import de.invation.code.toval.thread.ExecutorListener;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractFlowRelation;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractMarking;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPetriNet;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractPlace;
import de.uni.freiburg.iig.telematik.sepia.petrinet.abstr.AbstractTransition;
import de.uni.freiburg.iig.telematik.sepia.replay.ReplayCallable.TerminationCriteria;
import de.uni.freiburg.iig.telematik.sepia.util.PNUtils;
import de.uni.freiburg.iig.telematik.sewol.log.LogEntry;
public class Replay {
public static final TerminationCriteria DEFAULT_TERMINATION_CRITERIA = TerminationCriteria.NO_ENABLED_TRANSITIONS;
// private static final String doneReplayformat = "done [fitting=%s, not fitting=%s] [%s]";
//
// @SuppressWarnings("rawtypes")
// public static ReplayResult replay(AbstractPetriNet net, List> traces, TerminationCriteria terminationCriteria, boolean printNonFitting) throws Exception{
// System.out.print("Replaying log on model \""+net.getName()+"\"... ");
// Replayer replaying = new Replayer(net, terminationCriteria);
// long start = System.currentTimeMillis();
// ReplayResult result = replaying.replayTraces(traces);
// TimeValue runtime = new TimeValue(System.currentTimeMillis() - start, TimeScale.MILLISECONDS);
// runtime.adjustScale();
// System.out.println(String.format(doneReplayformat, result.portionFitting(), result.portionNonFitting(), runtime));
// if(printNonFitting)
// CollectionUtils.print(result.getNonFittingTraces());
// return result;
// }
public static < P extends AbstractPlace,
T extends AbstractTransition,
F extends AbstractFlowRelation,
M extends AbstractMarking,
S extends Object,
E extends LogEntry>
void
initiateReplay( ReplayCallableGenerator
generator,
ExecutorListener> listener)
throws ReplayException {
ThreadedReplayer calculator = new ThreadedReplayer
(generator);
calculator.addExecutorListener(listener);
calculator.runCalculation();
}
public static < P extends AbstractPlace,
T extends AbstractTransition,
F extends AbstractFlowRelation,
M extends AbstractMarking,
S extends Object,
E extends LogEntry>
ReplayResult
replayTraces(ReplayCallableGenerator generator)
throws ReplayException {
ThreadedReplayer
calculator = new ThreadedReplayer
(generator);
calculator.runCalculation();
return calculator.getResult();
}
public static < P extends AbstractPlace,
T extends AbstractTransition,
F extends AbstractFlowRelation,
M extends AbstractMarking,
S extends Object,
E extends LogEntry>
Map
getDefaultTransitionLabelRelation(AbstractPetriNet petriNet){
Map transitionLabelRelation = new HashMap();
Set transitionLabels = PNUtils.getLabelSetFromTransitions(petriNet.getTransitions(), false);
for(String transitionLabel: transitionLabels){
transitionLabelRelation.put(transitionLabel, transitionLabel);
}
return transitionLabelRelation;
}
}