示例#1
0
        /// <summary>
        /// Sets the rigid relations from the initial state and the defined operators. The relations in the initial state that are
        /// identified as rigid are moved to this structure and they are removed from the initial state.
        /// </summary>
        /// <param name="initialState">Initial state in the planning problem.</param>
        /// <param name="operators">Operators in the planning problem.</param>
        public void SetInitialState(IState initialState, LiftedOperators operators)
        {
            Clear();

            RigidRelationsBuilder builder        = new RigidRelationsBuilder();
            HashSet <IAtom>       rigidRelations = builder.Build(initialState, operators);

            foreach (var rigidRelation in rigidRelations)
            {
                initialState.RemovePredicate(rigidRelation);
                Add(rigidRelation);
            }
        }
示例#2
0
        /// <summary>
        /// Constructs the PDDL planning problem from the input data.
        /// </summary>
        /// <param name="inputData">Input data.</param>
        public Problem(InputData.PDDLInputData inputData)
        {
            DomainName        = inputData.Domain.Name;
            ProblemName       = inputData.Problem.Name;
            OriginalInputData = inputData;

            IdManager         = new IdManager(inputData);
            EvaluationManager = new EvaluationManager(new GroundingManager(inputData, IdManager));

            Operators            = new LiftedOperators(inputData.Domain.Actions, IdManager, EvaluationManager);
            InitialState         = new State(inputData.Problem.Init, IdManager);
            GoalConditions       = new Conditions(inputData.Problem.Goal, null, IdManager, EvaluationManager);
            RigidRelations       = new RigidRelations(InitialState, Operators);
            TransitionsGenerator = new Lazy <TransitionsGenerator>(() => new TransitionsGenerator(this));

            EvaluationManager.SetRigidRelations(RigidRelations);
        }
        /// <summary>
        /// Builds the collection of rigid relations in the PDDL planning problem.
        /// </summary>
        /// <param name="initialState">Initial state of the planning problem.</param>
        /// <param name="operators">Operators of the planning problem.</param>
        /// <returns>Set of relations of the initial state that are always true.</returns>
        public HashSet <IAtom> Build(IState initialState, LiftedOperators operators)
        {
            PredicatesInfluencedByOperators = new HashSet <int>();
            foreach (var oper in operators)
            {
                foreach (var effect in oper.Effects)
                {
                    effect.Accept(this);
                }
            }

            HashSet <IAtom> rigidRelations = new HashSet <IAtom>();

            foreach (var predicate in initialState.GetPredicates())
            {
                if (!PredicatesInfluencedByOperators.Contains(predicate.GetNameId()))
                {
                    rigidRelations.Add(predicate);
                }
            }

            return(rigidRelations);
        }
示例#4
0
 /// <summary>
 /// Constructs the rigid relations from the initial state and the defined operators.
 /// </summary>
 /// <param name="initialState">Initial state in the planning problem.</param>
 /// <param name="operators">Operators in the planning problem.</param>
 public RigidRelations(IState initialState, LiftedOperators operators)
 {
     SetInitialState(initialState, operators);
 }