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);
        }
        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);
        }
Beispiel #4
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);
        }
        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);
            }
        }
        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);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        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 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);
        }
        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);
        }
Beispiel #11
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
            }));
        }