コード例 #1
0
        private void GenerateGroundActions()
        {
            //now for each action, generate all possible argument lists and then generate an id.
            foreach (ProblemParser.Operator op in mDC.Operators)
            {
                // now for all possible arguments:
                op.ComputeHash();
                int argCount = op.ParamNames.Count;
                //TODO: Check this
                List <int> argList          = Enumerable.Repeat(0, argCount).ToList <int>();
                int        maxParamLinIndex = mDC.GetMaxIndexForSize(argCount);

                PlanAction.ID actID = new PlanAction.ID();
                actID.ActionName = op.Name;
                actID.ParamCount = op.ParamNames.Count;
                actID.DC         = mDC;

                for (int paramLinearIndex = 0; paramLinearIndex < maxParamLinIndex;
                     paramLinearIndex++)
                {
                    mDC.GetMultiIndex(paramLinearIndex, ref argList);
                    // now make them ground!
                    PlanAction act = GenerateSingleGroundAction(op, argList);
                    act.ActionID        = actID;
                    act.ParametersIndex = paramLinearIndex;

                    Actions.Add(act);
                }
            }
        }
コード例 #2
0
ファイル: PlanMutex.cs プロジェクト: alizarghami/KAPlanner
 public static bool InconsistentEffects(PlanAction act1, PlanAction act2)
 {
     // an effect of one negates an effect of other
     //TODO: Debug this
     return(act1.Effects.Positive.Overlaps(act2.Effects.Negative) ||
            act1.Effects.Negative.Overlaps(act2.Effects.Positive));
 }
コード例 #3
0
        private void Initialize()
        {
            MutexActions      = new Dictionary <PlanAction, HashSet <PlanAction> >(Actions.Count);
            PositiveProducers = new Dictionary <int, HashSet <PlanAction> >();
            NegativeProducers = new Dictionary <int, HashSet <PlanAction> >();
            // Initialize action mutexes
            for (int i = 0; i < Actions.Count; i++)
            {
                PlanAction act1 = Actions[i];
                if (!MutexActions.ContainsKey(act1))
                {
                    MutexActions.Add(act1, new HashSet <PlanAction>());
                }
                for (int j = i + 1; j < Actions.Count; j++)
                {
                    PlanAction act2 = Actions[j];
                    if (!MutexActions.ContainsKey(act2))
                    {
                        MutexActions.Add(act2, new HashSet <PlanAction>());
                    }

                    if (PlanMutex.ActionsMutex(act1, act2))
                    {
                        MutexActions[act1].Add(act2);
                        MutexActions[act2].Add(act1);
                    }
                }
            }
        }
コード例 #4
0
        private PlanAction GenerateSingleGroundAction(ProblemParser.Operator op, List <int> argList)
        {
            PlanAction action = new PlanAction();

            GenerateGroundActionArgs(op, op.Preconds, argList, ref action.Preconds.Positive);
            GenerateGroundActionArgs(op, op.PosEffect, argList, ref action.Effects.Positive);
            GenerateGroundActionArgs(op, op.NegEffect, argList, ref action.Effects.Negative);
            return(action);
        }
コード例 #5
0
ファイル: PlanMutex.cs プロジェクト: alizarghami/KAPlanner
 public static bool Interference(PlanAction act1, PlanAction act2)
 {
     // one deletes a precondition of the other
     //TODO: Debug this
     return(act1.Effects.Positive.Overlaps(act2.Preconds.Negative) ||
            act1.Effects.Negative.Overlaps(act2.Preconds.Positive) ||
            act2.Effects.Positive.Overlaps(act1.Preconds.Negative) ||
            act2.Effects.Negative.Overlaps(act1.Preconds.Positive));
 }
コード例 #6
0
ファイル: GraphPlan.cs プロジェクト: alizarghami/KAPlanner
            private void AddTo(PlanAction act1, PlanAction act2)
            {
                HashSet <PlanAction> hs;

                if (mutex.TryGetValue(act1, out hs))
                {
                    hs.Add(act2);
                }
                else
                {
                    hs = new HashSet <PlanAction>();
                    hs.Add(act2);
                    mutex.Add(act1, hs);
                }
            }
コード例 #7
0
ファイル: GraphPlan.cs プロジェクト: alizarghami/KAPlanner
            public bool AreActionsMutex(PlanAction act1, PlanAction act2)
            {
                HashSet <PlanAction> hs;

                if (mutex.TryGetValue(act1, out hs))
                {
                    return(hs.Contains(act2));
                }
                else
                {
                    // what if mutexes dont exists?
                    // BUG
                    throw new Exception("(GraphPlan.AMutex.AreActionsMutex) BUG");
                }
            }
コード例 #8
0
        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);
        }
コード例 #9
0
 public bool IsActionExecutable(PredicateList state, PlanAction act)
 {
     return(act.Preconds.Positive.IsSubsetOf(state.Positive));
 }
コード例 #10
0
ファイル: GraphPlan.cs プロジェクト: alizarghami/KAPlanner
 public void AddPair(PlanAction act1, PlanAction act2)
 {
     AddTo(act1, act2);
     AddTo(act2, act1);
 }
コード例 #11
0
ファイル: PlanMutex.cs プロジェクト: alizarghami/KAPlanner
/*        public static bool CompetingNeeds(PlanAction act1, PlanAction act2)
 *      {
 *          // having mutually exclusive precondition
 *          //TODO: Debug this
 *          return (act1.Preconds.Positive.Overlaps(act2.Preconds.Positive) ||
 *              act1.Preconds.Negative.Overlaps(act2.Preconds.Negative));
 *      }
 */
        public static bool ActionsMutex(PlanAction act1, PlanAction act2)
        {
            return(InconsistentEffects(act1, act2) || Interference(act1, act2));
        }