public void Reset() { PrevStates = new PredicateList(); CurrStates = new PredicateList(); PrevStates.DC = mProbDef.DC; CurrStates.DC = mProbDef.DC; PrevActionLayer = new HashSet <PlanAction>(); CurrActionLayer = new HashSet <PlanAction>(); RemainingActions.Clear(); RemainingActions.UnionWith(mProbDef.Actions); NumLevelsExpanded = 0; SearchState = GraphSearchState.ContinueSearch; StateMutexes.Clear(); PrevStateMutexes.Clear(); StateMutexes.DC = mProbDef.DC; PrevStateMutexes.DC = mProbDef.DC; ActionMutexes.Clear(); ActionMutexes.DC = mProbDef.DC; //NewActions.Clear(); //NewPreds.Clear(); //NewPreds.DC = mProbDef.DC; U.Clear(); PU.Clear(); }
void GenerateNextLevelStates() { PrevStates.Clear(); PrevStates.Union(CurrStates); foreach (PlanAction act in ExecutableActions) { // do execute the action CurrStates = mProbDef.ExecuteAction(CurrStates, act, false, true); } //NewPreds.Clear(); //NewPreds.Union(CurrStates); //NewPreds.IntersectWith(PrevStates); // now for the added predicates compute mutexes between themselves and previous predicates // but first, compute action mutexes. these are between executable actions and previousely // executed actions. //TODO:Think about prevactionlayer GenerateActionMutexes(); GenerateStateMutexes(); NumLevelsExpanded++; }
public void Union(PredicateList other) { if (DC == null) { DC = other.DC; } Positive.UnionWith(other.Positive); Negative.UnionWith(other.Negative); }
public void GenerateGraph(PredicateList startState) { Reset(); CurrStates.Union(startState); CheckGoal(); while (SearchState == GraphSearchState.ContinueSearch) { GenerateNextLevelStates(); CheckGoal(); } }
public HashSet <PlanAction> GetExecutableActions(PredicateList state, HashSet <PlanAction> allowedActs) { HashSet <PlanAction> lst = new HashSet <PlanAction>(); foreach (PlanAction act in allowedActs) { if (IsActionExecutable(state, act)) { lst.Add(act); } } return(lst); }
private bool CheckPrec(PredicateList p1, PredicateList p2) { HashSet <int> hs; foreach (int p in p1.Positive) { if (PosPos.TryGetValue(p, out hs)) { if (hs.Overlaps(p2.Positive)) { return(true); } } } return(false); }
private void GenerateGroundStates(List <ProblemParser.DataContainer.State> statList, ref PredicateList output) { foreach (ProblemParser.DataContainer.State stat in statList) { List <int> objectIds = new List <int>(stat.Objects.Count); for (int i = 0; i < stat.Objects.Count; i++) { objectIds.Add(mDC.ObjectID[stat.Objects[i]]); } int predID = stat.Pred.PredID; int finalPredID = mDC.GetLinearIndex(predID, objectIds); output.Positive.Add(finalPredID); } output.DC = mDC; }
public override string ToString() { if (DC == null) { return(base.ToString()); } StringBuilder sb = new StringBuilder(); PredicateList tmp = new PredicateList(); tmp.DC = DC; HashSet <Tuple <int, int> > allMutexes = new HashSet <Tuple <int, int> >(); foreach (int st1 in PosPos.Keys) { HashSet <int> mu = PosPos[st1]; foreach (int st2 in mu) { Tuple <int, int> norm = new Tuple <int, int>(st1, st2), rev = new Tuple <int, int>(st2, st1); if (!(allMutexes.Contains(norm) || allMutexes.Contains(rev))) { allMutexes.Add(norm); } } } foreach (Tuple <int, int> mutex in allMutexes) { sb.Append("{"); sb.Append(DC.GetPredicateString(mutex.Item1)); sb.Append(", "); sb.Append(DC.GetPredicateString(mutex.Item2)); sb.Append("}"); } return(sb.ToString()); }
public PredicateList ExecuteAction(PredicateList currState, PlanAction act, bool remove = true, bool inplace = false) { Debug.Assert(IsActionExecutable(currState, act)); PredicateList nextState; if (inplace) { nextState = currState; } else { nextState = new PredicateList(currState, mDC); } if (remove) { nextState.Positive.ExceptWith(act.Effects.Negative); nextState.Negative.ExceptWith(act.Effects.Positive); } nextState.Positive.UnionWith(act.Effects.Positive); nextState.Negative.UnionWith(act.Effects.Negative); return(nextState); }
public HashSet <PlanAction> GetExecutableActions(PredicateList state) { HashSet <PlanAction> hs = new HashSet <PlanAction>(this.Actions); return(GetExecutableActions(state, hs)); }
public bool IsActionExecutable(PredicateList state, int actID) { return(IsActionExecutable(state, this.Actions[actID])); }
public bool IsActionExecutable(PredicateList state, PlanAction act) { return(act.Preconds.Positive.IsSubsetOf(state.Positive)); }
public bool IsSubsetOf(PredicateList other) { return(Positive.IsSubsetOf(other.Positive) && Negative.IsSubsetOf(other.Negative)); }
public void IntersectWith(PredicateList other) { Positive.IntersectWith(other.Positive); Negative.IntersectWith(other.Negative); }
public SMutex(PredicateList pred) { }
public bool PreconditionsMutex(PredicateList p1, PredicateList p2) { //NOTE: Only positive preconditions return(CheckPrec(p1, p2) || CheckPrec(p2, p1)); }
public PredicateList(PredicateList other, ProblemParser.DataContainer dc) { Positive = new System.Collections.Generic.HashSet <int>(other.Positive); Negative = new System.Collections.Generic.HashSet <int>(other.Negative); DC = dc; }
public bool AddPredicate(PredicateList pred) { throw new NotImplementedException(); }
public bool Overlaps(PredicateList other) { return(Positive.Overlaps(other.Positive) || Negative.Overlaps(other.Negative)); }