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);
        }
Example #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);
        }
Example #3
0
    static async Task ReloadAllConfigs()
    {
        var servers_confFolder = CManiaNextControl.RunningPath + "configs";
        var global_confFile    = CManiaNextControl.RunningPath + "nextcontrol.conf";

        // Load global conf first
        {
        }

        CManiaNextControl.ServersConfig = new Dictionary <string, CServerConfig>();
        {
            CDebug.Log(servers_confFolder);

            if (!Directory.Exists(servers_confFolder))
            {
                Directory.CreateDirectory(servers_confFolder);
            }

            foreach (var file in Directory.GetFiles(servers_confFolder))
            {
                if (file.EndsWith(".conf"))
                {
                    CDebug.Log(file.LastIndexOf('.'));

                    string serverLogin = file.Substring(file.LastIndexOf("\\"), file.Length - file.LastIndexOf('.'));
                    var    config      = new CServerConfig(file);

                    if ((await config.GetLiveValue("Enabled", "false")).ToLower() == "false" ||
                        await config.GetLiveValue("Enabled", "false") == "0")
                    {
                        continue;
                    }

                    config.ServerLogin     = serverLogin;
                    config.SuperAdminLogin = await config.GetLiveValue("SuperAdminLogin", "SuperAdmin");

                    config.SuperAdminPassword = await config.GetLiveValue("SuperAdminPassword", "SuperAdmin");

                    config.Port = await config.GetLiveValue("Port", "") == "" ? CNetUtils.TryGetPort(serverLogin) : int.Parse(await config.GetLiveValue("Port"));

                    CManiaNextControl.ServersConfig[serverLogin] = config;
                }
            }
        }
    }
        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);
        }
Example #6
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);
        }
Example #7
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));
        }
        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);
        }
Example #9
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
            }));
        }
Example #10
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)));
 }