public void ToStringTest()
        {
            var event1 = new Event("A");
            var node = new EventNode(event1, 0.8);

            Assert.AreEqual("A", node.ToString());
        }
 /// <summary>
 /// Constructor for a tree node
 /// </summary>
 /// <param name="inductiveMiner"></param>
 /// <param name="operation">node operation</param>
 /// <param name="associatedEvent"></param>
 /// <param name="right"></param>
 /// <param name="left"></param>
 /// <author>Thomas Meents, Bernd Nottbeck</author>
 public InductiveMinerTreeNode(InductiveMiner inductiveMiner, OperationsEnum operation, Event associatedEvent = null, InductiveMinerTreeNode right = null, InductiveMinerTreeNode left = null)
 {
     Operation = operation;
     LeftLeaf = left;
     RightLeaf = right;
     Event = associatedEvent;
     petriNet = inductiveMiner.IMPetriNet;
 }
        /// <summary>
        /// Constructor for an graph node object
        /// </summary>
        /// <param name="name">associated event</param>
        ///  <author>Bernd Nottbeck</author>
        public InductiveMinerGraphNode(Event name)
        {
            threshHold = MinerSettings.GetAsDouble("InductiveThresholdSlider");

            Name = name;
            FollowerList = new List<InductiveMinerRow>();
            EventualFollowerList = new List<InductiveMinerRow>();
        }
        private EventLog createEventLogFrom(string sourceFile)
        {
            //The Method should return a list with EventLogs!

            EventLog eventLog = new EventLog(Path.GetFileName(sourceFile));
            Case caseFound = new Case();
            Event eventFound = new Event();

            String theActualElement = "";

            XmlTextReader reader = new XmlTextReader(sourceFile);
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // The node is an element.
                        theActualElement = reader.Name.ToLower();

                        if (reader.Name.ToLower().Equals("processinstance"))
                        {
                            //A new Case starts
                            caseFound = new Case(reader.GetAttribute("id"));
                        }
                        else if (reader.Name.ToLower().Equals("audittrailentry"))
                        {
                            //A new transition starts
                            eventFound = new Event();
                        }

                        break;
                    case XmlNodeType.Text: //Display the text in each element.
                        if (theActualElement.Equals("workflowmodelelement"))
                        {
                            eventFound.Name = reader.Value;
                        }
                        else if (theActualElement.Equals("timestamp"))
                        {
                            eventFound.Information.Add("TIMESTAMP", reader.Value);
                        }
                        break;
                    case XmlNodeType.EndElement: //Display the end of the element.
                        if (reader.Name.ToLower().Equals("processinstance"))
                        {
                            //The case ends in the mxml file and the case must put to the eventlog
                            eventLog.Cases.Add(caseFound);
                        }
                        else if (reader.Name.ToLower().Equals("audittrailentry"))
                        {
                            //The transition ends here
                            caseFound.EventList.Add(eventFound);
                        }

                        break;
                }
            }

            return eventLog;
        }
        public void EventNodeTest()
        {
            var event1 = new Event("A");
            var node = new EventNode(event1, 0.8);

            Assert.AreEqual("A", node.InnerEvent.Name);
            Assert.AreEqual(0.8, node.Adjacency);
            Assert.IsNotNull(node.ListOfFollowers);
        }
        public void EventConstructorTest1()
        {
            Event e = new Event();
            Assert.AreEqual("", e.Name);

            e.Name = "1234Test";
            Assert.AreEqual("1234Test", e.Name);

            if (e.Information.Count != 0) Assert.Fail("Event Information.Count != 0");
        }
 /// <summary>
 /// Initialize the InductiveMiner instance.
 /// </summary>
 /// <param name="field">Corresponding field</param>
 /// <author>Krystian Zielonka, Thomas Meents, Bernd Nottbeck</author>
 public InductiveMiner(Field field)
 {
     _field = field;
     DirectRowList = new List<InductiveMinerRow>();
     EventDictionary = new Dictionary<Event, InductiveMinerGraphNode>();
     IMPetriNet = new PetriNet(_field.Infotext);
     StartEvent = new Event("StartEvent");
     EndEvent = new Event("EndEvent");
     EventuallyRowList = new List<InductiveMinerRow>();
 }
        public void FindNodeTest()
        {
            var event1 = new Event("A");
            var event2 = new Event("B");
            var event3 = new Event("C");

            var eventNode = new EventNode(event1, 0.8, new List<EventNode> { new EventNode(event2, 0.8, new List<EventNode> { new EventNode(event3, 0.8) }) });

            Assert.AreEqual("C", eventNode.FindNode("C").InnerEvent.Name);
            Assert.IsNull(eventNode.FindNode("D"));
        }
 public void EventFollowsEventTest()
 {
     EventLog log = ExampleData.EventLogExample.OneCaseEventLog();
     Event first = new Event();
     Event second = new Event();
     foreach (Case cases in log.Cases)
     {
         first = cases.EventList.First();
         second = cases.EventList.Last();
         break;
     }
     Assert.IsTrue(log.EventFollowsEvent(first, second) == 1,"Count: " + log.EventFollowsEvent(first, second));
 }
 /// <summary>
 /// Constructor for a tree node´used duringt the cutting process.
 /// </summary>
 /// <param name="petriNet"></param>
 /// <param name="graphNode"></param>
 /// <param name="startEvent"></param>
 public InductiveMinerTreeNode(PetriNet petriNet, InductiveMinerGraphNode graphNode, Event startEvent)
 {
     GraphNode = graphNode;
     Operation = GraphNode.FollowerList.Count == 0 ? OperationsEnum.isLeaf : OperationsEnum.isUnkown;
     Event = GraphNode.Name;
     LeftLeaf = null;
     RightLeaf = null;
     this.startEvent = startEvent;
     visitedNodes = new HashSet<InductiveMinerGraphNode>();
     visitedLoopCheckNodes = new HashSet<InductiveMinerGraphNode>();
     this.petriNet = petriNet;
     newStart = new InductiveMinerGraphNode(new Event("NewStart"));
     DivideAndConquer();
 }
        public void EventEqualsTest()
        {
            Event e = new Event("Test");
            Event e2 = new Event("Test2");
            Event e3 = new Event("Test2");

            if (e.Equals(e2))
            {
                Assert.Fail("Event.equals check failed!");
            }

            if (!e2.Equals(e3))
            {
                Assert.Fail("Event.equals check failed!");
            }
        }
        public void CreateDependencyGraphTest()
        {
            var field = new Field { EventLog = EventLogExample.ThreeCaseEventLog() };
            var miner = new HeuristicMiner(field);
            var event1 = new Event("A");
            var event2 = new Event("B");
            var event3 = new Event("C");
            var eventList = new List<Event> { event1, event2, event3 };
            var matrix = new[,] { { 0.0, 0.8, 0.0 }, { 0.0, 0.0, 0.8 }, { 0.0, 0.0, 0.0 } };

            var actual = miner.CreateDependencyGraph(eventList, matrix, 0.5, 0.0, 0, 10);

            var expected = new EventNode(event1, 0.8, new List<EventNode> { new EventNode(event2, 0.8, new List<EventNode> { new EventNode(event3, 0.8) }) });

            Assert.AreEqual(expected.InnerEvent, actual.InnerEvent);
            Assert.AreEqual(expected.ListOfFollowers[0].InnerEvent, actual.ListOfFollowers[0].InnerEvent);
            Assert.AreEqual(expected.ListOfFollowers[0].ListOfFollowers[0].InnerEvent, actual.ListOfFollowers[0].ListOfFollowers[0].InnerEvent);
        }
        public void CaseAddEventTest1()
        {
            List<Event> eventList = new List<Event> {new Event("A")};

            //create Case and add event a
            Case ca = new Case("CaseName", eventList);

            //add event b
            ca.CreateEvent("B");

            //add event c
            ca.EventList.Add(new Event("C"));

            //add event d
            Event eventD = new Event {Name = "D"};
            ca.EventList.Add(eventD);

            foreach (Event e in ca.EventList)
            {
                if (e.Name.Equals("A"))
                {

                }
                else if (e.Name.Equals("B"))
                {

                }
                else if (e.Name.Equals("C"))
                {

                }
                else if (e.Name.Equals("D"))
                {

                }
                else
                {
                    Assert.Fail("Event not in case");
                }
            }
        }
