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));
        }
Example #2
0
        /// <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));
        }
 /// <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>
        /// Depending on the count of followers this adds one (or more) places and their following transitions.
        /// </summary>
        /// <param name="event1"></param>
        /// <param name="node">An event node</param>
        /// <param name="log">The current event log</param>
        /// <param name="petriNet"></param>
        /// <returns>The newly added transitions. This is where you need to continue working.</returns>
        /// <exception cref="NotImplementedException">If there are more than 3 followers in a non-trivial relation.</exception>
        /// <author>Jannik Arndt</author>
        public List<Transition> HandleNode(Transition event1, EventNode node, EventLog log, PetriNet petriNet)
        {
            // Case: No followers
            if (node.ListOfFollowers.Count == 0)
                return new List<Transition>();

            // one or more more followers => count the AND-relations
            var andRelations = CountANDRelations(node, log);

            // Case: All nodes are AND-related
            if (andRelations == node.ListOfFollowers.Count)
                return StartAND(event1, node.ListOfFollowers, petriNet);

            // Case: All nodes are XOR-related
            if (andRelations == 0)
                return StartXOR(event1, node.ListOfFollowers, petriNet);

            // Case: 3 Followers
            if (node.ListOfFollowers.Count == 3)
            {
                var x = node;
                var a = node.ListOfFollowers[0];
                var b = node.ListOfFollowers[1];
                var c = node.ListOfFollowers[2];

                if (andRelations == 2) // XOR-Relations == 1
                {
                    // There are two and-relations and one xor-relation. Find the xor and order the parameters accordingly
                    if (IsXorRelation(x.InnerEvent, b.InnerEvent, c.InnerEvent, log))
                        return StartAand_BxorC(event1, a, b, c, petriNet);
                    if (IsXorRelation(x.InnerEvent, a.InnerEvent, c.InnerEvent, log))
                        return StartAand_BxorC(event1, b, a, c, petriNet);
                    if (IsXorRelation(x.InnerEvent, a.InnerEvent, b.InnerEvent, log))
                        return StartAand_BxorC(event1, c, a, b, petriNet);
                }
                else // XOR-Relations == 2 && AND-Relations == 1
                {
                    // There are two xor-relations and one and-relation. Find the and and order the parameters accordingly
                    if (IsAndRelation(x.InnerEvent, b.InnerEvent, c.InnerEvent, log))
                        return StartAxor_BandC(event1, a, b, c, petriNet);
                    if (IsAndRelation(x.InnerEvent, a.InnerEvent, c.InnerEvent, log))
                        return StartAxor_BandC(event1, b, a, c, petriNet);
                    if (IsAndRelation(x.InnerEvent, a.InnerEvent, b.InnerEvent, log))
                        return StartAxor_BandC(event1, c, a, b, petriNet);
                }
            }
            if (node.ListOfFollowers.Count > 3)
                return StartXOR(event1, node.ListOfFollowers, petriNet);

            // optional transition
            if (node.ListOfFollowers.Count == 2)
                if (log.EventFollowsEvent(node.ListOfFollowers[0].InnerEvent, node.ListOfFollowers[1].InnerEvent) > 0)
                    return StartOptionalTransition(event1, node.ListOfFollowers[0].InnerEvent.Name, node.ListOfFollowers[1].InnerEvent.Name, petriNet);
                else if (log.EventFollowsEvent(node.ListOfFollowers[1].InnerEvent, node.ListOfFollowers[0].InnerEvent) > 0)
                    return StartOptionalTransition(event1, node.ListOfFollowers[1].InnerEvent.Name, node.ListOfFollowers[0].InnerEvent.Name, petriNet);

            return null;
        }
        /// <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);
        }
Example #6
0
        /// <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);
        }
Example #7
0
        /// <summary>
        /// Depending on the count of followers this adds one (or more) places and their following transitions.
        /// </summary>
        /// <param name="event1"></param>
        /// <param name="node">An event node</param>
        /// <param name="log">The current event log</param>
        /// <param name="petriNet"></param>
        /// <returns>The newly added transitions. This is where you need to continue working.</returns>
        /// <exception cref="NotImplementedException">If there are more than 3 followers in a non-trivial relation.</exception>
        /// <author>Jannik Arndt</author>
        public List <Transition> HandleNode(Transition event1, EventNode node, EventLog log, PetriNet petriNet)
        {
            // Case: No followers
            if (node.ListOfFollowers.Count == 0)
            {
                return(new List <Transition>());
            }

            // one or more more followers => count the AND-relations
            var andRelations = CountANDRelations(node, log);

            // Case: All nodes are AND-related
            if (andRelations == node.ListOfFollowers.Count)
            {
                return(StartAND(event1, node.ListOfFollowers, petriNet));
            }

            // Case: All nodes are XOR-related
            if (andRelations == 0)
            {
                return(StartXOR(event1, node.ListOfFollowers, petriNet));
            }

            // Case: 3 Followers
            if (node.ListOfFollowers.Count == 3)
            {
                var x = node;
                var a = node.ListOfFollowers[0];
                var b = node.ListOfFollowers[1];
                var c = node.ListOfFollowers[2];

                if (andRelations == 2) // XOR-Relations == 1
                {
                    // There are two and-relations and one xor-relation. Find the xor and order the parameters accordingly
                    if (IsXorRelation(x.InnerEvent, b.InnerEvent, c.InnerEvent, log))
                    {
                        return(StartAand_BxorC(event1, a, b, c, petriNet));
                    }
                    if (IsXorRelation(x.InnerEvent, a.InnerEvent, c.InnerEvent, log))
                    {
                        return(StartAand_BxorC(event1, b, a, c, petriNet));
                    }
                    if (IsXorRelation(x.InnerEvent, a.InnerEvent, b.InnerEvent, log))
                    {
                        return(StartAand_BxorC(event1, c, a, b, petriNet));
                    }
                }
                else // XOR-Relations == 2 && AND-Relations == 1
                {
                    // There are two xor-relations and one and-relation. Find the and and order the parameters accordingly
                    if (IsAndRelation(x.InnerEvent, b.InnerEvent, c.InnerEvent, log))
                    {
                        return(StartAxor_BandC(event1, a, b, c, petriNet));
                    }
                    if (IsAndRelation(x.InnerEvent, a.InnerEvent, c.InnerEvent, log))
                    {
                        return(StartAxor_BandC(event1, b, a, c, petriNet));
                    }
                    if (IsAndRelation(x.InnerEvent, a.InnerEvent, b.InnerEvent, log))
                    {
                        return(StartAxor_BandC(event1, c, a, b, petriNet));
                    }
                }
            }
            if (node.ListOfFollowers.Count > 3)
            {
                return(StartXOR(event1, node.ListOfFollowers, petriNet));
            }

            // optional transition
            if (node.ListOfFollowers.Count == 2)
            {
                if (log.EventFollowsEvent(node.ListOfFollowers[0].InnerEvent, node.ListOfFollowers[1].InnerEvent) > 0)
                {
                    return(StartOptionalTransition(event1, node.ListOfFollowers[0].InnerEvent.Name, node.ListOfFollowers[1].InnerEvent.Name, petriNet));
                }
                else if (log.EventFollowsEvent(node.ListOfFollowers[1].InnerEvent, node.ListOfFollowers[0].InnerEvent) > 0)
                {
                    return(StartOptionalTransition(event1, node.ListOfFollowers[1].InnerEvent.Name, node.ListOfFollowers[0].InnerEvent.Name, petriNet));
                }
            }

            return(null);
        }