示例#1
0
 public void Union(AssossiativeSet <T> other)
 {
     foreach (T member in other._array)
     {
         if (!Contains(member))
         {
             Add(member);
         }
     }
 }
示例#2
0
        public AssossiativeSet <T> Copy()
        {
            AssossiativeSet <T> toret = new AssossiativeSet <T>(this._capacity);

            _array.CopyTo(toret._array, 0);
            foreach (var i in _hash)
            {
                toret._hash.Add(i.Key, i.Value);
            }
            toret._head = _head;
            return(toret);
        }
示例#3
0
        public AssossiativeSet <T> IntersectWith(AssossiativeSet <T> other)
        {
            AssossiativeSet <T> toret = new AssossiativeSet <T>(_capacity);

            if (other != null)
            {
                toret = Copy();
                foreach (T member in _array)
                {
                    if (!other.Contains(member))
                    {
                        toret.Remove(member);
                    }
                }
            }
            return(toret);
        }
示例#4
0
        public static ModelConfiguration operator *(ModelConfiguration model, ActionModel action)
        {
            ModelConfiguration toret = new ModelConfiguration(model.Name + "_" + action.Name);

            List <EAState>     newStates = new List <EAState>();
            List <EAStatePair> newTrans  = new List <EAStatePair>();

            foreach (var aState in action.ActionStates)
            {
                foreach (var eState in model.States)
                {
                    if (eState.SatisfiesFormula(aState.Precondition))
                    {
                        newStates.Add(new EAState(eState, aState));
                    }
                }
            }

            foreach (var a in newStates)
            {
                foreach (var b in newStates)
                {
                    AssossiativeSet <Agent> episTaged    = model.GetTagedAgentOfTransitionBetween(a.ModelState, b.ModelState);
                    AssossiativeSet <Agent> actionTaged  = action.GetTagedAgentOfTransitionBetween(a.ActionState, b.ActionState);
                    AssossiativeSet <Agent> intersection = episTaged.IntersectWith(actionTaged);
                    if (!intersection.IsEmpty)
                    {
                        EAStatePair newTransPair = new EAStatePair(a, b);
                        newTransPair.TagedAgents = intersection;
                        newTrans.Add(newTransPair);

                        toret.AddState(a.ModelState);
                        toret.AddState(b.ModelState);

                        toret.AddTransition(a.ModelState, b.ModelState, intersection, true);
                    }
                }
            }

            return(toret);
        }
示例#5
0
        private void AddTransition(EpisState a, EpisState b, AssossiativeSet <Agent> tags, bool unionTagsIfAlreadyAPair)
        {
            EpisTransitionPair newPair = new EpisTransitionPair(a, b)
            {
                TagedAgents = tags
            };

            EpisTransitionPair availablePair = TransitionRelation.Find(x => x.Equals(newPair));

            if (availablePair == null)
            {
                TransitionRelation.Add(newPair);
            }
            else
            {
                if (unionTagsIfAlreadyAPair)
                {
                    availablePair.TagedAgents.Union(tags);
                }
            }
        }