Exemplo n.º 1
0
        /// <summary>
        ///     Checks a set of leaves whether they fulfill the constraint and
        ///     assigns them dead status. Dead if they do no fulfill the constraint, true otherwise.
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="constraint"></param>
        private void AssignLeavesStatus(List <ActivationNode> nodes, BiTemplate constraint)
        {
            ConstraintEvaluator evaluator = new();
            LtlExpression       expr;

            foreach (var leaf in nodes)
            {
                if (constraint is AlternateSuccession asu)
                {
                    expr = asu.GetFinishingExpression();
                }
                else if (constraint is AlternateResponse ar)
                {
                    expr = ar.GetFinishingExpression();
                }
                else
                {
                    expr = constraint.GetExpression();
                }
                leaf.IsDead = !evaluator
                              .EvaluateExpression(leaf.Subtrace, expr);
            }

            var maxFulfillingSubtraces = GetMaximalFulfillingSubtraces(nodes);

            foreach (var node in maxFulfillingSubtraces)
            {
                node.MaxFulfilling = true;
            }
        }
Exemplo n.º 2
0
 public ActivationBinaryTree(BiTemplate constraint)
 {
     Root   = new ActivationNode();
     Leaves = new List <ActivationNode>()
     {
         Root
     };
     Constraint = constraint;
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Evaluates trace on a constraint
        /// </summary>
        /// <param name="constraint">Constraint towards which trace is to be confirmed</param>
        /// <param name="trace">Trace to be checked</param>
        /// <returns>Conformance of trace for constraint.</returns>
        public ConstraintEvaluation ConformTrace(BiTemplate constraint, List <Event> trace)
        {
            ActivationTreeBuilder treeBuilder = new();
            var tree             = treeBuilder.BuildTree(trace, constraint);
            var f                = GetFulfillment(tree);
            var v                = GetViolation(tree);
            var c                = GetConflict(tree, v, f);
            var eventActivations =
                GetEventActivationTypes(trace, f, c, v);
            var healthiness = new Healthiness(tree, v.Count, f.Count, c.Count);

            return(new ConstraintEvaluation(constraint, healthiness, eventActivations));
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Builds an ActivationBinaryTree from a trace and a constraint.
        ///     Idea behind this algorithm is taken from
        ///     https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6337271
        /// </summary>
        /// <param name="trace">Trace</param>
        /// <param name="constraint">Constraint</param>
        /// <returns></returns>
        public ActivationBinaryTree BuildTree(List <Event> trace, BiTemplate constraint)
        {
            trace = UtilMethods.PreprocessTraceForEvaluation(constraint, trace);
            ActivationBinaryTree tree = new(constraint);
            var id = 1;

            foreach (var e in trace)
            {
                e.ActivityInTraceId = id;
                id++;
                foreach (var leaf in tree.Leaves.ToList())
                {
                    if (leaf.IsDead)
                    {
                        continue;
                    }

                    if (constraint.IsActivation(e))
                    {
                        //left
                        ActivationNode left = new(leaf.Subtrace.ToList());
                        tree.AddNodeLeft(leaf, left);

                        //right
                        ActivationNode right = new(leaf.Subtrace.ToList());
                        right.Subtrace.Add(e);
                        tree.AddNodeRight(leaf, right);
                    }
                    else
                    {
                        leaf.Subtrace.Add(e);
                    }
                }
            }

            AssignLeavesStatus(tree.Leaves, constraint);

            return(tree);
        }
Exemplo n.º 5
0
 private double LocalLikelihoodNode(ActivationNode node, int na, BiTemplate constraint)
 {
     return(node.Subtrace.Count(constraint.IsActivation) / (double)na);
 }