Esempio n. 1
0
        private void ingestDataSet(RuleContainer rc, DataSet dataSet, WorkingRule parent)
        {
            Log.LogMessage(Log.LogLevels.DETAILED, "Ingesting dataSet " + dataSet.getName() + " for " + ruleSet.getName() + " agent");

            // Create WorkingRule object for each DataPoint of each DataSet for each Rule in RuleSet.
            foreach (Rule r in rc.GetRules())
            {
                Log.LogMessage(Log.LogLevels.DETAILED, "Creating WorkingRule for Rule: " + r.GetName());

                WorkingRule wr = new WorkingRule(this, r, dataSet, parent);
                workingSet.Add(wr);
                if (parent != null)
                {
                    Log.LogMessage(Log.LogLevels.DETAILED, "Adding WorkingRule to parent");
                    parent.addWorkingRule(wr);
                }
                if (r.GetRules().Count > 0)
                {
                    Log.LogMessage(Log.LogLevels.DETAILED, "Checking chained rules...");
                    ingestDataSet(r, dataSet, wr);
                }
                if (rc is RuleSet)
                {
                    AddToOpenSetQueue(wr); // Add alpha nodes to openSet queue
                }
            }
        }
        internal WorkingRule(ExecutionAgent agent, Rule rule, DataSet dataSet, WorkingRule parent)
        {
            Log.LogMessage(Log.LogLevels.DETAILED, "WorkingRule constructor for Rule: " + rule.GetName() + " and DataSet: " + dataSet.getName());
            this.agent   = agent;
            this.rule    = rule;
            this.dataSet = dataSet;
            this.parent  = parent;

            dereference();
        }
        private void ingestDataSet(DataSet dataSet)
        {
            Log.LogMessage(Log.LogLevels.DETAILED, "Ingesting dataSet " + dataSet.GetName() + " for " + ruleSet.GetName() + " agent");

            foreach (Rule r in this.ruleSet.rules)
            {
                WorkingRule wr = new WorkingRule(r, dataSet, this);
                this.workingSet.Add(wr);
                this.EnqueueWorkingRule(wr);
            }

            Log.LogMessage(Log.LogLevels.DETAILED, "Finished Ingesting dataSet " + dataSet.GetName());
        }
 internal void EnqueueWorkingRule(WorkingRule wr)
 {
     lock (openSetLock)
     {
         if (!openSetQueue.Contains(wr))
         {
             Log.LogMessage(Log.LogLevels.DETAILED, "Enqueueing WorkingRule for: " + wr.getRule().GetName());
             openSetQueue.Add(wr);
         }
         else
         {
             Log.LogMessage(Log.LogLevels.DETAILED, "Not Enqueueing WorkingRule for: " + wr.getRule().GetName() + " - already in queue.");
         }
     }
 }
Esempio n. 5
0
        private bool hasAncestor(WorkingRule wr, List <WorkingRule> q)
        {
            // Slow! Can be optimized using branch address that contains parent address for each WorkingRule. TODO!!
            WorkingRule target = wr.parent;

            while (target != null)
            {
                foreach (WorkingRule w in q)
                {
                    if (target.Equals(w))
                    {
                        return(true);
                    }
                }
                target = target.parent;
            }
            return(false);
        }
Esempio n. 6
0
        internal void AddToOpenSetQueue(WorkingRule wr)
        {
            //When adding to the OpenSet queue, the following rules should be obeyed :-
            //
            // 1. WorkingRule with same identifier must not already be in the queue
            // 2. If ancestor of this WorkingRule is already in the queue, do not add this workingRule
            // 3. If this rule is an ancestor of a working rule in the queue, that rule must be removed from the queue.
            //TODO
            lock (openSetLock) {
                if (!openSetQueue.Contains(wr) && !hasAncestor(wr, openSetQueue))
                {
                    //Only add working rule if it's not already in the queue, and if there isn't already an ancestor in the queue
                    removeDecendants(wr.workingRules, openSetQueue);

                    Log.LogMessage(Log.LogLevels.DETAILED, "Adding WorkingRule to OpenSetQueue");
                    openSetQueue.Add(wr);
                }
                else
                {
                    Log.LogMessage(Log.LogLevels.DETAILED, "...ignored (already in queue or ancestor already in queue)");
                }
            }
        }
Esempio n. 7
0
 internal void AssociateWorkingRule(WorkingRule workingRule)
 {
     this.associatedWorkingRules.Add(workingRule);
 }
 internal void addWorkingRule(WorkingRule wr)
 {
     Log.LogMessage(Log.LogLevels.DETAILED, "Adding child WorkingRule to Dependencies for Rule: " + rule.GetName() + " and DataSet: " + dataSet.getName());
     this.workingRules.Add(wr);
 }