/// <param name="workflowLog">Workflow log</param> /// <param name="pNet">Petri net</param> /// <param name="traceMoveCost">Trace move cost</param> /// <param name="modelMoveCost">Model move cost</param> public AlignmentOnLog(WorkflowLog workflowLog, PetriNet pNet, int traceMoveCost = 1, int modelMoveCost = 1) { TraceMoveCost = traceMoveCost; ModelMoveCost = modelMoveCost; AlignmentsOnLog = AlignmentUtils.OptimalAlignmentsOnLog(workflowLog, pNet, traceMoveCost, modelMoveCost); ComputeFitness(); }
public void MakeSuccessorMatrixFromHardEventLogTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var expectedSuccessor = MakeExpectedHardSuccessorMatrix(); var expectedL2L = MakeExpectedHardL2LMatrix(); var expectedLong = MakeExpectedLongDistance(); //Act SuccessorMatrix successorMatrix = new SuccessorMatrix(wlog); Assert.AreEqual(expectedSuccessor.GetLength(0), successorMatrix.Activities.Count); CollectionAssert.AreEqual(expectedSuccessor, successorMatrix.DirectMatrix); CollectionAssert.AreEqual(expectedL2L, successorMatrix.L2LMatrix); CollectionAssert.AreEqual(new int[] { 129, 130, 130, 57, 100, 57, 100, 43, 43 }, successorMatrix.ActivityOccurrences); CollectionAssert.AreEqual(expectedLong, successorMatrix.LongDistanceMatrix); Assert.AreEqual(1, successorMatrix.StartActivities.Count); Assert.AreEqual(1, successorMatrix.EndActivities.Count); Assert.AreEqual("a", successorMatrix.StartActivities.First()); Assert.AreEqual("i", successorMatrix.EndActivities.First()); }
public void MakeHardDependencyMatrixFromSuccessorMatrix() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); SuccessorMatrix successorMatrix = new SuccessorMatrix(wlog); //Act DependencyMatrix dependencyMatrix = new DependencyMatrix(successorMatrix); //Assert Assert.AreEqual(successorMatrix.Activities.Count, dependencyMatrix.L1LDependencyMatrix.Length); //Each dependency is in range <-1, 1> foreach (var dependency in dependencyMatrix.DirectDependencyMatrix) { Assert.IsTrue(dependency >= -1 && dependency <= 1); } Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[0] > 0.9 && dependencyMatrix.L1LDependencyMatrix[0] < 1); //Check L2L dependency on BCB and CBC Assert.IsTrue(dependencyMatrix.L2LDependencyMatrix[1, 2] > 0.9 && dependencyMatrix.L2LDependencyMatrix[1, 2] < 1); Assert.IsTrue(dependencyMatrix.L2LDependencyMatrix[2, 1] > 0.9 && dependencyMatrix.L2LDependencyMatrix[2, 1] < 1); }
internal static void AddWorkflowLog(int PortalID, int ModuleID, int UserID, Pages Page, string Action, string Comment) { if (!string.IsNullOrEmpty(Comment)) { WorkflowLog wlog = new WorkflowLog { PortalID = PortalID, ModuleID = ModuleID, ReviewedBy = UserID, ReviewedOn = DateTime.UtcNow, StateID = Page.StateID.Value, Comment = Comment, TabID = Page.TabID, Version = Page.Version }; if (Action.ToLower() == "approve" || Action.ToLower() == "publish") { wlog.Approved = true; } else if (Action.ToLower() == "reject") { wlog.Approved = false; } wlog.Insert(); CacheFactory.Clear(CacheFactory.Keys.Workflow); } }
public void MakeDependencyMatrixFromSuccessorMatrix() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); SuccessorMatrix successorMatrix = new SuccessorMatrix(wlog); // Act DependencyMatrix dependencyMatrix = new DependencyMatrix(successorMatrix); // Assert Assert.AreEqual(successorMatrix.Activities.Count, dependencyMatrix.L1LDependencyMatrix.Length); for (int i = 0; i < 4; i++) { Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[i] == 0); } //1 self loop with dependency 0.8 Assert.IsTrue(dependencyMatrix.L1LDependencyMatrix[4] == 0.8); foreach (var dependency in dependencyMatrix.L2LDependencyMatrix) { Assert.IsTrue(dependency == 0); } //Each dependency is in range <-1, 1> foreach (var dependency in dependencyMatrix.DirectDependencyMatrix) { Assert.IsTrue(dependency >= -1 && dependency <= 1); } }
/// <summary> /// Computes token-based replay fitness of given event log to a given Petri Net. /// </summary> /// <param name="log">Event log to be replayed.</param> /// <param name="net">Petri net used for replaying given traces.</param> /// <returns>Fitness metric of given event log to given Petri Net.</returns> public static double ComputeFitness(ImportedEventLog log, IPetriNet net) { PetriNetTokenDiagnosticsOverlay netDiagnostics = new PetriNetTokenDiagnosticsOverlay(net); WorkflowLog eventLog = new WorkflowLog(log); foreach (WorkflowTrace t in eventLog.WorkflowTraces) { netDiagnostics.ReplayTrace(t); } double sumProduced = 0; double sumConsumed = 0; double sumMissing = 0; double sumRemaining = 0; foreach (PlaceTokenDiagnosticsOverlay diagnostics in netDiagnostics.Diagnostics.Values) { sumProduced += diagnostics.Produced; sumConsumed += diagnostics.Consumed; sumMissing += diagnostics.Missing; sumRemaining += diagnostics.Remaining; } if (sumConsumed == 0 && sumProduced == sumRemaining && sumProduced == sumMissing) // this should only be true if compared log is 100% different from given Petri Net. { return(0.0); } return(0.5 * (1 - sumMissing / sumConsumed) + 0.5 * (1 - sumRemaining / sumProduced)); }
public void MakeEasyPetriNetTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(easyCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); RelationMatrix matrix = new RelationMatrix(wlog); IPetriNet exampleNet = MakeEasyPetriNet(); // Act IPetriNet madeNet = Alpha.MakePetriNet(matrix); // Assert Assert.IsNotNull(exampleNet); Assert.AreEqual(exampleNet.EndPlace.Id, madeNet.EndPlace.Id); Assert.AreEqual(exampleNet.StartPlace.Id, madeNet.StartPlace.Id); Assert.AreEqual(exampleNet.Places.Count, madeNet.Places.Count); Assert.AreEqual(exampleNet.Transitions.Count, madeNet.Transitions.Count); foreach (IPlace p in exampleNet.Places) { Assert.IsTrue(madeNet.Places.Exists(a => a.Id == p.Id)); } foreach (ITransition t in exampleNet.Transitions) { Assert.IsTrue(madeNet.Transitions.Exists(a => a.Id == t.Id && a.Activity == t.Activity && a.InputPlaces.Count == t.InputPlaces.Count && a.OutputPlaces.Count == t.OutputPlaces.Count)); } }
public void AddWorkflowLog(WorkflowLog workflowLog) { using (var context = DataContext.Instance()) { var rep = context.GetRepository <WorkflowLog>(); rep.Insert(workflowLog); } }
public void SimpleDependencyGraphWithL1LLoop() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var successorMatrix = new SuccessorMatrix(wlog); // Act HeuristicMinerSettings settings = new HeuristicMinerSettings { L1LThreshold = 0.7 }; DependencyGraph dependencyGraph = new DependencyGraph(successorMatrix, settings); // Assert Assert.AreEqual(successorMatrix.Activities.Count, dependencyGraph.Activities.Count); var start = successorMatrix.ActivityIndices[successorMatrix.StartActivities.First()]; var end = successorMatrix.ActivityIndices[successorMatrix.EndActivities.First()]; Assert.AreEqual(start, dependencyGraph.StartActivity); Assert.AreEqual(end, dependencyGraph.EndActivity); Assert.IsTrue(dependencyGraph.LongDependencies.Count == 0); //NO INPUT FOR START ACT Assert.IsTrue(dependencyGraph.InputActivities[start].Count == 0); //NO OUTPUT FOR END ACT Assert.IsTrue(dependencyGraph.OutputActivities[end].Count == 0); //ARCS CORRECT IN Assert.IsTrue(dependencyGraph.InputActivities[1].SetEquals(new HashSet <int> { 2, 3, 4 })); Assert.IsTrue(dependencyGraph.InputActivities[2].SetEquals(new HashSet <int> { 0 })); Assert.IsTrue(dependencyGraph.InputActivities[3].SetEquals(new HashSet <int> { 0 })); //SELF LOOP Assert.IsTrue(dependencyGraph.InputActivities[4].SetEquals(new HashSet <int> { 0, 4 })); //ARCS CORRECT OUT Assert.IsTrue(dependencyGraph.OutputActivities[0].SetEquals(new HashSet <int> { 2, 3, 4 })); Assert.IsTrue(dependencyGraph.OutputActivities[2].SetEquals(new HashSet <int> { 1 })); Assert.IsTrue(dependencyGraph.OutputActivities[3].SetEquals(new HashSet <int> { 1 })); //SELF LOOP Assert.IsTrue(dependencyGraph.OutputActivities[4].SetEquals(new HashSet <int> { 1, 4 })); }
private RelationMatrix MakeVeryHardRelationMatrix() { ImportedEventLog elog = CSVImport.MakeDataFrame(veryHardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); return(new RelationMatrix(wlog)); }
/// <param name="workflowLog">Workflow log</param> /// <param name="heuristicsMinerSettings">Heuristic miner settings</param> public CNet(WorkflowLog workflowLog, HeuristicMinerSettings heuristicsMinerSettings) { var successorMatrix = new SuccessorMatrix(workflowLog); var dependencyGraph = new DependencyGraph(successorMatrix, heuristicsMinerSettings); IndexToActivity = dependencyGraph.Activities; ActivityIndices = dependencyGraph.ActivityIndices; FillActivities(successorMatrix); PrepareBindings(dependencyGraph); FindBindings(dependencyGraph, workflowLog); }
internal static List <WorkflowLog> GetPagesWorkflowLogs(int TabID, int Version) { string CacheKey = CacheFactory.GetCacheKey(CacheFactory.Keys.Workflow + "GetPagesWorkflowLogs", TabID, Version); List <WorkflowLog> WorkflowLogs = CacheFactory.Get(CacheKey) as List <WorkflowLog>; if (WorkflowLogs == null) { WorkflowLogs = WorkflowLog.Query("Where Tabid=@0 and Version=@1", TabID, Version).ToList(); CacheFactory.Set(CacheKey, WorkflowLogs); } return(WorkflowLogs); }
public void MakeCNetHardLongDistanceSettings() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); // Act HeuristicMinerSettings settings = new HeuristicMinerSettings { UseLongDistance = true }; CNet causalNet = HeuristicMiner.MineCNet(wlog, settings); // Assert Assert.AreEqual(2, causalNet.LongDependencies.Count); Assert.AreEqual(0, causalNet.StartActivity.Id); Assert.AreEqual(6, causalNet.EndActivity.Id); //ACTIVITY OCCURRENCE Assert.AreEqual(9, causalNet.Activities.Count); Assert.AreEqual(129, causalNet.Activities[0].Frequency); Assert.AreEqual(130, causalNet.Activities[1].Frequency); Assert.AreEqual(130, causalNet.Activities[2].Frequency); Assert.AreEqual(57, causalNet.Activities[3].Frequency); Assert.AreEqual(100, causalNet.Activities[4].Frequency); Assert.AreEqual(57, causalNet.Activities[5].Frequency); Assert.AreEqual(100, causalNet.Activities[6].Frequency); Assert.AreEqual(43, causalNet.Activities[7].Frequency); Assert.AreEqual(43, causalNet.Activities[8].Frequency); //BINDINGS Assert.AreEqual(1, causalNet.InputBindings[0].Count); Assert.AreEqual(2, causalNet.InputBindings[1].Count); Assert.AreEqual(1, causalNet.InputBindings[2].Count); Assert.AreEqual(1, causalNet.InputBindings[3].Count); Assert.AreEqual(2, causalNet.InputBindings[4].Count); Assert.AreEqual(1, causalNet.InputBindings[5].Count); Assert.AreEqual(2, causalNet.InputBindings[6].Count); Assert.AreEqual(1, causalNet.InputBindings[7].Count); Assert.AreEqual(1, causalNet.InputBindings[8].Count); Assert.AreEqual(2, causalNet.OutputBindings[0].Count); Assert.AreEqual(1, causalNet.OutputBindings[1].Count); Assert.AreEqual(3, causalNet.OutputBindings[2].Count); Assert.AreEqual(1, causalNet.OutputBindings[3].Count); Assert.AreEqual(2, causalNet.OutputBindings[4].Count); Assert.AreEqual(1, causalNet.OutputBindings[5].Count); Assert.AreEqual(0, causalNet.OutputBindings[6].Count); Assert.AreEqual(1, causalNet.OutputBindings[7].Count); Assert.AreEqual(1, causalNet.OutputBindings[8].Count); }
internal static void DeleteWorkflow(Workflow wflow) { foreach (WorkflowState state in GetAllStatesbyWorkflowID(wflow.ID)) { WorkflowLog.Delete("Where StateID=@0", state.StateID); WorkflowStatePermission.Delete("Where StateID=@0", state.StateID); state.Delete(); } WorkflowPermission.Delete("Where Workflowid=@0", wflow.ID); wflow.Delete(); CacheFactory.Clear(CacheFactory.Keys.Workflow); }
public async Task <ResultModel> StartWorkflowLogger(WorkflowLog model) { if (model.Actions == null) { model.Actions = new List <WorkflowAction>(); model.Actions.Add(new WorkflowAction { Action = 1, CreationDate = DateTime.Now, }); } await new MongoDbContext(_workflowConfig.DbConfig.ServerAdderss, _workflowConfig.DbConfig.DatabaseName) .AddOne <WorkflowLog>(model); return(new ResultModel()); }
private void AddWorkflowLog(int contentItemId, int workflowId, WorkflowLogType type, string action, string comment, int userId) { var workflowLog = new WorkflowLog { ContentItemID = contentItemId, WorkflowID = workflowId, Type = (int)type, Action = action, Comment = comment, User = userId, Date = DateTime.UtcNow }; _workflowLogRepository.AddWorkflowLog(workflowLog); }
public void CompareLogWithAccordingPetriNetTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); RelationMatrix matrix = new RelationMatrix(wlog); IPetriNet madeNet = Alpha.MakePetriNet(matrix); // Act double fitness = Computations.ComputeFitness(elog, madeNet); // Assert Assert.AreEqual(1.0, fitness); }
public void ComputeWorstAlignmentOnHardModel() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); PetriNet petriNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog)); // Act var cost = AlignmentUtils.ComputeWorstCostOfModel(petriNet, 1); // Assert Assert.AreEqual(7, cost); }
public void MakeCNetEasyCustomSettings() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var successorMatrix = new SuccessorMatrix(wlog); // Act HeuristicMinerSettings settings = new HeuristicMinerSettings { DependencyThreshold = 0.7, RelativeToBestThreshold = 0.15, L1LThreshold = 0.7 }; CNet causalNet = HeuristicMiner.MineCNet(wlog, settings); // Assert Assert.AreEqual(0, causalNet.StartActivity.Id); Assert.AreEqual(1, causalNet.EndActivity.Id); //ACTIVITY OCCURRENCE Assert.AreEqual(5, causalNet.Activities.Count); Assert.AreEqual(40, causalNet.Activities[0].Frequency); Assert.AreEqual(40, causalNet.Activities[1].Frequency); Assert.AreEqual(21, causalNet.Activities[2].Frequency); Assert.AreEqual(21, causalNet.Activities[3].Frequency); Assert.AreEqual(17, causalNet.Activities[4].Frequency); //Number of bindings Assert.AreEqual(0, causalNet.InputBindings[0].Count); //NEW ARC A->C Assert.AreEqual(5, causalNet.InputBindings[1].Count); Assert.AreEqual(1, causalNet.InputBindings[2].Count); Assert.AreEqual(1, causalNet.InputBindings[3].Count); //NEW ARC D->D Assert.AreEqual(2, causalNet.InputBindings[4].Count); //NEW ARC A->C Assert.AreEqual(5, causalNet.OutputBindings[0].Count); Assert.AreEqual(0, causalNet.OutputBindings[1].Count); Assert.AreEqual(1, causalNet.OutputBindings[2].Count); Assert.AreEqual(1, causalNet.OutputBindings[3].Count); //NEW ARC D->D Assert.AreEqual(2, causalNet.OutputBindings[4].Count); //A&B BIND FREQUENCY Assert.AreEqual(20, causalNet.OutputBindings[0].First(u => u.Activities.Count == 2).Frequency); Assert.AreEqual(20, causalNet.InputBindings[1].First(b => b.Activities.Count == 2).Frequency); }
public void AlignmentOnLogEasy() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog)); // Act AlignmentOnLog alignment = new AlignmentOnLog(wlog, pNet); // Assert Assert.IsTrue(alignment.Fitness >= 0.96); Assert.AreEqual(wlog.GetTracesWithOccurrence().Count, alignment.AlignmentsOnLog.Count); }
public void AlignmentOnTraceHard() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); PetriNet pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog)); // Act (EACH TRACE FITS TO THE MODEL) foreach (var trace in wlog.WorkflowTraces) { var alignment = new AlignmentOnTrace(trace, pNet); //Assert Assert.AreEqual(1, alignment.Fitness); Assert.AreEqual(0, alignment.OptimalCost); } }
/// <summary> /// Find bindings based on the dependency graph and the workflow log /// </summary> /// <param name="dependencyGraph">Dependency graph</param> /// <param name="workflowLog">Workflow log</param> private void FindBindings(DependencyGraph dependencyGraph, WorkflowLog workflowLog) { foreach (var(trace, occurrence) in workflowLog.GetTracesWithOccurrence()) { for (var i = 0; i < trace.Activities.Count; i++) { int currentActivity = dependencyGraph.ActivityIndices[trace.Activities[i]]; var outCandidate = OutBindCandidate(dependencyGraph, currentActivity, i, trace, occurrence); var inCandidate = InBindCandidate(dependencyGraph, currentActivity, i, trace); if (outCandidate.Count > 0) { var binding = OutputBindings[currentActivity].FirstOrDefault(b => b.Activities.SetEquals(outCandidate)); if (binding is null) { OutputBindings[currentActivity].Add(new Binding(outCandidate, occurrence)); } else { binding.AddFrequency(occurrence); } } if (inCandidate.Count <= 0) { continue; } { var binding = InputBindings[currentActivity].FirstOrDefault(b => b.Activities.SetEquals(inCandidate)); if (binding is null) { InputBindings[currentActivity].Add(new Binding(inCandidate, occurrence)); } else { binding.AddFrequency(occurrence); } } } } }
public void CompareMildlyTamperedLogWithHardPetriNetTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); RelationMatrix matrix = new RelationMatrix(wlog); IPetriNet madeNet = Alpha.MakePetriNet(matrix); ImportedEventLog tamperedLog = CSVImport.MakeDataFrame(tamperedHardCsv); tamperedLog.SetActivity("act"); tamperedLog.SetCaseId("id"); // Act double fitness = Computations.ComputeFitness(tamperedLog, madeNet); // Assert Assert.AreEqual(96, (int)(fitness*100)); }
public void WorkflowLogBasicTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(easyCsv); elog.SetActivity("act"); elog.SetCaseId("id"); // Act WorkflowLog wlog = new WorkflowLog(elog); // Assert Assert.AreEqual(wlog.WorkflowTraces[0].CaseId, "1"); Assert.AreEqual(wlog.WorkflowTraces[1].CaseId, "2"); Assert.AreEqual(wlog.WorkflowTraces[0].Activities[0], "a"); Assert.AreEqual(wlog.WorkflowTraces[0].Activities[1], "b"); Assert.AreEqual(wlog.WorkflowTraces[0].Activities[2], "c"); Assert.AreEqual(wlog.WorkflowTraces[1].Activities[0], "a"); Assert.AreEqual(wlog.WorkflowTraces[1].Activities[1], "d"); Assert.AreEqual(wlog.WorkflowTraces[1].Activities[2], "c"); }
public void AlignmentOnLogHardCustomSettings() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog, new HeuristicMinerSettings() { L2LThreshold = 1 })); // Act AlignmentOnLog alignment = new AlignmentOnLog(wlog, pNet); // Assert // Now all traces doesn't fit, because L2L loop (B->C->B) is removed Assert.IsTrue(alignment.Fitness < 1); Assert.AreEqual(wlog.GetTracesWithOccurrence().Count, alignment.AlignmentsOnLog.Count); }
public void ConvertEasyCNetToPetriNetTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); CNet causalNet = new CNet(wlog, new HeuristicMinerSettings()); // Act PetriNet petriNet = CNetUtils.ConvertCNetToPetriNet(causalNet); // Assert Assert.AreEqual("p0", petriNet.StartPlace.Id); Assert.AreEqual("p" + (2 * causalNet.EndActivity.Id + 1), petriNet.EndPlace.Id); Assert.AreEqual(10, petriNet.Places.Count); Assert.AreEqual(13, petriNet.Transitions.Count); // 8 invisible transitions Assert.AreEqual(8, petriNet.Transitions.Count(t => t.Invisible)); }
public void AlignmentOnTraceHardNoL2LLoop() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); PetriNet pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog, new HeuristicMinerSettings() { L2LThreshold = 1 })); // Act unfitting trace abcbcdfgi (deleted L2L loop B->C->B) var alignment = new AlignmentOnTrace(wlog.WorkflowTraces[61], pNet); // Assert Assert.AreEqual(0.875, alignment.Fitness); // two moves (model and trace) for B and one for C Assert.AreEqual(2, alignment.OptimalCost); }
public void ConvertHardCNetToPetriNetTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); CNet causalNet = HeuristicMiner.MineCNet(wlog); // Act PetriNet petriNet = HeuristicMiner.MinePetriNet(wlog); // Assert Assert.AreEqual("p0", petriNet.StartPlace.Id); Assert.AreEqual("p" + (2 * causalNet.EndActivity.Id + 1), petriNet.EndPlace.Id); Assert.AreEqual(18, petriNet.Places.Count); Assert.AreEqual(21, petriNet.Transitions.Count); // 12 invisible transitions Assert.AreEqual(12, petriNet.Transitions.Count(t => t.Invisible)); }
public void AlignmentOnTraceEasy() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); PetriNet pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog)); // Act // trace "AE" -> Doesn't fit var traceAlignment1 = new AlignmentOnTrace(wlog.WorkflowTraces[0], pNet); // trace "ACBE" fits perfectly var traceAlignment2 = new AlignmentOnTrace(wlog.WorkflowTraces[10], pNet); // Assert Assert.AreEqual(0.8, traceAlignment1.Fitness); Assert.AreEqual(1, traceAlignment1.OptimalCost); Assert.AreEqual(1, traceAlignment2.Fitness); Assert.AreEqual(0, traceAlignment2.OptimalCost); }
public void MakeCNetEasyDefaultSettings() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(heuristicCsv); elog.SetActivity("act"); elog.SetCaseId("id"); WorkflowLog wlog = new WorkflowLog(elog); var successorMatrix = new SuccessorMatrix(wlog); // Act CNet causalNet = HeuristicMiner.MineCNet(wlog); // Assert Assert.AreEqual(0, causalNet.StartActivity.Id); Assert.AreEqual(1, causalNet.EndActivity.Id); //ACTIVITY OCCURRENCE Assert.AreEqual(5, causalNet.Activities.Count); Assert.AreEqual(40, causalNet.Activities[0].Frequency); Assert.AreEqual(40, causalNet.Activities[1].Frequency); Assert.AreEqual(21, causalNet.Activities[2].Frequency); Assert.AreEqual(21, causalNet.Activities[3].Frequency); Assert.AreEqual(17, causalNet.Activities[4].Frequency); //Number of bindings Assert.AreEqual(0, causalNet.InputBindings[0].Count); Assert.AreEqual(4, causalNet.InputBindings[1].Count); Assert.AreEqual(1, causalNet.InputBindings[2].Count); Assert.AreEqual(1, causalNet.InputBindings[3].Count); Assert.AreEqual(1, causalNet.InputBindings[4].Count); Assert.AreEqual(4, causalNet.OutputBindings[0].Count); Assert.AreEqual(0, causalNet.OutputBindings[1].Count); Assert.AreEqual(1, causalNet.OutputBindings[2].Count); Assert.AreEqual(1, causalNet.OutputBindings[3].Count); Assert.AreEqual(1, causalNet.OutputBindings[4].Count); //A&B BIND FREQUENCY Assert.AreEqual(20, causalNet.OutputBindings[0].First(u => u.Activities.Count == 2).Frequency); Assert.AreEqual(20, causalNet.InputBindings[1].First(b => b.Activities.Count == 2).Frequency); }