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 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); }
public List <TextImportation> keysImport; // Stock each key ( line ) in a custom class private void Awake() { if (Singleton != null) { Destroy(this); } else { Singleton = this; } string[] data = csvFile.text.Split(new char[] { '\n' }); // Separate each line of a file ( CSV better ) for (int i = 1; i < data.Length; i++) { string[] row = data[i].Split(new char[] { ',' }); // Separate each ',' from a CSV file TextImportation importRow = new TextImportation(); // Create a custom class to stock text / id... importRow.PageName = row[0]; for (int y = 1; y < row.Length; y++) { importRow.Addresses.Add(row[y]); } keysImport.Add(importRow); } }
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); } }
public void CSVImportInvalidTest() { // Arrange string path = "." + separator + "thisFileDoesNotExist.csv"; // Act and Assert Assert.ThrowsException <ArgumentException>(() => CSVImport.MakeDataFrame(path)); }
public frmMain() { InitializeComponent(); worksheet = shcMain.ActiveWorksheet; CSVImport csvImport = new CSVImport(@"E:\Магистратура\5\test2.csv", ";"); worksheet.Load(csvImport); }
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)); }
public static void ImportCsv <T, TList>(string configFile, string tableId, string importId, string sourceFile, TList successList, TList failList, bool withEvents, SourceDataValidatingHandler <DataRow, DataTable> sourceDataVilidater = null, DataValidatingHandler <T, TList> targetDataValidater = null) where T : class, new() where TList : class { CSVImport <T, TList> import = CreateCsvImport <T, TList>(configFile, tableId, importId, withEvents, sourceDataVilidater, targetDataValidater); import.Import(sourceFile, successList, failList); import.Dispose(); }
public void CSVImportValidTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPath); // Assert Assert.IsNotNull(importedEventLog); }
public void CSVImportValidDefinedCultureTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPath, culture: "en-US"); // Assert Assert.IsNotNull(importedEventLog); }
public CSVImport GetOrCreateCSVImport(int?CSVImportID) { if (CSVImportID.GetValueOrDefault(0) > 0) { return(this.CSVImport.FirstOrDefault(x => x.CSVImportID == CSVImportID)); } var newItem = new CSVImport(); this.CSVImport.AddObject(newItem); return(newItem); }
public void CSVImportValidSemicolonSeparatorTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPathSemicolon, separatorsString: ";"); // Assert Assert.IsNotNull(importedEventLog); }
public CSVImport GetOrCreateCSVImport(int?CSVImportID) { CSVImport item = this.CSVImport.FirstOrDefault(x => x.CSVImportID == CSVImportID); if (item == null) { item = new CSVImport(); this.CSVImport.AddObject(item); } return(item); }
public void CSVImportValidLimitedRowsTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPath, maxRows: 2); // Assert Assert.IsNotNull(importedEventLog); Assert.AreEqual(importedEventLog.Contents.RowCount, 2); }
public void CSVImportValidNoHeadersTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPath, hasHeaders: false); // Assert Assert.IsNotNull(importedEventLog); Assert.AreEqual(importedEventLog.Contents.GetRow <string>(0).GetAt(0), "id"); }
public void CSVImportValidNoInferenceTest() { // Arrange ImportedEventLog importedEventLog; // Act importedEventLog = CSVImport.MakeDataFrame(CSVPath, inferTypes: false); // Assert Assert.IsNotNull(importedEventLog); Assert.AreEqual(importedEventLog.Contents.GetRow <string>(0).GetAt(0), "1"); }
public void ImportedEventLogSetInvalidValuesTest() { // Arrange ImportedEventLog elog = CSVImport.MakeDataFrame(timestampedCsv); // Act and assert Assert.IsFalse(elog.SetActivity("thisIsNotValidActivity")); Assert.IsFalse(elog.SetCaseId("thisIsNotValidCaseId")); Assert.IsFalse(elog.SetTimestamp("thisIsNotValidTimestamp")); Assert.IsNull(elog.Activity); Assert.IsNull(elog.CaseId); Assert.IsNull(elog.Timestamp); }
// Import information from file with offers and file with routes (see CSVImport in DataAccess for more info) public void InitializeImport(string masterDataFilepath, string routeNumberFilepath) { CSVImport csvImport = new CSVImport(); csvImport.ImportContractors(masterDataFilepath); csvImport.ImportRouteNumbers(); csvImport.ImportOffers(routeNumberFilepath); contractorList = csvImport.SendContractorListToContainer(); routeNumberList = csvImport.SendRouteNumberListToContainer(); ListContainer listContainer = ListContainer.GetInstance(); listContainer.GetLists(routeNumberList, contractorList); }
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 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); }
//Starts the import of data when import is clicked public void InitializeImport(string masterDataFilepath, string routeNumberFilepath) { CSVImport csvImport = new CSVImport(); //only import from excel file if database is empty and there are excel files to import if (masterDataFilepath != null || routeNumberFilepath != null) { //Import data from excel files csvImport.ImportContractors(masterDataFilepath); csvImport.ImportRouteNumbers(); csvImport.ImportOffers(routeNumberFilepath); } //Import data from database contractorList = csvImport.SendContractorListToListContainer(); routeNumberList = csvImport.SendRouteNumberListToListContainer(); ListContainer listContainer = ListContainer.GetInstance(); listContainer.GetLists(routeNumberList, contractorList); }
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 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 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); }