public void CopyNestedTest() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = true }; var activityF = new Activity("F", "somename6") { Included = true }; dcrGraph.AddActivity(activityC.Id, activityC.Name); dcrGraph.AddActivity(activityD.Id, activityD.Name); dcrGraph.AddActivity(activityE.Id, activityE.Name); dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddActivity(activityA.Id, activityA.Name); dcrGraph.AddActivity(activityB.Id, activityB.Name); dcrGraph.AddActivity(activityF.Id, activityF.Name); dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation //ingoing relations dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); var copy = dcrGraph.Copy(); Assert.AreEqual(dcrGraph.ToString(), copy.ToString()); }
public void FitnessOnNestedGraph() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = true }; var activityF = new Activity("F", "somename6") { Included = true }; dcrGraph.AddActivities(activityA,activityB,activityC,activityD,activityE,activityF); dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation //ingoing relations dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); var log = new Log(); log.AddTrace(new LogTrace('A', 'C','D')); log.AddTrace(new LogTrace('A', 'B', 'C')); log.AddTrace(new LogTrace('A', 'E', 'F')); log.AddTrace(new LogTrace('C', 'E','D')); //illegal trace should count down //expecting fitness = 75% var qd = UlrikHovsgaardAlgorithm.QualityMeasures.QualityDimensionRetriever.Retrieve(dcrGraph, log); Assert.AreEqual(75d, qd.Fitness); }
public void RedundantRemoverWithNested() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = true }; var activityF = new Activity("F", "somename6") { Included = true }; dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF); dcrGraph.AddIncludeExclude(true, activityC.Id,activityD.Id); dcrGraph.AddIncludeExclude(true, activityC.Id, activityE.Id); //Redundant include dcrGraph.AddCondition(activityE.Id,activityF.Id); //outgoing relation //ingoing relation dcrGraph.AddCondition(activityA.Id,activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.MakeNestedGraph(new HashSet<Activity>() {activityC, activityD, activityE}); var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph); //we check that the Nested graph has had the redundant relation removed. Assert.IsFalse(newGraph.InRelation(activityE,newGraph.IncludeExcludes)); }
public void RetrieveImageWithConditionRelationTest() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = false }; dcrGraph.AddActivities(activityA, activityB); dcrGraph.AddCondition(activityA.Id, activityB.Id); var img = GraphImageRetriever.Retrieve(dcrGraph).Result; Assert.IsNotNull(img); }
public void TestNonRedundantConditionIsNotRemoved() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = false }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; dcrGraph.Activities.Add(activityA); dcrGraph.Activities.Add(activityB); dcrGraph.Activities.Add(activityC); dcrGraph.AddCondition(activityB.Id, activityA.Id); dcrGraph.AddIncludeExclude(true, activityC.Id, activityA.Id); dcrGraph.AddIncludeExclude(true, activityB.Id, activityA.Id); var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph); Assert.IsTrue(newGraph.InRelation(activityB, newGraph.Conditions)); }
public void TestQualityDimensionsRetriever() { var graph = new DcrGraph(); graph.AddActivity("A", "somename1"); graph.AddActivity("B", "somename2"); graph.AddActivity("C", "somename3"); //graph.AddActivity("D", "somename3"); graph.SetIncluded(true, "A"); // Start at A graph.AddIncludeExclude(true, "A", "B"); graph.AddIncludeExclude(true, "B", "C"); graph.AddIncludeExclude(false, "C", "B"); graph.AddResponse("B", "C"); // Self-excludes graph.AddIncludeExclude(false, "A", "A"); graph.AddIncludeExclude(false, "B", "B"); graph.AddIncludeExclude(false, "C", "C"); graph.AddCondition("A", "B"); graph.AddMileStone("A", "B"); var someLog = new Log() { Traces = new List<LogTrace> { new LogTrace('A', 'B', 'C'), new LogTrace('A', 'C') } }; var res = QualityDimensionRetriever.Retrieve(graph, someLog); Console.WriteLine(graph); Console.WriteLine(res); var graph2 = new DcrGraph(); graph2.AddActivity("A", "somename1"); graph2.AddActivity("B", "somename2"); graph2.AddActivity("C", "somename3"); graph2.SetIncluded(true, "A"); graph2.SetIncluded(true, "B"); graph2.SetIncluded(true, "C"); res = QualityDimensionRetriever.Retrieve(graph2, someLog); Console.WriteLine(graph2); Console.WriteLine(res); var graph3 = new DcrGraph(); graph3.AddActivity("A", "somename1"); graph3.AddActivity("B", "somename2"); graph3.AddActivity("C", "somename3"); graph3.AddIncludeExclude(false, "A", "A"); graph3.AddIncludeExclude(false, "B", "B"); graph3.AddIncludeExclude(false, "C", "C"); graph3.AddIncludeExclude(false, "A", "B"); graph3.AddIncludeExclude(false, "B", "A"); graph3.AddIncludeExclude(false, "C", "A"); graph3.AddIncludeExclude(false, "C", "B"); graph3.AddIncludeExclude(false, "A", "C"); graph3.AddIncludeExclude(false, "B", "C"); graph3.AddResponse("A", "B"); graph3.AddResponse("A", "C"); graph3.AddResponse("B", "A"); graph3.AddResponse("B", "C"); graph3.AddResponse("C", "A"); graph3.AddResponse("C", "B"); graph3.AddCondition("A", "B"); graph3.AddCondition("A", "C"); graph3.AddCondition("B", "A"); graph3.AddCondition("B", "C"); graph3.AddCondition("C", "A"); graph3.AddCondition("C", "B"); graph3.AddMileStone("A", "B"); graph3.AddMileStone("A", "C"); graph3.AddMileStone("B", "A"); graph3.AddMileStone("B", "C"); graph3.AddMileStone("C", "A"); graph3.AddMileStone("C", "B"); res = QualityDimensionRetriever.Retrieve(graph3, someLog); Console.WriteLine(graph3); Console.WriteLine(res); // "Original" test log var activities = new HashSet<Activity>(); for (char ch = 'A'; ch <= 'F'; ch++) { activities.Add(new Activity("" + ch, "somename " + ch)); } var exAl = new ContradictionApproach(activities); var originalLog = new List<LogTrace>(); originalLog.Add(new LogTrace('A', 'B', 'E')); originalLog.Add(new LogTrace('A', 'C', 'F', 'A', 'B', 'B', 'F')); originalLog.Add(new LogTrace('A', 'C', 'E')); originalLog.Add(new LogTrace('A', 'D', 'F')); originalLog.Add(new LogTrace('A', 'B', 'F', 'A', 'B', 'E')); originalLog.Add(new LogTrace('A', 'C', 'F')); originalLog.Add(new LogTrace('A', 'B', 'F', 'A', 'C', 'F', 'A', 'C', 'E')); originalLog.Add(new LogTrace('A', 'B', 'B', 'B', 'F')); originalLog.Add(new LogTrace('A', 'B', 'B', 'E')); originalLog.Add(new LogTrace('A', 'C', 'F', 'A', 'C', 'E')); exAl.AddTrace(originalLog[0]); exAl.AddTrace(originalLog[1]); exAl.AddTrace(originalLog[2]); exAl.AddTrace(originalLog[3]); exAl.AddTrace(originalLog[4]); exAl.AddTrace(originalLog[5]); exAl.AddTrace(originalLog[6]); exAl.AddTrace(originalLog[7]); exAl.AddTrace(originalLog[8]); exAl.AddTrace(originalLog[9]); var log = new Log() {Traces = originalLog}; res = QualityDimensionRetriever.Retrieve(exAl.Graph, log); Console.WriteLine(exAl.Graph); Console.WriteLine(res); Console.WriteLine("Removing redundancy::::::::::::::::::::::::::::::::::"); exAl.Graph = new RedundancyRemover().RemoveRedundancy(exAl.Graph); res = QualityDimensionRetriever.Retrieve(exAl.Graph, log); Console.WriteLine(exAl.Graph); Console.WriteLine(res); Console.ReadLine(); }
public void TestConditionMilestoneRedundancy() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = false }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; dcrGraph.Activities.Add(activityA); dcrGraph.Activities.Add(activityB); dcrGraph.Activities.Add(activityC); dcrGraph.AddCondition(activityA.Id, activityB.Id); dcrGraph.AddMileStone(activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(true, activityC.Id, activityA.Id); dcrGraph.AddResponse(activityC.Id, activityA.Id); var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph); //Now either the redundant Condition or Milestone relation should be removed:"); Assert.IsFalse(newGraph.InRelation(activityA, newGraph.Conditions) && newGraph.InRelation(activityA, newGraph.Milestones)); }
public void TestIncludeConditionRedundancy() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = false }; dcrGraph.Activities.Add(activityA); dcrGraph.Activities.Add(activityB); dcrGraph.AddCondition(activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id); var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph); //Now the redundant condition relation from A to B should be removed: Assert.IsFalse(newGraph.InRelation(activityB, newGraph.Conditions)); }
public void TestActivityAlwaysExcludedRedundant() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = false }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; dcrGraph.Activities.Add(activityA); dcrGraph.Activities.Add(activityB); dcrGraph.Activities.Add(activityC); dcrGraph.AddCondition(activityA.Id, activityB.Id); dcrGraph.AddMileStone(activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(false, activityA.Id, activityC.Id); dcrGraph.AddResponse(activityA.Id, activityB.Id); dcrGraph.AddResponse(activityB.Id, activityA.Id); var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph); //Now all the relations from or to A should be removed:"); Assert.IsTrue(!newGraph.InRelation(activityA, newGraph.Conditions) && !newGraph.InRelation(activityA, newGraph.IncludeExcludes) && !newGraph.InRelation(activityA, newGraph.Responses) && !newGraph.InRelation(activityA, newGraph.Milestones)); }
public void TestAlwaysIncludeIncludedRedundant() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = false }; dcrGraph.Activities.Add(activityA); dcrGraph.Activities.Add(activityB); dcrGraph.Activities.Add(activityC); dcrGraph.AddCondition(activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(true, activityB.Id, activityC.Id); dcrGraph.AddIncludeExclude(true, activityA.Id, activityC.Id); var newDcr = new RedundancyRemover().RemoveRedundancy(dcrGraph); //we should now have removed include b -> c. so we are asserting that B no longer has a include relation Assert.IsFalse(newDcr.GetIncludeOrExcludeRelation(activityB, true).Contains(activityC)); }
public void ParseMortgageApplication2() { var graph = new DcrGraph(); graph.AddActivities(new Activity("Collect Documents", "Collect Documents") { Included = true, Roles = "Caseworker" }); graph.AddIncludeExclude(false, "Collect Documents", "Collect Documents"); graph.AddActivities(new Activity("Irregular neighbourhood", "Irregular neighbourhood") { Included = true, Roles = "it" }); graph.AddIncludeExclude(false, "Irregular neighbourhood", "Irregular neighbourhood"); graph.AddActivities(new Activity("Make appraisal appointment", "Make appraisal appointment") { Included = true, Roles = "Mobile consultant" }); graph.AddIncludeExclude(false, "Make appraisal appointment", "Make appraisal appointment"); graph.AddActivities(new Activity("Appraisal audit", "Appraisal audit") { Included = true, Roles = "Auditor" }); graph.AddIncludeExclude(false, "Appraisal audit", "Appraisal audit"); graph.AddActivities(new Activity("On-site appraisal", "On-site appraisal") { Included = true, Roles = "Mobile consulant" }); graph.AddIncludeExclude(false, "On-site appraisal", "On-site appraisal"); graph.AddActivities(new Activity("Submit budget", "Submit budget") { Included = true, Roles = "Customer" }); graph.AddIncludeExclude(false, "Submit budget", "Submit budget"); graph.AddActivities(new Activity("Budget screening approve", "Budget screening approve") { Included = true, Pending = true, Roles = "Intern" }); graph.AddIncludeExclude(false, "Budget screening approve", "Budget screening approve"); graph.AddActivities(new Activity("Statistical appraisal", "Statistical appraisal") { Included = true, Roles = "Caseworker" }); graph.AddIncludeExclude(false, "Statistical appraisal", "Statistical appraisal"); graph.AddActivities(new Activity("Assess loan application", "Assess loan application") { Included = true, Pending = true, Roles = "Caseworker" }); graph.AddIncludeExclude(false, "Assess loan application", "Assess loan application"); graph.AddCondition("Collect Documents", "Irregular neighbourhood"); graph.AddCondition("Collect Documents", "Make appraisal appointment"); graph.AddCondition("Collect Documents", "On-site appraisal"); graph.AddCondition("Collect Documents", "Statistical appraisal"); graph.AddIncludeExclude(false, "Statistical appraisal", "Irregular neighbourhood"); graph.AddIncludeExclude(false, "Statistical appraisal", "Make appraisal appointment"); graph.AddIncludeExclude(false, "Statistical appraisal", "On-site appraisal"); graph.AddIncludeExclude(false, "Irregular neighbourhood","Statistical appraisal"); graph.AddIncludeExclude(false, "Make appraisal appointment","Statistical appraisal" ); graph.AddIncludeExclude(false, "On-site appraisal","Statistical appraisal"); graph.AddCondition("Irregular neighbourhood", "Make appraisal appointment"); graph.AddCondition("Make appraisal appointment", "On-site appraisal"); graph.AddCondition("On-site appraisal", "Submit budget"); graph.AddCondition("Submit budget", "Budget screening approve"); graph.AddCondition("Budget screening approve", "Assess loan application"); graph.AddCondition("Assess loan application","Appraisal audit"); graph.AddCondition("Statistical appraisal", "Submit budget"); var nested = new HashSet<Activity>(); nested.Add(graph.GetActivity("Irregular neighbourhood")); nested.Add(graph.GetActivity("Make appraisal appointment")); nested.Add(graph.GetActivity("On-site appraisal")); graph.MakeNestedGraph(nested); //LogGenerator9001 logGenerator9001 = new LogGenerator9001(20, graph); //Log log = new Log(); //foreach (var trace in logGenerator9001.GenerateLog(500)) //{ // log.AddTrace(trace); //} using (StreamWriter sw = new StreamWriter("C:/Downloads/mortgageStrict.xml")) { sw.WriteLine(graph.ExportToXml()); } }
public void SomeTestForFindingTracesBeforeAfterStuff() { var dcr = new DcrGraph(); dcr.AddActivities(new Activity("A", "A"), new Activity("B", "B"), new Activity("C", "C")); dcr.AddCondition("A", "B"); dcr.AddCondition("A", "C"); dcr.AddCondition("B", "C"); dcr.SetIncluded(true, "A"); dcr.SetIncluded(true, "B"); dcr.SetIncluded(true, "C"); dcr.SetPending(true, "C"); var traceFinder = new UniqueTraceFinder(new ByteDcrGraph(dcr)); dcr = dcr.Copy(); dcr.RemoveCondition("A", "B"); traceFinder = new UniqueTraceFinder(new ByteDcrGraph(dcr)); }
public void CreateNestsTest() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true, Pending = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = true }; var activityE = new Activity("E", "somename5") { Included = true, Pending = true }; var activityF = new Activity("F", "somename6") { Included = true }; var activityG = new Activity("G", "somename7") { Included = true }; dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF, activityG); dcrGraph.AddResponse(activityB.Id, activityC.Id); //inner nest condition //From A to all inner dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(false, activityA.Id, activityC.Id); dcrGraph.AddIncludeExclude(false, activityA.Id, activityD.Id); dcrGraph.AddIncludeExclude(false, activityA.Id, activityE.Id); dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(false, activityD.Id, activityF.Id); //from in to out dcrGraph.AddMileStone(activityF.Id, activityG.Id); //From G to all inner and F dcrGraph.AddCondition(activityG.Id, activityB.Id); dcrGraph.AddCondition(activityG.Id, activityC.Id); dcrGraph.AddCondition(activityG.Id, activityD.Id); dcrGraph.AddCondition(activityG.Id, activityE.Id); dcrGraph.AddCondition(activityG.Id, activityF.Id); var exhaust = new ContradictionApproach(dcrGraph.Activities) { Graph = dcrGraph }; exhaust.Graph = ContradictionApproach.CreateNests(exhaust.Graph); Assert.IsTrue(exhaust.Graph.Activities.Any(a => a.IsNestedGraph)); }
public void SimplicityOnNestedGraph() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true, Pending = true}; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = false }; var activityF = new Activity("F", "somename6") { Included = false }; dcrGraph.AddActivities(activityA, activityC, activityD, activityE, activityF); //ingoing relations dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.AddCondition(activityC.Id, activityE.Id); //inside nested relation dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddIncludeExclude(true, activityD.Id, activityE.Id); dcrGraph.AddIncludeExclude(true, activityE.Id, activityF.Id); //outgoing relation dcrGraph.AddIncludeExclude(false, activityA.Id, activityA.Id); dcrGraph.AddIncludeExclude(false, activityC.Id, activityC.Id); dcrGraph.AddIncludeExclude(false, activityD.Id, activityD.Id); dcrGraph.AddIncludeExclude(false, activityE.Id, activityE.Id); //F can be run more than once dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); var log = new Log(); log.AddTrace(new LogTrace('A', 'C', 'D', 'E', 'F')); log.AddTrace(new LogTrace('A', 'C', 'D', 'E', 'E')); //S1 = amount of relations (9) / amount of possible relations n=6 (4n^2 - 3n = 126) = 9/126 //S2 = amount of coupled relations (9) / possible coupled relations (n^2 = 36) = 0,25 //S3 = amount of pending activities 1 / all activities (5) = 0,2 (pending activities should not count the nested graph) const double totalRelationsPart = (1.0 - 9.0 / 126.0) / 2; // 50 % weight const double relationCouplesPart = (1.0 - 9.0 / 21.0) / 2; // 50 % weight const double pendingPart = (1.0 / 5.0) * 0.1; // 10 % possible negative weight const double nestedPart = (1.0 / 5) * 0.2; // 20 % possible negative weight //expecting simplicity: 1 - ((9/126)*0,45 + 0,25*0,45 + 0,2 * 0,10) const double expected = (totalRelationsPart + relationCouplesPart - pendingPart - nestedPart) * 100.0; var qd = UlrikHovsgaardAlgorithm.QualityMeasures.QualityDimensionRetriever.Retrieve(dcrGraph, log); Assert.AreEqual(expected, qd.Simplicity); }
public void GetConditionsTest() { var dcr = new DcrGraph(); var nested = new DcrGraph(); nested.AddActivities(new Activity("C", ""), new Activity("D", "")); nested.AddCondition("C", "D"); var nestedAct = new Activity("N", "", nested); dcr.AddActivities(new Activity("A", ""), new Activity("B", ""), nestedAct); dcr.AddCondition("A", "B"); var allConditions = dcr.GetConditions(); Assert.AreEqual(2, allConditions.Count); }
public void PrecisionOnNestedGraph() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = false }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = false }; var activityF = new Activity("F", "somename6") { Included = false }; dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF); //ingoing relations dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.AddCondition(activityC.Id, activityE.Id); dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddIncludeExclude(true, activityD.Id, activityE.Id); dcrGraph.AddIncludeExclude(true, activityE.Id, activityF.Id); //outgoing relation dcrGraph.AddIncludeExclude(false, activityA.Id, activityA.Id); dcrGraph.AddIncludeExclude(false, activityC.Id, activityC.Id); dcrGraph.AddIncludeExclude(false, activityD.Id, activityD.Id); dcrGraph.AddIncludeExclude(false, activityE.Id, activityE.Id); //F can be run more than once dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); var log = new Log(); log.AddTrace(new LogTrace('A', 'C', 'D', 'E', 'F')); // we don't execute 'F' twice log.AddTrace(new LogTrace('A', 'C', 'D', 'E', 'E')); //we illegally execute E //legal activities executed pr. state = 5 // divided by illegal executed activities (1) + legal activities that could be executed (5 + 1) (F could be executed again.) //expecting precision 5/7 var qd = UlrikHovsgaardAlgorithm.QualityMeasures.QualityDimensionRetriever.Retrieve(dcrGraph, log); Assert.AreEqual((5d/7d)*100, qd.Precision); }
public void MakeNestedGraphTest() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = false }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = true }; var activityF = new Activity("F", "somename6") { Included = true }; dcrGraph.AddActivity(activityC.Id, activityC.Name); dcrGraph.AddActivity(activityD.Id, activityD.Name); dcrGraph.AddActivity(activityE.Id, activityE.Name); dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddActivity(activityA.Id, activityA.Name); dcrGraph.AddActivity(activityB.Id, activityB.Name); dcrGraph.AddActivity(activityF.Id, activityF.Name); dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation //ingoing relation dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); //we check that the Nested graph exists Assert.IsTrue(dcrGraph.Activities.Any(a => a.IsNestedGraph)); }
public void GetRelationCountTest() { DcrGraph dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true, Pending = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = false }; dcrGraph.AddActivities(activityA, activityB, activityC); dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id); dcrGraph.AddIncludeExclude(true, activityB.Id, activityC.Id); dcrGraph.AddIncludeExclude(false, activityB.Id, activityB.Id); dcrGraph.AddCondition(activityB.Id, activityC.Id); //non-sensical condition dcrGraph.AddCondition(activityB.Id, activityB.Id); dcrGraph.AddMileStone(activityA.Id, activityC.Id); dcrGraph.AddResponse(activityA.Id, activityC.Id); Assert.AreEqual(6, dcrGraph.GetRelationCount); }
public void GetNestedActivityTest() { var dcrGraph = new DcrGraph(); var activityA = new Activity("A", "somename1") { Included = true }; var activityB = new Activity("B", "somename2") { Included = true }; var activityC = new Activity("C", "somename3") { Included = true }; var activityD = new Activity("D", "somename4") { Included = false }; var activityE = new Activity("E", "somename5") { Included = true }; var activityF = new Activity("F", "somename6") { Included = true }; dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF); dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id); dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation //ingoing relations dcrGraph.AddCondition(activityA.Id, activityC.Id); dcrGraph.AddCondition(activityA.Id, activityD.Id); dcrGraph.AddCondition(activityA.Id, activityE.Id); dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE }); var retrievedActivity = dcrGraph.GetActivity(activityC.Id); Assert.AreEqual(activityC.ToString(), retrievedActivity.ToString()); }
private static void ParseRelations(DcrGraph graph, XDocument doc) { foreach (var condition in doc.Descendants("conditions").Elements()) { graph.AddCondition(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value); } foreach (var condition in doc.Descendants("responses").Elements()) { graph.AddResponse(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value); } foreach (var condition in doc.Descendants("excludes").Elements()) { graph.AddIncludeExclude(false, condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value); } foreach (var condition in doc.Descendants("includes").Elements()) { graph.AddIncludeExclude(true, condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value); } foreach (var condition in doc.Descendants("milestones").Elements()) { graph.AddMileStone(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value); } }
public static DcrGraph ParseDreyerLog() { var graph = new DcrGraph(); graph.AddActivities(new Activity("Execute abandon", "Execute abandon") {Included = true, Roles = "Caseworker"}); graph.AddActivities(new Activity("Change phase to abandon", "Change phase to abandon") { Included = true, Roles = "Nobody" }); graph.AddActivities(new Activity("Round ends", "Round ends") {Included = true, Pending = false, Roles = "it"}); graph.AddActivities(new Activity("Fill out application", "Fill out application") { Included = true, Pending = false, Roles = "Nobody" }); graph.AddActivities(new Activity("End", "End") { Included = true, Pending = false, Roles = "*" }); graph.AddActivities(new Activity("Screening approve", "Screening approve") { Included = true, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("File architect", "File architect") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Screening reject", "Screening reject") { Included = true, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("File lawyer", "File lawyer") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Review 1", "Review 1") { Included = true, Pending = false, Roles = "lawyer" }); graph.AddActivities(new Activity("Review 2", "Review 2") { Included = true, Pending = false, Roles = "architect" }); graph.AddActivities(new Activity("Review 3", "Review 3") { Included = true, Pending = false, Roles = "lawyer" }); graph.AddActivities(new Activity("Review 4", "Review 4") { Included = true, Pending = false, Roles = "architect" }); graph.AddActivities(new Activity("Round approved", "Round approved") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Set pre-approved", "Set pre-approved") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Inform approve", "Inform approve") { Included = true, Pending = false, Roles = "casework" }); graph.AddActivities(new Activity("Receive end report", "Receive end report") { Included = true, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("Payout", "Payout") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Payout complete", "Payout complete") { Included = true, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Undo payout", "Undo payout") { Included = true, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("Reject application", "Reject application") { Included = true, Pending = false, Roles = "board" }); graph.AddActivities(new Activity("Approve application", "Approve application") { Included = true, Pending = false, Roles = "board" }); graph.AddActivities(new Activity("Note decision", "Note decision") { Included = true, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("Account no changed", "Account no changed") { Included = false, Pending = false, Roles = "it" }); graph.AddActivities(new Activity("Approve account no", "Approve account no") { Included = true, Pending = false, Roles = "accountant" }); graph.AddActivities(new Activity("Guard", "Guard") { Included = true, Pending = true, Roles = "*" }); //Should abort be included??? graph.AddActivities(new Activity("Abort application", "Abort application") { Included = false, Pending = false, Roles = "caseworker" }); graph.AddActivities(new Activity("Inform reject", "Inform reject") { Included = false, Pending = false, Roles = "caseworker"}); graph.AddActivities(new Activity("Purge application", "Purge application") { Included = false, Pending = false, Roles = "it" }); graph.AddIncludeExclude(false, "File architect", "File lawyer"); graph.AddIncludeExclude(false, "File lawyer", "File architect"); graph.AddCondition("Approve application", "Note decision"); graph.AddCondition("Reject application", "Note decision"); graph.AddIncludeExclude(false, "Payout", "Payout"); graph.AddCondition("Payout", "Undo payout"); graph.AddIncludeExclude(true, "Undo payout", "Payout"); graph.AddResponse("Undo payout", "Payout"); graph.AddResponse("Payout", "Payout complete"); graph.AddIncludeExclude(false, "Payout complete", "Undo payout"); graph.AddMileStone("Payout", "Payout complete"); graph.AddCondition("Abort application", "Inform reject"); graph.AddResponse("Abort application", "Inform reject"); graph.AddCondition("Inform reject", "Purge application"); graph.AddResponse("Inform reject", "Purge application"); graph.AddIncludeExclude(true, "Screening reject", "Inform reject"); graph.AddIncludeExclude(true, "Reject application", "Inform reject"); graph.AddIncludeExclude(false, "Screening approve", "Screening reject"); graph.AddCondition("Screening approve", "File lawyer"); graph.AddCondition("Screening approve", "File architect"); graph.AddCondition("File lawyer", "Review 1"); graph.AddCondition("File lawyer", "Review 2"); graph.AddCondition("File lawyer", "Review 3"); graph.AddCondition("File lawyer", "Review 4"); graph.AddCondition("File architect", "Review 1"); graph.AddCondition("File architect", "Review 2"); graph.AddCondition("File architect", "Review 3"); graph.AddCondition("File architect", "Review 4"); graph.AddIncludeExclude(false, "File architect", "Review 1"); graph.AddIncludeExclude(false, "File lawyer", "Review 2"); graph.AddCondition("Fill out application", "Screening approve"); graph.AddCondition("Fill out application", "Screening reject"); graph.AddResponse("Fill out application", "Payout"); graph.AddCondition("Review 3", "Approve application"); graph.AddCondition("Review 4", "Approve application"); graph.AddCondition("Review 3", "Reject application"); graph.AddCondition("Review 4", "Reject application"); graph.AddCondition("Inform approve", "Payout"); graph.AddCondition("Inform approve", "Receive end report"); graph.AddResponse("Approve application", "Set pre-approved"); graph.AddIncludeExclude(true, "Set pre-approved", "Abort application"); graph.AddCondition("Payout", "Receive end report"); graph.AddMileStone("Payout", "Receive end report"); graph.AddIncludeExclude(false, "Round approved", "Set pre-approved"); graph.AddResponse("Round approved", "Approve application"); graph.AddResponse("Round approved", "Reject application"); graph.AddResponse("Round approved", "Set pre-approved"); graph.AddResponse("Account no changed", "Approve account no"); graph.AddCondition("Account no changed", "Approve account no"); graph.AddMileStone("Approve account no", "Payout"); graph.AddIncludeExclude(false, "Payout", "Abort application"); graph.AddIncludeExclude(false, "Payout", "Account no changed"); graph.AddIncludeExclude(true, "Reject application", "Inform reject"); graph.AddCondition("Approve application", "Set pre-approved"); graph.AddCondition("Approve application", "Inform approve"); graph.AddIncludeExclude(false, "Inform approve", "Review 1"); graph.AddIncludeExclude(false, "Inform approve", "Review 2"); graph.AddIncludeExclude(false, "Inform approve", "Review 3"); graph.AddIncludeExclude(false, "Inform approve", "Review 4"); graph.AddIncludeExclude(false, "Inform approve", "Approve application"); graph.AddIncludeExclude(false, "Inform approve", "Reject application"); graph.AddIncludeExclude(false, "Inform approve", "Note decision"); graph.AddIncludeExclude(false, "Inform approve", "Abort application"); graph.AddCondition("Inform approve", "Payout"); graph.AddCondition("Inform approve", "Receive end report"); graph.AddResponse("Approve application", "Set pre-approved"); graph.AddCondition("Payout", "Receive end report"); graph.AddMileStone("Payout", "Receive end report"); graph.AddResponse("Approve application", "Payout"); graph.AddIncludeExclude(true,"Approve application", "Approve account no"); graph.AddIncludeExclude(true, "Set pre-approved", "Approve account no"); graph.AddIncludeExclude(false, "Receive end report", "Guard"); graph.AddIncludeExclude(false, "Inform reject", "Guard"); graph.AddCondition("Guard","Guard"); graph.AddCondition("Guard", "End"); graph.AddResponse("Fill out application","End"); return graph; }