Example #14
0
 /// <summary>
 /// Returns how often e1 is followed by e2.
 /// </summary>
 /// <param name="event1">The first event</param>
 /// <param name="event2">The second event, which must follow the first event directly</param>
 /// <returns>The count of what IndexesOfPair returns.</returns>
 /// <author>Jannik Arndt</author>
 public int EventFollowsEventCount(Event event1, Event event2)
 {
     return IndexesOfPair(event1, event2).Count;
 }
 /// <summary>
 /// Count how often e2 follows e1.
 /// </summary>
 /// <param name="event1"></param>
 /// <param name="event2"></param>
 /// <returns></returns>
 /// <author>Jannik Arndt</author>
 public int EventFollowsEvent(Event event1, Event event2)
 {
     return Cases.Sum(Case => Case.EventFollowsEventCount(event1, event2));
 }
 /// <summary>
 /// Calculates whether b and c (both followers of a) are in an XOR-relation.
 /// </summary>
 /// <param name="a">First event</param>
 /// <param name="b">Second event</param>
 /// <param name="c">Third event</param>
 /// <param name="log">The current event log</param>
 /// <returns></returns>
 /// <author>Jannik Arndt</author>
 public bool IsXorRelation(Event a, Event b, Event c, EventLog log)
 {
     return !IsAndRelation(a, b, c, log);
 }
 /// <summary>
 /// Calculates whether b and c (both followers of a) are in an AND-relation.
 /// </summary>
 /// <param name="a">Event a</param>
 /// <param name="b">Event b</param>
 /// <param name="c">Event c</param>
 /// <param name="log">The current event log</param>
 /// <returns>Returns a result bigger than 0.1</returns>
 /// <author>Jannik Arndt</author>
 public bool IsAndRelation(Event a, Event b, Event c, EventLog log)
 {
     var result = Convert.ToDouble(log.EventFollowsEvent(b, c) + log.EventFollowsEvent(c, b)) / Convert.ToDouble(log.EventFollowsEvent(a, b) + log.EventFollowsEvent(a, c) + 1);
     return result > 0.1;
 }
        /// <summary>
        /// Calculates the adjacency of two events in a given EventLog. Called by CreateAdjacencyMatrix()
        /// </summary>
        /// <param name="event1">First Event</param>
        /// <param name="event2">Second Event</param>
        /// <param name="log">The EventLog to be searched</param>
        /// <returns>The adjacency of two events in an eventlog</returns>
        /// <author>Jannik Arndt</author>
        public double GetAdjacency(Event event1, Event event2, EventLog log)
        {
            if (event1 == null)
                throw new ArgumentNullException("event1", "The given arguments are not valid");
            if (event2 == null)
                throw new ArgumentNullException("event2", "The given arguments are not valid");
            if (log == null)
                throw new ArgumentNullException("log", "The given arguments are not valid");

            var event1ToEvent2 = log.EventFollowsEvent(event1, event2);
            var event2ToEvent1 = log.EventFollowsEvent(event2, event1);
            return Convert.ToDouble(event1ToEvent2 - event2ToEvent1) / Convert.ToDouble(event1ToEvent2 + event2ToEvent1 + 1);
        }
 public void ToStringTest()
 {
     Event ev = new Event { Name = "Event" };
     Assert.IsTrue(ev.Name == ev.ToString());
 }
        /// <summary>
        /// Checks the DirectRowList if a row from event A to event B exists. If not a new row is created, else the directly follow count is increased by one.
        /// </summary>
        /// <param name="fromEvent">From event A</param>
        /// <param name="toEvent">To event B</param>
        /// <author>Bernd Nottbeck</author>
        protected void CheckAddRowEventDic(Event fromEvent, Event toEvent)
        {
            if (!EventDictionary.ContainsKey(toEvent))
                EventDictionary.Add(toEvent, new InductiveMinerGraphNode(toEvent));

            InductiveMinerRow currentRow;

            var query = from SearchRow in DirectRowList
                        where SearchRow.FromNode == EventDictionary[fromEvent] && SearchRow.ToNode == EventDictionary[toEvent]
                        select SearchRow;

            currentRow = query.FirstOrDefault();

            if (currentRow != null)
            {
                currentRow.Count++;
            }
            else
            {
                DirectRowList.Add(new InductiveMinerRow(EventDictionary[fromEvent], EventDictionary[toEvent]));
            }
        }
        /// <summary>
        /// Reads the Events from the Database and returns a DataSet.
        /// </summary>
        /// <returns>A list of Fact-objects.</returns>
        /// <author>Jannik Arndt, Bernd Nottbeck</author>
        public List<List<Case>> GetFacts(string sqlcode)
        {
            var listOfFacts = new List<List<Case>>();

            try
            {
                // Loads a list of all facts and then converts it into fact-, case- and event-objects.
                Open();

                var factDataTable = GetFactDataTable(sqlcode);

                var currentFactID = "";
                var currentCaseID = "";
                List<Case> currentFact = null;
                Case currentCase = null;

                // iterate over the FactDataTable: object with the same fact_id will be combined into one fact-object.
                foreach (DataRow row in factDataTable.Rows)
                {
                    // 1. Did a new fact start?
                    if (currentFactID != row[ColumnNameFactID].ToString())
                    {
                        // save the current one
                        if (currentFact != null)
                            listOfFacts.Add(currentFact);

                        // and create a new one
                        currentFactID = row[ColumnNameFactID].ToString();
                        currentFact = new List<Case>();
                    }

                    // 2. Did a new case start?
                    if (currentCaseID != row[ColumnNameCaseID].ToString())
                    {
                        currentCaseID = row[ColumnNameCaseID].ToString();
                        currentCase = new Case(currentCaseID);
                        currentCase.AdditionalData.Add(ColumnNameFactID, row[ColumnNameFactID].ToString());
                        if (Settings.Default.JoinAllDimensions)
                            foreach (var dimension in DBWorker.MetaData.ListOfFactDimensions)
                                if (!dimension.IsEmptyDimension)
                                    currentCase.AdditionalData.Add(dimension.ToTable, row[dimension.ToTable].ToString());

                        if (currentFact != null)
                            currentFact.Add(currentCase);
                    }

                    // 3. create an event and add it to the case
                    var currentEvent = new Event(row[DBWorker.MetaData.EventClassifier].ToString());
                    foreach (var columnName in DBWorker.MetaData.ListOfEventsTableColumnNames)
                        currentEvent.Information.Add(columnName, row[columnName].ToString());

                    if (currentCase != null)
                        currentCase.EventList.Add(currentEvent);
                }
                // since the last case and fact are not saved yet, we need to do this now.
                listOfFacts.Add(currentFact);

                return listOfFacts;
            }
            finally
            {
                Close();
            }
        }
 public void EventConstructorTest2()
 {
     Event e = new Event("Test");
     Assert.AreEqual("Test", e.Name);
 }
 public void EventFollowsEventCountTest()
 {
     Case ca = new Case();
     Event ev1 = new Event {Name = "first"};
     Event ev2 = new Event {Name = "second"};
     ca.EventList.Add(ev1);
     ca.EventList.Add(ev2);
     Assert.IsTrue(ca.EventFollowsEventCount(ev1, ev2)==1,"Count: " + ca.EventFollowsEventCount(ev1,ev2));
 }
 /// <summary>
 /// Constructor, which set the following parameter.
 /// </summary>
 /// <param name="innerEvent">The InnerEvent</param>
 /// <param name="adjacency">The Adjacency</param>
 /// <param name="listOfFollowers">List of followers</param>
 public EventNode(Event innerEvent, double adjacency, List<EventNode> listOfFollowers = null)
 {
     InnerEvent = innerEvent;
     Adjacency = adjacency;
     ListOfFollowers = listOfFollowers ?? new List<EventNode>();
 }
