コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public void SyncNetHard()
        {
            // Arrange
            ImportedEventLog elog = CSVImport.MakeDataFrame(hardCsv);

            elog.SetActivity("act");
            elog.SetCaseId("id");
            WorkflowLog wlog = new WorkflowLog(elog);
            var         tNet = AlignmentUtils.MakePNetFromTrace(wlog.WorkflowTraces[23]);
            var         pNet = CNetUtils.ConvertCNetToPetriNet(HeuristicMiner.MineCNet(wlog));

            // Act
            var syncNet = new SynchronousProductNet(tNet, pNet);

            // Assert
            Assert.AreEqual(syncNet.Places.Count, pNet.Places.Count + tNet.Places.Count);
            Assert.AreEqual(pNet.Transitions.Count + 2 * tNet.Transitions.Count, syncNet.Transitions.Count);
            Assert.IsTrue(syncNet.EndPlaces.SetEquals(new HashSet <IPlace> {
                tNet.EndPlace, pNet.EndPlace
            }));
            Assert.IsTrue(syncNet.StartPlaces.SetEquals(new HashSet <IPlace> {
                tNet.StartPlace, pNet.StartPlace
            }));
        }
コード例 #9
0
 /// <summary>
 /// Mine Petri net from a workflow log based on given settings
 /// </summary>
 /// <param name="workflowLog">Workflow log</param>
 /// <param name="heuristicMinerSettings">Heuristic miner settings</param>
 /// <returns></returns>
 public static PetriNet MinePetriNet(WorkflowLog workflowLog, HeuristicMinerSettings heuristicMinerSettings)
 {
     return(CNetUtils.ConvertCNetToPetriNet(MineCNet(workflowLog, heuristicMinerSettings)));
 }