public void ProccessActions() { if(_start==null || _resault==null) return; ModelConfiguration mc = new ModelConfiguration(_start); for (int i = 0; i < _actions.Count; i++) { mc = mc*_actions[i]; } _resault.CopyFrom(mc); }
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); }
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; }
public ModelConfiguration GeneratRawModelConfiguration(string name) { ModelConfiguration modelConfiguration = new ModelConfiguration(name); int stateCount = (int)Math.Pow(2, _atomics.Count); bool[] positivity = InitializeSingleValueArray(_atomics.Count, false); for (int i = 0; i < stateCount; i++) { EpisState toAdd = new EpisState(_atomics.Values.ToArray(), positivity); modelConfiguration.AddState(toAdd); IncreamentBinarySeq(ref positivity); } foreach (var s1 in modelConfiguration.States) { foreach (var s2 in modelConfiguration.States) { EpisTransitionPair trans = new EpisTransitionPair(s1, s2); trans.TagedAgents = new AssossiativeSet <Agent>(_agents.Values); modelConfiguration.TransitionRelation.Add(trans); } } return(modelConfiguration); }
public ModelConfiguration CreateNewModel(string name) { ModelConfiguration modelConfiguration = new ModelConfiguration(name); _models.Add(name, modelConfiguration); return modelConfiguration; }
public ModelConfiguration(ModelConfiguration model) { CopyFrom(model); }
public void CopyFrom(ModelConfiguration modelConfiguration) { Name = modelConfiguration.Name; EpisState[] StateArray = new EpisState[modelConfiguration.States.Count]; EpisTransitionPair[] TransArray = new EpisTransitionPair[modelConfiguration.TransitionRelation.Count]; modelConfiguration.States.CopyTo(StateArray); modelConfiguration.TransitionRelation.CopyTo(TransArray); States = StateArray.ToList(); TransitionRelation = TransArray.ToList(); }