public void PrepareAndRun()
        {
            Parser.path = @"D:\documents\frostbow\";
            UPC.ReadProblem();

            if (DeCacheIt)
            {
                DeCacheIt = false;
                cacheManager.DeCacheIt();
            }
            else if (justCacheMapsAndEffort)
            {
                cacheManager.DecacheSteps();
                AddObservedNegativeConditions(UPC);

                CacheMaps.CacheLinks(GroundActionFactory.GroundActions);
                CacheMaps.CacheGoalLinks(GroundActionFactory.GroundActions, UPC.goalPredicateList);
                CacheMaps.CacheAddReuseHeuristic(new State(UPC.initialPredicateList) as IState);
                UnityGroundActionFactory.PrimaryEffectHack(new State(UPC.initialPredicateList) as IState);

                cacheManager.justCacheMapsAndEffort = true;
                cacheManager.CacheIt();
                cacheManager.justCacheMapsAndEffort = false;
                return;
            }
            else
            {
                UGAF.PreparePlanner(true);
                GroundActionFactory.GroundActions = new HashSet <IOperator>(GroundActionFactory.GroundActions).ToList();
                AddObservedNegativeConditions(UPC);
                UnityGroundActionFactory.CreateSteps(UPC, UGAF.DecompositionSchemata);

                cacheManager.CacheIt();
            }

            var initialPlan = PlannerScheduler.CreateInitialPlan(UPC.initialPredicateList, UPC.goalPredicateList);


            Debug.Log("Planner and initial plan Prepared");

            // MW-Loc-Conf
            var solution = Run(initialPlan, new ADstar(false), new E0(new AddReuseHeuristic(), true), cutoffTime);

            //var solution = Run(initialPlan, new ADstar(false), new E3(new AddReuseHeuristic()), cutoffTime);
            //var solution = Run(initPlan, new BFS(), new Nada(new ZeroHeuristic()), 20000);
            if (solution != null)
            {
                //Debug.Log(solution.ToStringOrdered());
                PlanSteps = new List <string>();
                foreach (var step in solution.Orderings.TopoSort(solution.InitialStep))
                {
                    Debug.Log(step);
                    PlanSteps.Add(step.ToString());
                }
            }
            else
            {
                Debug.Log("No good");
            }
        }
示例#2
0
        public void DeCacheIt()
        {
            Parser.path = @"D:\documents\frostbow\";
            DecacheSteps();

            UnityPlanningInterface.AddObservedNegativeConditions(UPC);

            var CausalMapFileName = GetCausalMapFileName();
            var ThreatMapFileName = GetThreatMapFileName();
            var EffortMapFileName = GetEffortDictFileName();

            try
            {
                var cmap = BinarySerializer.DeSerializeObject <TupleMap <IPredicate, List <int> > >(CausalMapFileName + ".CachedCausalMap");
                CacheMaps.CausalTupleMap = cmap;

                var tcmap = BinarySerializer.DeSerializeObject <TupleMap <IPredicate, List <int> > >(ThreatMapFileName + ".CachedThreatMap");
                CacheMaps.ThreatTupleMap = tcmap;

                try
                {
                    var emap = BinarySerializer.DeSerializeObject <TupleMap <IPredicate, int> >(EffortMapFileName + ".CachedEffortMap");
                    HeuristicMethods.visitedPreds = emap;
                }
                catch
                {
                    CacheMaps.CacheAddReuseHeuristic(new State(UPC.initialPredicateList) as IState);
                    UnityGroundActionFactory.PrimaryEffectHack(new State(UPC.initialPredicateList) as IState);
                }
            }
            catch
            {
                CacheMaps.CacheLinks(GroundActionFactory.GroundActions);
                CacheMaps.CacheGoalLinks(GroundActionFactory.GroundActions, UPC.goalPredicateList);
                CacheMaps.CacheAddReuseHeuristic(new State(UPC.initialPredicateList) as IState);
                UnityGroundActionFactory.PrimaryEffectHack(new State(UPC.initialPredicateList) as IState);
            }
        }