//ResultMatrix with ResultMatrix-cellTypes /// <summary> /// Compares two footprints and saves the result in ResultMatrix /// </summary> /// <param name="footprint1">The first footprint</param> /// <param name="footprint2">The second footprint</param> /// <autor>Andrej Albrecht</autor> public ComparingFootprintResultMatrix(ComparingFootprint footprint1, ComparingFootprint footprint2) { AddEventHeader(footprint1); AddEventHeader(footprint2); ResultMatrix = new ResultCellType[HeaderWithEventNames.Count, HeaderWithEventNames.Count]; for (int row = 0; row < HeaderWithEventNames.Count; row++) for (int column = 0; column < HeaderWithEventNames.Count; column++) { CellType matrix1Cell = footprint1.GetFootprintCellState(HeaderWithEventNames[row], HeaderWithEventNames[column]); CellType matrix2Cell = footprint2.GetFootprintCellState(HeaderWithEventNames[row], HeaderWithEventNames[column]); if (matrix1Cell.Equals(matrix2Cell)) { //If the cellstates of the both footprints are equal, then they have no differences ResultMatrix[row, column] = ResultCellType.NoDifferences; } else { // find the right CellState for the differences of both footprints ResultMatrix[row, column] = ComparingFootprintResultMatrixCell.GetResultCellType(matrix1Cell, matrix2Cell); } } }
public void AddEventHeaderTest() { ComparingFootprint footprint = new ComparingFootprint(); footprint.AddEventHeader("A"); footprint.AddEventHeader("B"); Assert.IsTrue(footprint.HeaderWithEventNames.Contains("A")); Assert.IsTrue(footprint.HeaderWithEventNames.Contains("B")); }
/// <summary> /// Constructor the show a footprint of just one transition /// </summary> /// <param name="transitionName"></param> public FootprintViewer(String transitionName) { InitializeComponent(); ComparingFootprint footPrintEventlog = ComparingFootprintAlgorithm.CreateFootprint(Viewer.CurrentField.EventLog); ComparingFootprint footPrintPetrinet = ComparingFootprintAlgorithm.CreateFootprint((PetriNet)Viewer.CurrentField.ProcessModel); ComparingFootprintResultMatrix resultFootprint = new ComparingFootprintResultMatrix(footPrintEventlog, footPrintPetrinet); ComparingFootprintResultMatrix result = StripFootprintForTransition(transitionName, resultFootprint); ShowFootprint(result, EventLogGrid); }
/// <summary> /// Constructor for the output of a normal footprint /// </summary> public FootprintViewer() { InitializeComponent(); ComparingFootprint footPrintEventlog = ComparingFootprintAlgorithm.CreateFootprint(Viewer.CurrentField.EventLog); ComparingFootprint footPrintPetrinet = ComparingFootprintAlgorithm.CreateFootprint((PetriNet)Viewer.CurrentField.ProcessModel); ComparingFootprintResultMatrix resultFootprint = new ComparingFootprintResultMatrix(footPrintEventlog, footPrintPetrinet); ShowFootprint(footPrintEventlog, EventLogGrid); ShowFootprint(footPrintPetrinet, PetriNetGrid); ShowFootprint(resultFootprint, ComparisonGrid); }
/// <summary> /// Draws the footprint to the grid /// </summary> /// <param name="footprint"></param> /// <param name="dataGrid"></param> /// <autor>Andrej Albrecht</autor> private void ShowFootprint(ComparingFootprint footprint, DataGrid dataGrid) { try { DataTable dataTable = new DataTable(); dataTable.Columns.Add(""); //empty c on the upper left corner foreach (String headerNameY in footprint.HeaderWithEventNames) { dataTable.Columns.Add(headerNameY); } for (int rowIndex = 0; rowIndex < footprint.HeaderWithEventNames.Count; rowIndex++) { object[] row = new object[1 + footprint.HeaderWithEventNames.Count]; row[0] = footprint.HeaderWithEventNames[rowIndex]; //row header description for (int columnIndex = 0; columnIndex < footprint.HeaderWithEventNames.Count; columnIndex++) { try { if (footprint is ComparingFootprintResultMatrix) { row[columnIndex + 1] = GetResultCellTypeName(((ComparingFootprintResultMatrix)footprint).ResultMatrix[rowIndex, columnIndex]); } else { row[columnIndex + 1] = GetCellTypeName(footprint.ResultMatrix[rowIndex, columnIndex]); } } catch (Exception) { row[columnIndex + 1] = "-?-"; } } dataTable.Rows.Add(row); } dataGrid.DataContext = dataTable; } catch (Exception Ex) { ErrorHandling.ReportErrorToUser("Error: " + Ex.Message + Ex.StackTrace); } }
public void ComparingFootprintHeaderNamesFromPetriNetTest1() { ComparingFootprint footprintResult = ComparingFootprintAlgorithm.CreateFootprint(PetriNetExample.PetriNetWithFivePlacesAndFourTransitions()); List <String> headerNames = footprintResult.HeaderWithEventNames; if (headerNames.Count != 4) { Assert.Fail(); } int index = 0; foreach (String hName in headerNames) { if (!hName.Equals("TransitionA") && index == 0) { Assert.Fail(); } if (!hName.Equals("TransitionB") && index == 1) { Assert.Fail(); } if (!hName.Equals("TransitionC") && index == 2) { Assert.Fail(); } if (!hName.Equals("TransitionD") && index == 3) { Assert.Fail(); } index++; } }
/// <summary> /// Draws the footprint to the grid /// </summary> /// <param name="footprint"></param> /// <param name="dataGrid"></param> /// <autor>Andrej Albrecht</autor> private void ShowFootprint(ComparingFootprint footprint, DataGrid dataGrid) { try { DataTable dataTable = new DataTable(); dataTable.Columns.Add(""); //empty c on the upper left corner foreach (String headerNameY in footprint.HeaderWithEventNames) dataTable.Columns.Add(headerNameY); for (int rowIndex = 0; rowIndex < footprint.HeaderWithEventNames.Count; rowIndex++) { object[] row = new object[1 + footprint.HeaderWithEventNames.Count]; row[0] = footprint.HeaderWithEventNames[rowIndex]; //row header description for (int columnIndex = 0; columnIndex < footprint.HeaderWithEventNames.Count; columnIndex++) { try { if (footprint is ComparingFootprintResultMatrix) row[columnIndex + 1] = GetResultCellTypeName(((ComparingFootprintResultMatrix)footprint).ResultMatrix[rowIndex, columnIndex]); else row[columnIndex + 1] = GetCellTypeName(footprint.ResultMatrix[rowIndex, columnIndex]); } catch (Exception) { row[columnIndex + 1] = "-?-"; } } dataTable.Rows.Add(row); } dataGrid.DataContext = dataTable; } catch (Exception Ex) { ErrorHandling.ReportErrorToUser("Error: " + Ex.Message + Ex.StackTrace); } }
/// <summary> /// Conformance Check between the eventlog and generated process model. /// The criticized transitions are shown in the process model. /// </summary> /// <autor>Andrej Albrecht</autor> public void DrawConformanceModelInCanvas(Field field, Canvas canvas) { try { // Create Footprints ComparingFootprint footPrintEventlog = ComparingFootprintAlgorithm.CreateFootprint(field.EventLog); ComparingFootprint footPrintPetrinet = ComparingFootprintAlgorithm.CreateFootprint((PetriNet)field.ProcessModel); ComparingFootprintResultMatrix resultFootprint = new ComparingFootprintResultMatrix(footPrintEventlog, footPrintPetrinet); // Calculate Fitness double fitnessComparingFootprint = ComparingFootprintAlgorithm.CalculateFitness(resultFootprint.GetNumberOfDifferences(), resultFootprint.GetNumberOfOpportunities()); FitnessComparingFootprints.Content = "Fitness Comparing Footprints: " + Math.Round(fitnessComparingFootprint * 100, 2) + " %"; // Prepare Canvas & draw model RemoveListenerFromCanvas(canvas); canvas.Children.Clear(); VisualizationHelpers.GetOrCreatePetriNetVisualization(field, canvas); AddListenertoTransitions(canvas); // Color the transitions in List <String> listOfGreenTransitions = new List <String>(); List <String> listOfRedTransitions = new List <String>(); List <List <String> > listOfLinesToBeRemoved = new List <List <String> >(); int row = 0; foreach (String rowHeaderName in resultFootprint.HeaderWithEventNames) { int column = 0; foreach (String columnHeaderName in resultFootprint.HeaderWithEventNames) { if (resultFootprint.ResultMatrix[row, column].Equals(ResultCellType.NoDifferences) && rowHeaderName.Equals(columnHeaderName)) { listOfGreenTransitions.Add(rowHeaderName); } else if (resultFootprint.ResultMatrix[row, column].Equals(ResultCellType.NothingAndRight)) { listOfLinesToBeRemoved.Add(new List <String> { rowHeaderName, columnHeaderName }); } // else if (ResultFootprint.ResultMatrix[Row, Column].Equals(ResultCellType.RightAndNothing)) // Model enhacement: here you can fill a list of lines that are must to be add to the petrinet // example: listOfLinesToAddTo.Add(new TransitionCombination(yHeaderName, xHeaderName)); else if (rowHeaderName.Equals(columnHeaderName)) { listOfRedTransitions.Add(rowHeaderName); } column++; } row++; } SetColorInCanvas(listOfGreenTransitions, Brushes.Green, canvas); SetColorInCanvas(listOfRedTransitions, Brushes.Red, canvas); SetColorOnLinesToBeRemoved(listOfLinesToBeRemoved, canvas, (PetriNet)field.ProcessModel); } catch (Exception Ex) { ErrorHandling.ReportErrorToUser("Error: " + Ex.Message + Ex.StackTrace); } }
public void ComparingFootprintFromPetriNetTest3() { ComparingFootprint footprintResult = new ComparingFootprint(); footprintResult = ComparingFootprintAlgorithm.CreateFootprint(PetriNetExample.PetriNetWithSixPlacesAndFiveTransitions()); CellType[,] resultMatrix = footprintResult.ResultMatrix; List<String> headerNames = footprintResult.HeaderWithEventNames; if (headerNames.Count != 5) Assert.Fail("ComparingFootprints header Names Count != 6"); int y = 0; foreach (String hNameY in headerNames) { int x = 0; foreach (String hNameX in headerNames) { if (hNameY.Equals("A") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else { Assert.Fail("ComparingFootprintFromPetriNetTest3"); } x++; } y++; } }
public void CompareEventLogAndPetriNetTest1() { // //EventLog // //create Case1 Case ca1 = new Case(); ca1.CreateEvent("A"); ca1.CreateEvent("C"); ca1.CreateEvent("D"); ca1.CreateEvent("E"); ca1.CreateEvent("H"); //create Case2 Case ca2 = new Case(); ca2.CreateEvent("A"); ca2.CreateEvent("B"); ca2.CreateEvent("D"); ca2.CreateEvent("E"); ca2.CreateEvent("G"); //create Case3 Case ca3 = new Case(); ca3.CreateEvent("A"); ca3.CreateEvent("D"); ca3.CreateEvent("C"); ca3.CreateEvent("E"); ca3.CreateEvent("H"); //create Case4 Case ca4 = new Case(); ca4.CreateEvent("A"); ca4.CreateEvent("B"); ca4.CreateEvent("D"); ca4.CreateEvent("E"); ca4.CreateEvent("H"); //create Case5 Case ca5 = new Case(); ca5.CreateEvent("A"); ca5.CreateEvent("C"); ca5.CreateEvent("D"); ca5.CreateEvent("E"); ca5.CreateEvent("G"); //create Case6 Case ca6 = new Case(); ca6.CreateEvent("A"); ca6.CreateEvent("D"); ca6.CreateEvent("C"); ca6.CreateEvent("E"); ca6.CreateEvent("G"); //create Case7 Case ca7 = new Case(); ca7.CreateEvent("A"); ca7.CreateEvent("D"); ca7.CreateEvent("B"); ca7.CreateEvent("E"); ca7.CreateEvent("H"); //create Case8 Case ca8 = new Case(); ca8.CreateEvent("A"); ca8.CreateEvent("C"); ca8.CreateEvent("D"); ca8.CreateEvent("E"); ca8.CreateEvent("F"); ca8.CreateEvent("D"); ca8.CreateEvent("B"); ca8.CreateEvent("E"); ca8.CreateEvent("H"); //create Case9 Case ca9 = new Case(); ca9.CreateEvent("A"); ca9.CreateEvent("D"); ca9.CreateEvent("B"); ca9.CreateEvent("E"); ca9.CreateEvent("G"); //create Case10 Case ca10 = new Case(); ca10.CreateEvent("A"); ca10.CreateEvent("C"); ca10.CreateEvent("D"); ca10.CreateEvent("E"); ca10.CreateEvent("F"); ca10.CreateEvent("B"); ca10.CreateEvent("D"); ca10.CreateEvent("E"); ca10.CreateEvent("H"); //create Case11 Case ca11 = new Case(); ca11.CreateEvent("A"); ca11.CreateEvent("C"); ca11.CreateEvent("D"); ca11.CreateEvent("E"); ca11.CreateEvent("F"); ca11.CreateEvent("B"); ca11.CreateEvent("D"); ca11.CreateEvent("E"); ca11.CreateEvent("G"); //create Case12 Case ca12 = new Case(); ca12.CreateEvent("A"); ca12.CreateEvent("C"); ca12.CreateEvent("D"); ca12.CreateEvent("E"); ca12.CreateEvent("F"); ca12.CreateEvent("D"); ca12.CreateEvent("B"); ca12.CreateEvent("E"); ca12.CreateEvent("G"); //create Case13 Case ca13 = new Case(); ca13.CreateEvent("A"); ca13.CreateEvent("D"); ca13.CreateEvent("C"); ca13.CreateEvent("E"); ca13.CreateEvent("F"); ca13.CreateEvent("C"); ca13.CreateEvent("D"); ca13.CreateEvent("E"); ca13.CreateEvent("H"); //create Case14 Case ca14 = new Case(); ca14.CreateEvent("A"); ca14.CreateEvent("D"); ca14.CreateEvent("C"); ca14.CreateEvent("E"); ca14.CreateEvent("F"); ca14.CreateEvent("D"); ca14.CreateEvent("B"); ca14.CreateEvent("E"); ca14.CreateEvent("H"); //create Case15 Case ca15 = new Case(); ca15.CreateEvent("A"); ca15.CreateEvent("D"); ca15.CreateEvent("C"); ca15.CreateEvent("E"); ca15.CreateEvent("F"); ca15.CreateEvent("B"); ca15.CreateEvent("D"); ca15.CreateEvent("E"); ca15.CreateEvent("G"); //create Case16 Case ca16 = new Case(); ca16.CreateEvent("A"); ca16.CreateEvent("C"); ca16.CreateEvent("D"); ca16.CreateEvent("E"); ca16.CreateEvent("F"); ca16.CreateEvent("B"); ca16.CreateEvent("D"); ca16.CreateEvent("E"); ca16.CreateEvent("F"); ca16.CreateEvent("D"); ca16.CreateEvent("B"); ca16.CreateEvent("E"); ca16.CreateEvent("G"); //create Case17 Case ca17 = new Case(); ca17.CreateEvent("A"); ca17.CreateEvent("D"); ca17.CreateEvent("C"); ca17.CreateEvent("E"); ca17.CreateEvent("F"); ca17.CreateEvent("D"); ca17.CreateEvent("B"); ca17.CreateEvent("E"); ca17.CreateEvent("G"); //create Case18 Case ca18 = new Case(); ca18.CreateEvent("A"); ca18.CreateEvent("D"); ca18.CreateEvent("C"); ca18.CreateEvent("E"); ca18.CreateEvent("F"); ca18.CreateEvent("B"); ca18.CreateEvent("D"); ca18.CreateEvent("E"); ca18.CreateEvent("F"); ca18.CreateEvent("B"); ca18.CreateEvent("D"); ca18.CreateEvent("E"); ca18.CreateEvent("G"); //create Case19 Case ca19 = new Case(); ca19.CreateEvent("A"); ca19.CreateEvent("D"); ca19.CreateEvent("C"); ca19.CreateEvent("E"); ca19.CreateEvent("F"); ca19.CreateEvent("D"); ca19.CreateEvent("B"); ca19.CreateEvent("E"); ca19.CreateEvent("F"); ca19.CreateEvent("B"); ca19.CreateEvent("D"); ca19.CreateEvent("E"); ca19.CreateEvent("H"); //create Case20 Case ca20 = new Case(); ca20.CreateEvent("A"); ca20.CreateEvent("D"); ca20.CreateEvent("B"); ca20.CreateEvent("E"); ca20.CreateEvent("F"); ca20.CreateEvent("B"); ca20.CreateEvent("D"); ca20.CreateEvent("E"); ca20.CreateEvent("F"); ca20.CreateEvent("D"); ca20.CreateEvent("B"); ca20.CreateEvent("E"); ca20.CreateEvent("G"); //create Case21 Case ca21 = new Case(); ca21.CreateEvent("A"); ca21.CreateEvent("D"); ca21.CreateEvent("C"); ca21.CreateEvent("E"); ca21.CreateEvent("F"); ca21.CreateEvent("D"); ca21.CreateEvent("B"); ca21.CreateEvent("E"); ca21.CreateEvent("F"); ca21.CreateEvent("C"); ca21.CreateEvent("D"); ca21.CreateEvent("E"); ca21.CreateEvent("F"); ca21.CreateEvent("D"); ca21.CreateEvent("B"); ca21.CreateEvent("E"); ca21.CreateEvent("G"); //create Event Log EventLog eventLog = new EventLog(); eventLog.Cases.Add(ca1); eventLog.Cases.Add(ca2); eventLog.Cases.Add(ca3); eventLog.Cases.Add(ca4); eventLog.Cases.Add(ca5); eventLog.Cases.Add(ca6); eventLog.Cases.Add(ca7); eventLog.Cases.Add(ca8); eventLog.Cases.Add(ca9); eventLog.Cases.Add(ca10); eventLog.Cases.Add(ca11); eventLog.Cases.Add(ca12); eventLog.Cases.Add(ca13); eventLog.Cases.Add(ca14); eventLog.Cases.Add(ca15); eventLog.Cases.Add(ca16); eventLog.Cases.Add(ca17); eventLog.Cases.Add(ca18); eventLog.Cases.Add(ca19); eventLog.Cases.Add(ca20); eventLog.Cases.Add(ca21); // //PetriNet // PetriNet petriNet = new PetriNet("Petri-Net Name"); Place pStart = new Place("Place Start", 0); Place pC1 = new Place("c1", 0); Place pC2 = new Place("c2", 0); Place pC3 = new Place("c3", 0); Place pC4 = new Place("c4", 0); Place pC5 = new Place("c5", 0); Place pEnd = new Place("Place End", 0); Transition tA = new Transition("A"); Transition tB = new Transition("B"); Transition tC = new Transition("C"); Transition tD = new Transition("D"); Transition tE = new Transition("E"); Transition tF = new Transition("F"); Transition tG = new Transition("G"); Transition tH = new Transition("H"); tG.AddOutgoingPlace(pEnd); tG.AddIncomingPlace(pC5); tH.AddOutgoingPlace(pEnd); tH.AddIncomingPlace(pC5); tE.AddIncomingPlace(pC3); tE.AddIncomingPlace(pC4); tE.AddOutgoingPlace(pC5); pC3.AppendIncomingTransition(tB); pC3.AppendIncomingTransition(tC); pC3.AppendOutgoingTransition(tE); pC4.AppendIncomingTransition(tD); pC4.AppendOutgoingTransition(tE); tB.AddIncomingPlace(pC1); tB.AddOutgoingPlace(pC3); tC.AddIncomingPlace(pC1); tC.AddOutgoingPlace(pC3); tD.AddIncomingPlace(pC2); tD.AddOutgoingPlace(pC4); pC1.AppendIncomingTransition(tA); pC1.AppendOutgoingTransition(tB); pC1.AppendOutgoingTransition(tC); pC2.AppendIncomingTransition(tA); pC2.AppendOutgoingTransition(tD); tF.AddIncomingPlace(pC5); tF.AddOutgoingPlace(pC1); tF.AddOutgoingPlace(pC2); // tA.AddIncomingPlace(pStart); tA.AddOutgoingPlace(pC1); tA.AddOutgoingPlace(pC2); pStart.AppendOutgoingTransition(tA); pEnd.AppendIncomingTransition(tG); pEnd.AppendIncomingTransition(tH); //// petriNet.Transitions.Add(tA); petriNet.Transitions.Add(tB); petriNet.Transitions.Add(tC); petriNet.Transitions.Add(tD); petriNet.Transitions.Add(tE); petriNet.Transitions.Add(tF); petriNet.Transitions.Add(tG); petriNet.Transitions.Add(tH); //// petriNet.Places.Add(pStart); petriNet.Places.Add(pC1); petriNet.Places.Add(pC2); petriNet.Places.Add(pC3); petriNet.Places.Add(pC4); petriNet.Places.Add(pC5); petriNet.Places.Add(pEnd); ComparingFootprint footprintEventLog = ComparingFootprintAlgorithm.CreateFootprint(eventLog); ComparingFootprint footprintPetriNet = ComparingFootprintAlgorithm.CreateFootprint(petriNet); ComparingFootprintResultMatrix footprintResultMatrix = new ComparingFootprintResultMatrix(footprintEventLog, footprintPetriNet); if (footprintResultMatrix.HeaderWithEventNames.Count != 8) { Assert.Fail(""); } int y = 0; foreach (String headerNameY in footprintResultMatrix.HeaderWithEventNames) { int x = 0; foreach (String headerNameX in footprintResultMatrix.HeaderWithEventNames) { ResultCellType resultCellType = footprintResultMatrix.ResultMatrix[y, x]; Console.WriteLine("Test headerNameY: " + headerNameY + ", headerNameX: " + headerNameX + " [" + y + "," + x + "].CellType:" + resultCellType); if (!resultCellType.Equals(ResultCellType.NoDifferences)) { Assert.Fail("Test headerNameY: " + headerNameY + ", headerNameX: " + headerNameX + " [" + y + "," + x + "].CellType:" + resultCellType); } x++; } y++; } //Arrange (Create Footprints) ComparingFootprint footPrintEventlog = ComparingFootprintAlgorithm.CreateFootprint(eventLog); ComparingFootprint footPrintPetrinet = ComparingFootprintAlgorithm.CreateFootprint(petriNet); ComparingFootprintResultMatrix resultFootprint = new ComparingFootprintResultMatrix(footPrintEventlog, footPrintPetrinet); // Act (Calculate Fitness) double fitnessComparingFootprint = ComparingFootprintAlgorithm.CalculateFitness(resultFootprint.GetNumberOfDifferences(), resultFootprint.GetNumberOfOpportunities()); if (fitnessComparingFootprint != 1.0) { // Assert Assert.Fail("Fitness not correct! (" + fitnessComparingFootprint + ")"); } }
/// <summary> /// create a single footprint from a list of footprints /// </summary> /// <param name="footprintList">A list of footprints</param> /// <returns>A Footprint</returns> /// <autor>Andrej Albrecht</autor> public static ComparingFootprint MergeFootprints(List<ComparingFootprint> footprintList) { ComparingFootprint footprintResult = new ComparingFootprint(); footprintResult.MergeFootprints(footprintList); return footprintResult; }
/// <summary> /// Create a footprint from one case /// </summary> /// <param name="c">A case</param> /// <param name="cases">A list of cases</param> /// <autor>Andrej Albrecht</autor> public static ComparingFootprint CreateFootprint(Case c, List<Case> cases = null) { ComparingFootprint footprint = new ComparingFootprint(); foreach (Event Event in c.EventList) footprint.AddEventHeader(Event.Name); int numberOfEventsInCase = c.EventList.Count; CellType[,] resultMatrix = new CellType[numberOfEventsInCase, numberOfEventsInCase]; for (int row = 0; row < footprint.HeaderWithEventNames.Count; row++) { for (int column = 0; column < footprint.HeaderWithEventNames.Count; column++) { //first of all, reset the cellstate to nothing: resultMatrix[row, column] = CellType.Nothing; //Go through all events of the case for (int eventIndex = 0; eventIndex < c.EventList.Count - 1; eventIndex++) { String leftEventName = c.EventList.ElementAt(eventIndex).Name; String rightEventName = c.EventList.ElementAt(eventIndex + 1).Name; if (footprint.HeaderWithEventNames[row].Equals(leftEventName) && footprint.HeaderWithEventNames[column].Equals(rightEventName) && leftEventName.Equals(rightEventName)) { resultMatrix[row, column] = CellType.Loop; resultMatrix[row, column] = CellType.Loop; } else if (footprint.HeaderWithEventNames[row].Equals(leftEventName) && footprint.HeaderWithEventNames[column].Equals(rightEventName)) { if (resultMatrix[row, column].Equals(CellType.Left)) resultMatrix[row, column] = CellType.Parallel; else if (resultMatrix[row, column].Equals(CellType.Nothing)) { resultMatrix[row, column] = CellType.Right; if (row != column) { resultMatrix[column, row] = CellType.Left; //ResultMatrix[Row, Column] = CellType.Left; } } } else if (footprint.HeaderWithEventNames[row].Equals(rightEventName) && footprint.HeaderWithEventNames[column].Equals(leftEventName)) { if (resultMatrix[row, column].Equals(CellType.Right)) resultMatrix[row, column] = CellType.Parallel; else if (resultMatrix[row, column].Equals(CellType.Nothing)){ resultMatrix[row, column] = CellType.Left; } else if (resultMatrix[row, column].Equals(CellType.Parallel)) resultMatrix[row, column] = CellType.Parallel; } } } } footprint.ResultMatrix = resultMatrix; return footprint; }
/// <summary> /// Create a footprint for a petrinet /// </summary> /// <param name="petriNet">Petrinet</param> /// <returns>returns a ComparingFootprint</returns> /// <autor>Andrej Albrecht</autor> public static ComparingFootprint CreateFootprint(PetriNet petriNet) { ComparingFootprint resultFootprint = new ComparingFootprint(new CellType[petriNet.Transitions.Count, petriNet.Transitions.Count]); foreach (Transition transition in petriNet.Transitions) { if (!transition.IsLoop) resultFootprint.AddEventHeader(transition.Name); } List<String> transitionLoops = Transition.GetTransitionLoops(petriNet); int indexRow = 0; foreach (String headerNameRow in resultFootprint.HeaderWithEventNames) { int indexColumn = 0; foreach (String headerNameColumn in resultFootprint.HeaderWithEventNames) { CellType transitionRelationship = GetTransitionRelationship(headerNameRow, headerNameColumn, petriNet); //reset the cellstate to nothing, if the cell have no state: resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Nothing; //save the found transition relationship to the cell and check parallelism with method checkTransitionParallel: if (headerNameRow.Equals(headerNameColumn) && transitionLoops.Contains(headerNameColumn)) { resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Loop; } else if (transitionRelationship.Equals(CellType.Parallel)) { resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Parallel; if (indexRow != indexColumn) resultFootprint.ResultMatrix[indexColumn, indexRow] = CellType.Parallel; } else if (transitionRelationship.Equals(CellType.Right)) { if (resultFootprint.ResultMatrix[indexRow, indexColumn].Equals(CellType.Left)) resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Parallel; resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Right; if (indexRow != indexColumn) resultFootprint.ResultMatrix[indexColumn, indexRow] = CellType.Left; } else if (transitionRelationship.Equals(CellType.Left)) { if (resultFootprint.ResultMatrix[indexRow, indexColumn].Equals(CellType.Right)) resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Parallel; resultFootprint.ResultMatrix[indexRow, indexColumn] = CellType.Left; } indexColumn++; } indexRow++; } return resultFootprint; }
public void ComparingFootprintFromPetriNetTest2() { //generate Footprint ComparingFootprint footprintResult = ComparingFootprintAlgorithm.CreateFootprint(PetriNetExample.PetriNetWithFivePlacesAndEightTransitions()); CellType[,] resultMatrix = footprintResult.ResultMatrix; List <String> headerNames = footprintResult.HeaderWithEventNames; if (headerNames.Count != 8) { Assert.Fail("ComparingFootprints header Names Count != 6"); } int y = 0; foreach (String hNameY in headerNames) { int x = 0; foreach (String hNameX in headerNames) { if (hNameY.Equals("A") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { //System.Diagnostics.Debug.WriteLine("Assert: " + hNameY + "->" + hNameX + " " + resultMatrix[y, x]); Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { //System.Diagnostics.Debug.WriteLine("Assert: " + hNameY + "->" + hNameX + " " + resultMatrix[y, x]); Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("F") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("G") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("F")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("G")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("H") && hNameX.Equals("H")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else { Assert.Fail("ComparingFootprintFromPetriNetTest2"); } x++; } y++; } }
/// <summary> /// Adds the event header from a given footprint /// </summary> /// <param name="footprint">A Footprint</param> /// <autor>Andrej Albrecht</autor> private void AddEventHeader(ComparingFootprint footprint) { foreach (String name in footprint.HeaderWithEventNames) AddEventHeader(name); }
public void ComparingFootprintFromPetriNetTest3() { ComparingFootprint footprintResult = new ComparingFootprint(); footprintResult = ComparingFootprintAlgorithm.CreateFootprint(PetriNetExample.PetriNetWithSixPlacesAndFiveTransitions()); CellType[,] resultMatrix = footprintResult.ResultMatrix; List <String> headerNames = footprintResult.HeaderWithEventNames; if (headerNames.Count != 5) { Assert.Fail("ComparingFootprints header Names Count != 6"); } int y = 0; foreach (String hNameY in headerNames) { int x = 0; foreach (String hNameX in headerNames) { if (hNameY.Equals("A") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("A") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("B") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("C") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Parallel)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("D") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("A")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("B")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("C")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("D")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else if (hNameY.Equals("E") && hNameX.Equals("E")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(hNameY + "->" + hNameX + " " + resultMatrix[y, x]); } } else { Assert.Fail("ComparingFootprintFromPetriNetTest3"); } x++; } y++; } }
public void ComparingFootprintFromPetriNetTest1() { ComparingFootprint footprintResult = ComparingFootprintAlgorithm.CreateFootprint(PetriNetExample.PetriNetWithFivePlacesAndFourTransitions()); CellType[,] resultMatrix = footprintResult.ResultMatrix; List <String> headerNames = footprintResult.HeaderWithEventNames; if (headerNames.Count != 4) { Assert.Fail(); } int y = 0; foreach (String hNameY in headerNames) { int x = 0; foreach (String hNameX in headerNames) { if (hNameY.Equals("TransitionA") && hNameX.Equals("TransitionA")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionA") && hNameX.Equals("TransitionB")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionA") && hNameX.Equals("TransitionC")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionA") && hNameX.Equals("TransitionD")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionB") && hNameX.Equals("TransitionA")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionB") && hNameX.Equals("TransitionB")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionB") && hNameX.Equals("TransitionC")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionB") && hNameX.Equals("TransitionD")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionC") && hNameX.Equals("TransitionA")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionC") && hNameX.Equals("TransitionB")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionC") && hNameX.Equals("TransitionC")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionC") && hNameX.Equals("TransitionD")) { if (!resultMatrix[y, x].Equals(CellType.Right)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionD") && hNameX.Equals("TransitionA")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionD") && hNameX.Equals("TransitionB")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionD") && hNameX.Equals("TransitionC")) { if (!resultMatrix[y, x].Equals(CellType.Left)) { Assert.Fail(); } } else if (hNameY.Equals("TransitionD") && hNameX.Equals("TransitionD")) { if (!resultMatrix[y, x].Equals(CellType.Nothing)) { Assert.Fail(); } } else { Assert.Fail("HNameY:" + hNameY + " HNameX:" + hNameX + " ResultMatrix[" + y + ", " + x + "]:" + resultMatrix[y, x]); } x++; } y++; } }