public void TC_IStateOrConditions()
        {
            var problem   = new Planner.SAS.Problem(new SASInputData(GetFilePath("TC_Gripper.sas")));
            var heuristic = new FFHeuristic(problem);

            IStateOrConditions state  = problem.InitialState;
            IStateOrConditions state2 = new Planner.SAS.State(1, 1, 1, 1, 0, 4, 4);

            Assert.IsTrue(CollectionsEquality.Equals(problem.GetSuccessors((IState)state), state.DetermineTransitions(problem)));
            Assert.IsFalse(state.DetermineGoalNode(problem));
            Assert.IsTrue(state2.DetermineGoalNode(problem));
            Assert.AreEqual(heuristic.GetValue((IState)state), state.DetermineHeuristicValue(heuristic));

            IStateOrConditions conditions  = problem.GoalConditions;
            IStateOrConditions conditions2 = new Planner.SAS.Conditions(new Planner.SAS.Assignment(5, 4), new Planner.SAS.Assignment(6, 4));

            Assert.IsTrue(CollectionsEquality.Equals(problem.GetPredecessors((IConditions)conditions), conditions.DetermineTransitions(problem)));
            Assert.IsFalse(conditions.DetermineGoalNode(problem));
            Assert.IsTrue(conditions2.DetermineGoalNode(problem));
            Assert.AreEqual(heuristic.GetValue((IConditions)conditions), conditions.DetermineHeuristicValue(heuristic));

            IStateOrConditions relativeState  = problem.GoalConditions.GetCorrespondingRelativeStates(problem).First();
            IStateOrConditions relativeState2 = new Planner.SAS.RelativeState(-1, -1, -1, -1, -1, 4, 4);

            Assert.IsTrue(CollectionsEquality.Equals(problem.GetPredecessors((IRelativeState)relativeState), relativeState.DetermineTransitions(problem)));
            Assert.IsFalse(relativeState.DetermineGoalNode(problem));
            Assert.IsTrue(relativeState2.DetermineGoalNode(problem));
            Assert.AreEqual(heuristic.GetValue((IRelativeState)relativeState), relativeState.DetermineHeuristicValue(heuristic));
        }
Esempio n. 2
0
        protected override double GetValueImpl(PAD.Planner.IState state)
        {
            float heurVal = nextFFHeurResult == -1 ? (float)heur.GetValue(state) : (float)nextFFHeurResult;

            nextFFHeurResult             = -1;
            nnInputs[nnInputs.Count - 1] = heurVal;
            double networkVal = network.eval(nnInputs);

            return(networkVal >= 0 ? networkVal + (double)heurVal / 10000 : heurVal);               //breaking ties in this heuristic values by values of the inner heuristic
        }
        public void TC_FFHeuristic()
        {
            var sasProblem  = new Planner.SAS.Problem(new SASInputData(GetFilePath("TC_Gripper.sas")));
            var pddlProblem = new Planner.PDDL.Problem(new PDDLInputData(GetFilePath("TC_Gripper_D.pddl"), GetFilePath("TC_Gripper_P.pddl")));

            var heuristic = new FFHeuristic(sasProblem);

            Assert.AreEqual(9, heuristic.GetValue(sasProblem.GetInitialState()));
            Assert.AreEqual(9, heuristic.GetValue(sasProblem.GetGoalConditions()));
            Assert.AreEqual(9, heuristic.GetValue(sasProblem.GetGoalConditions().GetCorrespondingRelativeStates(sasProblem).First()));
            Assert.AreEqual("FF Heuristic", heuristic.GetName());
            Assert.AreEqual(3, heuristic.GetCallsCount());

            var heuristic2 = new FFHeuristic(pddlProblem);

            Assert.AreEqual(5, heuristic2.GetValue(pddlProblem.GetInitialState()));
            Assert.AreEqual(5, heuristic2.GetValue(pddlProblem.GetGoalConditions()));
            Assert.AreEqual(5, heuristic2.GetValue(pddlProblem.GetGoalConditions().GetCorrespondingRelativeStates(pddlProblem).First()));
            Assert.AreEqual("FF Heuristic", heuristic2.GetName());
            Assert.AreEqual(3, heuristic2.GetCallsCount());
        }
Esempio n. 4
0
        public static double computeFFHeuristic(string stateString)
        {
            var    splitted      = stateString.Split('_');
            string domainName    = splitted[0];
            string problemName   = splitted[1];
            string stateAsString = splitted[2];

            string  sasProblemPath = Path.Combine(SAS_all_WithoutAxioms, domainName, problemName);
            Problem p     = new Problem(sasProblemPath, false);
            IState  state = State.Parse(stateAsString);

            FFHeuristic h = new FFHeuristic(p);

            return(h.GetValue(state));
        }