Class ProblemExpert
Defined in File ProblemExpert.hpp
Inheritance Relationships
Base Type
public plansys2::ProblemExpertInterface(Class ProblemExpertInterface)
Class Documentation
-
class ProblemExpert : public plansys2::ProblemExpertInterface
Class that implements the ProblemExpertInterface to manage a PDDL problem.
This class provides the concrete implementation for manipulating PDDL problem elements such as instances, predicates, functions, and goals.
Public Functions
Constructor that initializes the ProblemExpert with a DomainExpert.
- Parameters:
domain_expert – [in] Shared pointer to a DomainExpert instance that provides information about the PDDL domain.
-
virtual std::vector<plansys2::Instance> getInstances()
Get all instances in the problem.
- Returns:
std::vector<plansys2::Instance> Vector containing all instances in the problem.
-
virtual bool addInstance(const plansys2::Instance &instance)
Add a new instance to the problem.
- Parameters:
instance – [in] The instance to be added.
- Returns:
true if the instance was successfully added, false otherwise.
-
virtual bool removeInstance(const plansys2::Instance &instance)
Remove an instance from the problem.
- Parameters:
instance – [in] The instance to be removed.
- Returns:
true if the instance was successfully removed, false otherwise.
-
virtual std::optional<plansys2::Instance> getInstance(const std::string &name)
Get a specific instance by name.
- Parameters:
name – [in] The name of the instance to retrieve.
- Returns:
std::optional<plansys2::Instance> The instance if found, empty otherwise.
-
virtual std::vector<plansys2::Predicate> getPredicates()
Get all predicates in the problem.
- Returns:
std::vector<plansys2::Predicate> Vector containing all predicates in the problem.
-
virtual bool addPredicate(const plansys2::Predicate &predicate)
Add a new predicate to the problem.
- Parameters:
predicate – [in] The predicate to be added.
- Returns:
true if the predicate was successfully added, false otherwise.
-
virtual bool removePredicate(const plansys2::Predicate &predicate)
Remove a predicate from the problem.
- Parameters:
predicate – [in] The predicate to be removed.
- Returns:
true if the predicate was successfully removed, false otherwise.
-
virtual bool existPredicate(const plansys2::Predicate &predicate)
Check if a predicate exists in the problem.
- Parameters:
predicate – [in] The predicate to check.
- Returns:
true if the predicate exists, false otherwise.
-
virtual std::optional<plansys2::Predicate> getPredicate(const std::string &expr)
Get a specific predicate by its expression.
- Parameters:
expr – [in] The expression of the predicate to retrieve.
- Returns:
std::optional<plansys2::Predicate> The predicate if found, empty otherwise.
-
virtual std::vector<plansys2::Function> getFunctions()
Get all functions in the problem.
- Returns:
std::vector<plansys2::Function> Vector containing all functions in the problem.
-
virtual bool addFunction(const plansys2::Function &function)
Add a new function to the problem.
- Parameters:
function – [in] The function to be added.
- Returns:
true if the function was successfully added, false otherwise.
-
virtual bool removeFunction(const plansys2::Function &function)
Remove a function from the problem.
- Parameters:
function – [in] The function to be removed.
- Returns:
true if the function was successfully removed, false otherwise.
-
virtual bool existFunction(const plansys2::Function &function)
Check if a function exists in the problem.
- Parameters:
function – [in] The function to check.
- Returns:
true if the function exists, false otherwise.
-
virtual bool updateFunction(const plansys2::Function &function)
Update the value of an existing function.
- Parameters:
function – [in] The function with the updated value.
- Returns:
true if the function was successfully updated, false otherwise.
-
virtual std::optional<plansys2::Function> getFunction(const std::string &expr)
Get a specific function by its expression.
- Parameters:
expr – [in] The expression of the function to retrieve .
- Returns:
std::optional<plansys2::Function> The function if found, empty otherwise.
-
virtual plansys2::Goal getGoal()
Get the current goal of the problem.
- Returns:
plansys2::Goal The current goal.
-
virtual bool setGoal(const plansys2::Goal &goal)
Set a new goal for the problem.
- Parameters:
goal – [in] The goal to be set.
- Returns:
true if the goal was successfully set, false otherwise.
-
virtual bool isGoalSatisfied(const plansys2::Goal &goal)
Check if a goal is satisfied in the current state.
- Parameters:
goal – [in] The goal to check for satisfaction.
- Returns:
true if the goal is satisfied, false otherwise.
-
virtual bool clearGoal()
Clear the current goal from the problem.
- Returns:
true if the goal was successfully cleared, false otherwise.
-
virtual bool clearKnowledge()
Clear all knowledge (instances, predicates, functions, and goal) from the problem.
- Returns:
true if the knowledge was successfully cleared, false otherwise.
-
virtual std::string getProblem()
Get the complete PDDL problem as a string.
- Returns:
std::string The complete PDDL problem string.
-
virtual bool addProblem(const std::string &problem_str)
Add a complete PDDL problem from a string.
- Parameters:
problem_str – [in] The PDDL problem string to parse and add.
- Returns:
true if the problem was successfully added, false otherwise.
-
bool existInstance(const std::string &name)
Check if an instance with the given name exists.
- Parameters:
name – [in] The name of the instance to check.
- Returns:
true if an instance with the given name exists, false otherwise.
-
bool isValidType(const std::string &type)
Check if a type is valid according to the domain.
- Parameters:
type – [in] The type to check.
- Returns:
true if the type is valid, false otherwise.
-
bool isValidPredicate(const plansys2::Predicate &predicate)
Check if a predicate is valid according to the domain.
- Parameters:
predicate – [in] The predicate to check.
- Returns:
true if the predicate is valid, false otherwise.