public void Union(AssossiativeSet <T> other) { foreach (T member in other._array) { if (!Contains(member)) { Add(member); } } }
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); }
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); }
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); }
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); } } }