Class DefaultParsedProblem

java.lang.Object
fr.uga.pddl4j.parser.DefaultParsedProblem
All Implemented Interfaces:
ParsedDomain, ParsedProblem, Serializable

public class DefaultParsedProblem extends Object implements ParsedDomain, ParsedProblem
This class implements a parsed problem. This object is returned by the parser after parsing.
See Also:
Serialized Form
  • Constructor Details

    • DefaultParsedProblem

      public DefaultParsedProblem(Symbol<String> domain)
      Creates a new parsed problem with a specific problemName of domain.
      Parameters:
      domain - the problemName of the domain.
    • DefaultParsedProblem

      public DefaultParsedProblem(Symbol<String> problem, Symbol<String> domain)
      Creates a new problem with a specific problem and domain.
      Parameters:
      problem - the name of the problem.
      domain - the name of the domain.
    • DefaultParsedProblem

      public DefaultParsedProblem(ParsedDomain domain, ParsedProblem problem)
      Creates a new parsed problem from a specific domain and problem.
      Parameters:
      domain - the domain.
      problem - the problem.
  • Method Details

    • getDomainName

      public final Symbol<String> getDomainName()
      Returns the problemName of the domain.
      Specified by:
      getDomainName in interface ParsedDomain
      Specified by:
      getDomainName in interface ParsedProblem
      Returns:
      the problemName of the domain.
    • setDomainName

      public final void setDomainName(Symbol<String> name)
      Sets a problemName to the domain.
      Specified by:
      setDomainName in interface ParsedDomain
      Specified by:
      setDomainName in interface ParsedProblem
      Parameters:
      name - the problemName to set.
    • getRequirements

      public final Set<RequireKey> getRequirements()
      Returns the set of requirements.
      Specified by:
      getRequirements in interface ParsedDomain
      Specified by:
      getRequirements in interface ParsedProblem
      Returns:
      the set of requirements.
    • addRequirement

      public final boolean addRequirement(RequireKey requirement)
      Adds a requirements to the domain.
      Specified by:
      addRequirement in interface ParsedDomain
      Specified by:
      addRequirement in interface ParsedProblem
      Parameters:
      requirement - the requirement to add.
      Returns:
      true if the requirement was added; false otherwise.
    • getTypes

      public final List<TypedSymbol<String>> getTypes()
      Returns the parsed types in the domain file.
      Specified by:
      getTypes in interface ParsedDomain
      Returns:
      the parsed types in the domain file.
    • addType

      public final boolean addType(TypedSymbol<String> type)
      Adds a type to the domain.
      Specified by:
      addType in interface ParsedDomain
      Parameters:
      type - the type to add.
      Returns:
      true if the type was added; false otherwise.
    • getConstants

      public final List<TypedSymbol<String>> getConstants()
      Returns the parsed constants in the domain file.
      Specified by:
      getConstants in interface ParsedDomain
      Returns:
      the parsed constants in the domain file.
    • addConstant

      public final boolean addConstant(TypedSymbol<String> constant)
      Adds a constant to the domain.
      Specified by:
      addConstant in interface ParsedDomain
      Parameters:
      constant - the constant to add.
      Returns:
      true if the constant was added; false otherwise.
    • getPredicates

      public final List<NamedTypedList> getPredicates()
      Returns the parsed predicates in the domain file.
      Specified by:
      getPredicates in interface ParsedDomain
      Returns:
      the parsed predicates in the domain file.
    • addPredicate

      public final boolean addPredicate(NamedTypedList predicate)
      Adds a predicate to the domain.
      Specified by:
      addPredicate in interface ParsedDomain
      Parameters:
      predicate - the predicate to add.
      Returns:
      true if the predicate was added; false otherwise.
      Throws:
      NullPointerException - if the specified predicate is null.
    • getFunctions

      public final List<NamedTypedList> getFunctions()
      Returns the parsed functions in the domain file.
      Specified by:
      getFunctions in interface ParsedDomain
      Returns:
      the parsed functions in the domain file.
    • addFunction

      public final boolean addFunction(NamedTypedList function)
      Adds a function to the domain.
      Specified by:
      addFunction in interface ParsedDomain
      Parameters:
      function - the function to add.
      Returns:
      true if the function was added; false otherwise.
    • getTasks

      public final List<NamedTypedList> getTasks()
      Returns the parsed tasks un the domain file.
      Specified by:
      getTasks in interface ParsedDomain
      Returns:
      the parsed tasks in the domain file.
    • addTask

      public final boolean addTask(NamedTypedList task)
      Adds a task to the domain.
      Specified by:
      addTask in interface ParsedDomain
      Parameters:
      task - the task to add.
      Returns:
      true if the task was added; false otherwise.
    • getConstraints

      public final Expression<String> getConstraints()
      Returns the constraints loaded in the domain file.
      Specified by:
      getConstraints in interface ParsedDomain
      Specified by:
      getConstraints in interface ParsedProblem
      Returns:
      the constraints loaded in the domain file or null if the domain has no constraints.
    • setConstraints

      public final void setConstraints(Expression<String> constraints)
      Sets the constraints to the domain.
      Specified by:
      setConstraints in interface ParsedDomain
      Specified by:
      setConstraints in interface ParsedProblem
      Parameters:
      constraints - the constraint of the domain.
    • getActions

      public final List<ParsedAction> getActions()
      Returns the list of parsed actions.
      Specified by:
      getActions in interface ParsedDomain
      Returns:
      the list of parsed actions.
    • addAction

      public final boolean addAction(ParsedAction action)
      Adds an action to the domain.
      Specified by:
      addAction in interface ParsedDomain
      Parameters:
      action - the action to add.
      Returns:
      true if the action was added; false otherwise.
    • getMethods

      public final List<ParsedMethod> getMethods()
      Returns the list of parsed methods.
      Specified by:
      getMethods in interface ParsedDomain
      Returns:
      the list of parsed methods.
    • addMethod

      public final boolean addMethod(ParsedMethod method)
      Adds a method to the domain.
      Specified by:
      addMethod in interface ParsedDomain
      Parameters:
      method - the method to add.
      Returns:
      true if the method was added; false otherwise.
    • getDerivesPredicates

      public final List<ParsedDerivedPredicate> getDerivesPredicates()
      Returns the list of parsed derived predicates.
      Specified by:
      getDerivesPredicates in interface ParsedDomain
      Returns:
      the list of parsed derived predicates.
    • addDerivedPredicate

      public final boolean addDerivedPredicate(ParsedDerivedPredicate predicate)
      Adds a derived predicate to the domain.
      Specified by:
      addDerivedPredicate in interface ParsedDomain
      Parameters:
      predicate - the derived predicate to add.
      Returns:
      true if the derived predicate was added; false otherwise.
      Throws:
      NullPointerException - if the specified predicate is null.
    • isDeclaredType

      public boolean isDeclaredType(Symbol<String> type)
      Returns if a specified type symbol was declared.
      Specified by:
      isDeclaredType in interface ParsedDomain
      Parameters:
      type - the type symbol.
      Returns:
      true if the specified symbol is a declared type; false otherwise.
    • getType

      public TypedSymbol<String> getType(Symbol<String> symbol)
      Returns the type from a specified symbol.
      Specified by:
      getType in interface ParsedDomain
      Parameters:
      symbol - The symbol.
      Returns:
      the type from a specified symbol or null if no type with this symbol was declared.
    • isDeclaredConstant

      public boolean isDeclaredConstant(Symbol<String> constant)
      Returns if a specified constant symbol was declared.
      Specified by:
      isDeclaredConstant in interface ParsedDomain
      Parameters:
      constant - the constant symbol.
      Returns:
      true if the specified symbol is a declared constant; false otherwise.
    • getConstant

      public TypedSymbol<String> getConstant(Symbol<String> symbol)
      Returns the constant from a specified symbol.
      Specified by:
      getConstant in interface ParsedDomain
      Parameters:
      symbol - The symbol.
      Returns:
      the constant from a specified symbol or null if no constant with this symbol was declared.
    • getProblemName

      public final Symbol<String> getProblemName()
      Return the problemName of the problem.
      Specified by:
      getProblemName in interface ParsedProblem
      Returns:
      the problemName of the problem.
    • setProblemName

      public final void setProblemName(Symbol<String> problemName)
      Sets the problemName of the problem.
      Specified by:
      setProblemName in interface ParsedProblem
      Parameters:
      problemName - the problemName to set.
    • getObjects

      public List<TypedSymbol<String>> getObjects()
      Returns the list of objects declared in the problem file.
      Specified by:
      getObjects in interface ParsedProblem
      Returns:
      the list of objects declared in the problem file.
    • addObject

      public final boolean addObject(TypedSymbol<String> object)
      Adds an object to the problem.
      Specified by:
      addObject in interface ParsedProblem
      Parameters:
      object - the object to add.
      Returns:
      true if the object was added; false otherwise.
    • setInitialTaskNetwork

      public final void setInitialTaskNetwork(ParsedTaskNetwork network)
      Set the initial task network of the problem.
      Specified by:
      setInitialTaskNetwork in interface ParsedProblem
      Parameters:
      network - The task network to set.
    • getInitialTaskNetwork

      public final ParsedTaskNetwork getInitialTaskNetwork()
      Returns the task network of the problem.
      Specified by:
      getInitialTaskNetwork in interface ParsedProblem
      Returns:
      the task network of the problem. The task network may null if it is not defined.
    • getInit

      public List<Expression<String>> getInit()
      Returns the list of initial facts defined in the problem file.
      Specified by:
      getInit in interface ParsedProblem
      Returns:
      the list of initial facts defined in the problem file.
    • addInitialFact

      public final boolean addInitialFact(Expression<String> fact)
      Adds an initial fact to the problem.
      Specified by:
      addInitialFact in interface ParsedProblem
      Parameters:
      fact - the fact to add.
      Returns:
      true if the fact was added; false otherwise.
    • getGoal

      public Expression<String> getGoal()
      Returns the list of goal defined in the problem file.
      Specified by:
      getGoal in interface ParsedProblem
      Returns:
      the list of goal defined in the problem file.
    • setGoal

      public void setGoal(Expression<String> goal)
      Set the goal of this problem.
      Specified by:
      setGoal in interface ParsedProblem
      Parameters:
      goal - the goal of this problem.
    • getMetric

      public Expression<String> getMetric()
      Returns the metric of the problem or null if the problem has no metric specification.
      Specified by:
      getMetric in interface ParsedProblem
      Returns:
      the metric of the problem or null if the problem has no metric specification.
    • setMetric

      public final void setMetric(Expression<String> metric)
      Sets the metric of the problem.
      Specified by:
      setMetric in interface ParsedProblem
      Parameters:
      metric - the metric to set.
    • getObject

      public final TypedSymbol<String> getObject(Symbol<String> symbol)
      Returns the object from a specified symbol.
      Specified by:
      getObject in interface ParsedProblem
      Parameters:
      symbol - The symbol.
      Returns:
      the object from a specified symbol or null if no object with this symbol was declared.
    • equals

      public boolean equals(Object object)
      Return if this parsed problem is equal to another specified object.
      Overrides:
      equals in class Object
      Parameters:
      object - the other object.
      Returns:
      true if the specified object is a non null instance of the class DefaultParsedProblem and has the same problem and domain name; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code value of this parsed problem.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value of this parsed problem..
    • isSubType

      public boolean isSubType(TypedSymbol<String> s1, TypedSymbol<String> s2)
      Returns if the types of two typed symbol matched, i.e., if the types of the first typed symbol can be viewed as a subtype of the second.
      Specified by:
      isSubType in interface ParsedDomain
      Parameters:
      s1 - the first typed symbol.
      s2 - the second typed symbol.
      Returns:
      true if the types of the first typed symbol can be viewed as a subtype of the seconds. false otherwise.
    • normalize

      public void normalize()
      Normalize the domain. This method rename the variables used in the domain and normalize its actions and derived predicates.
      Specified by:
      normalize in interface ParsedDomain
      Specified by:
      normalize in interface ParsedProblem
    • renameTaskIDs

      public void renameTaskIDs(Expression<String> exp)
      Renames the tag of the tasks contained in the expression. The tag tasks renames have the form T0, ..., Tn.
      Parameters:
      exp - the expression to rename.
    • toString

      public String toString()
      Returns a string representation of this domain.
      Specified by:
      toString in interface ParsedDomain
      Specified by:
      toString in interface ParsedProblem
      Overrides:
      toString in class Object
      Returns:
      a string representation of this domain.