Example #25
0
 /// <summary>
 /// Returns a list of integers, which are the indexes of each occurrence of Event e1 and Event e2 directly following each other.
 /// </summary>
 /// <param name="event1">The first event</param>
 /// <param name="event2">The second event, which must follow the first event directly</param>
 /// <returns>A list of indexes</returns>
 /// <author>Jannik Arndt</author>
 public List<int> IndexesOfPair(Event event1, Event event2)
 {
     return Enumerable.Range(0, EventList.Count - 1).Where(i => EventList[i].Name == event1.Name && EventList[i + 1].Name == event2.Name).ToList();
 }
        /// <summary>
        /// Checks the eventuallyRowList if a row from event A to event B exists. If not a new row is created, else the directly follow count is increased by one.
        /// </summary>
        /// <param name="fromEvent">From event A</param>
        /// <param name="toEvent">To event B</param>
        /// <author>Bernd Nottbeck, Krystian Zielonka </author>
        protected void CheckAddRowEventualFollowsDic(Event fromEvent, Event toEvent)
        {
            if (!EventDictionary.ContainsKey(toEvent))
                throw new Exception("Something is wrong! Key Missing in event dictionary");

            InductiveMinerRow currentRow;

            var query = from SearchRow in EventuallyRowList
                        where SearchRow.FromNode == EventDictionary[fromEvent] && SearchRow.ToNode == EventDictionary[toEvent]
                        select SearchRow;

            currentRow = query.FirstOrDefault();

            if (currentRow != null)
            {
                currentRow.Count++;
            }
            else
            {
                EventuallyRowList.Add(new InductiveMinerRow(EventDictionary[fromEvent], EventDictionary[toEvent]));
            }
        }
Example #27
0
 /// <summary>
 /// Creates a new Event and adds it to a <see cref="Case"/>.
 /// </summary>
 /// <param name="name">The Name of the new event</param>
 public Event CreateEvent(String name)
 {
     Event item = new Event(name);
     EventList.Add(item);
     return item;
 }
 public void GetHashCodeTest()
 {
     Event ev = new Event { Name = "Event" };
     Assert.IsTrue(ev.Name.GetHashCode() == ev.GetHashCode());
 }
        /// <summary>
        /// This method creates an event log with one case.
        /// </summary>
        /// <autor>Thomas Meents</autor>
        public static EventLog OneCaseEventLog()
        {
            Event firstEvent = new Event("first");
            Event secondEvent = new Event("second");
            List<Event> listOfEvents = new List<Event> { firstEvent, secondEvent };
            Case ca = new Case("ExampleCase", listOfEvents);
            EventLog eventLog = new EventLog();
            eventLog.Cases.Add(ca);

            return eventLog;
        }
 public void IndexesOfPairTest()
 {
     Case ca = new Case();
     Event ev1 = new Event { Name = "first" };
     Event ev2 = new Event { Name = "second" };
     ca.EventList.Add(ev1);
     ca.EventList.Add(ev2);
     List<int> list = ca.IndexesOfPair(ev1, ev2);
     Assert.IsTrue(list.Count==1);
 }