pyGrounder is a library that provides classes and methods for modeling problems defined in Planning Domain Definition Language (PDDL+) and in particular it allows to ground the domain on a defined problem.
The grounding process is performed by replacing the variables in the domain with the instances of objects present in a given associated problem.
Domain + Problem ---pyGrounder--> Grounded Domain
- Python version: 3.7 or higher
- Antlr4
- Antlr4 Python3 runtime target
Download the python wheel file containing the library and run the following command:
python pip -m install pyGrounder-0.0.1-py3-none-any.whl
The example.py contains an example of use where:
Domain(domain_path)
Creates an instance of the Domain object from the file domain.pddlProblem(problem_path)
Creates an instance of the Problem object from the file problem.pddlobjDomain.ground(objProblem)
Returns the grounded Domain object.writeJson(result_folder,"filename")
Writes the object in json format in the result_folderobjDomainGrounded.writePddl(result_folder,"filename")
Writes the pddl file of the Domain object
This class represents the pddl file of the domain.
name : str
The string representing the name of the domainrequirements : list[str]
The list representing the requirements of the domaintypes : list[str]
The list representing the types of the domainpredicates : list[Predicate]
The list representing the predicates of the domainfunctions : list[Function]
The list representing the functions of the domainactions : list[Action]
The list representing the actions of the domainevents : list[Event]
The list representing the events of the domainprocesses : list[Process]
The list representing the processes of the domainconstants :list[Variable]
The list representing the constants of the domain
.writeJson(file_path:str,filename:str)
It writes the Json representation of the Domain, naming it as filename, in the folder result at the file_path. Example.toJson()
It returns the dictionary containing the json representation of the domain.printAll()
It prints in console each attributes of the domain and their values.ground(problem: Problem)
It makes the grounding of the domain on the problem given as input. The method returns a Domain object. Example of grounded domain.writePddl(file_path:str,filename:str)
It writes the PDDL file of the Domain, naming it as filename, in the folder result at the file_path
This class represents the pddl file of the problem.
name : str
The string representing the name of the problemdomain : str
The list representing the name of the domainobjects : list[dict]
The list representing the objects of the probleminit : list[dict]
The list of predicates that represent the initial state of the problemgoal : list[dict]
The list of the predicates that represent the goal of the problem
.writeJson(file_path:str,filename:str)
It writes the Json representation of the Problem, naming it as filename, in the folder result at the file_path. Example.toJson()
It returns the dictionary containing the json representation of the Problem.printAll()
It prints in console each attributes of the Problem and their values
The variable object represents a variable in <name> - <type>
format.
For example: "?r - robot"
name : str
The name of the variable.
For example: "?r"type : str
The type of the variable.
For example: "robot"
The Variable's constructor takes in input the string in "name - type" format and it splits the string by removing the dash in order to store the name and the type.
For example: Variable("?r - robot")
.toString()
It returns the whole variable in string format.
For example: "?r - robot"
The Literal object represents a proposition in <name> <argument1>..<argumentN>
format.
For example: "atRobot ?r - robot ?l - room"
name : str
The name of the Literal.
For example "atRobot"arguments : list[Variable]
The list containing the arguments of the Literal.
For example: [?r - robot, ?l - room]
The Predicate's constructor takes in input an antlr4 tree containing the nodes with the name of the Literal and its arguments
For example: Literal(node)
The Predicate object represents a proposition in <name> <argument1>..<argumentN>
format. It extends the Literal object.
For example: "atRobot ?r - robot ?l - room"
name : str
The name of the Predicate.
For example "atRobot"arguments : list[Variable]
The list containing the arguments of the Predicate.
For example: [?r - robot, ?l - room]
The Predicate's constructor takes in input an antlr4 tree containing the nodes with the name of the Literal and its arguments
For example: Predicate(node)
The Function object represents a proposition in <name> <argument1>..<argumentN>
format. It extends the Literal object.
For example: "distance ?a - room ?b - room"
name : str
The name of the Function.
For example "atRobot"arguments : list[Variable]
The list containing the arguments of the Function.
For example: [?a - room ?b - room]
The Predicate's constructor takes in input an antlr4 tree containing the nodes with the name of the Literal and its arguments
For example: Function(node)
This class represents one parameter for the action/event/process. It inherits everything from the Variable class
The Precondition class represents one precondition for the action/process/event. It only contains one predicate, that can be a SimplePredicate, NegatedPredicate or ComposedPredicate
predicate : SimplePredicate | NegatedPredicate | ComposedPredicate
The Precondition's constructor can take as input:
- or an antlr4 tree containing the node with the precondition
- or one predicate between SimplePredicate, NegatedPredicate, ComposedPredicate
.getString()
It returns the string of the Precondition
The Effect class represents one effect for the action/process/event. It only contains one predicate, that can be a SimplePredicate, NegatedPredicate or ComposedPredicate
predicate : SimplePredicate | NegatedPredicate | ComposedPredicate
The Effect's constructor can take as input:
- or an antlr4 tree containing the node with the effect
- or one predicate between SimplePredicate, NegatedPredicate, ComposedPredicate
.getString()
It returns the string of the Effect
This class represents a SimplePredicate in this form: <name> <argument1>..<argumentN>
.
For Example: "atRobot ?r ?b"
string : str
The string of the whole predicate into brackets.
For example: "(atRobot ?r ?b)name : str
The name of the predicate.
For example: "atRobot"arguments:List[str]
The list containing the string of each argument.
For example: [?r, ?b]isComplex:False
Metadata for some operations, it means it's not a composed predicateisNegated:False
Metadata for some operations, it means it's not a negated predicate
The constructor can take as input:
- or a string containing the predicate
For example: SimplePredicate("atRobot ?r ?b") - or the parameters for the name and the arguments
For example: SimplePredicate(name = "atRobot", arguments = ["?r", ?b"])
.getString()
It returns the string of the predicate into brackets.
For example: "(atRobot ?r ?b)"
This class represents a Negated Predicate in this form: not <name> <argument1>..<argumentN>
.
For Example: "not(atRobot ?r ?b)"
string : str
The string of the whole predicate into brackets.
For example: "(not (atRobot ?r ?b))"name : str
The name of the predicate.
For example: "atRobot"arguments:List[str]
The list containing the string of each argument.
For example: [?r, ?b]isComplex:False
Metadata for some operations, it means it's not a composed predicateisNegated:True
Metadata for some operations, it means it's a negated predicate
The constructor can take as input:
- or a string containing the predicate
For example: NegatedPredicate(" not(atRobot ?r ?b)") - or the parameters for the name and the arguments
For example: NegatedPredicate(name = "atRobot", arguments = ["?r", ?b"])
.getString()
It returns the string of the predicate into brackets.
For example: "not((atRobot ?r ?b))"
This class represents a Composed Predicate in this form: operation <argument1> <argument2>
.
For Example: " >= (distanceRun ?r ?a ?b) (distance ?a ?b)"
string : str
The string of the whole predicate into brackets.
For example: "(>= (distanceRun ?r ?a ?b) (distance ?a ?b))"name : str
The name of the operation.
For example: ">="arguments:List[SimplePredicate|ConstantPredicate|ComposedPredicate]
The list containing the predicate of each argument.
For example: [(distanceRun ?r ?a ?b),(distance ?a ?b)]isComplex:True
Metadata for some operations, it means it's a composed predicateisNegated:False
Metadata for some operations, it means it's not a negated predicate
The constructor can take as input:
- or a string containing the predicate
For example: NegatedPredicate(" not(atRobot ?r ?b)") - or the parameters for the name and the arguments
For example: NegatedPredicate(name = "atRobot", arguments = ["?r", ?b"])
.toString()
It returns the string of the predicate into brackets.
For example: "(>= (distanceRun ?r ?a ?b) (distance ?a ?b))"
The class Operation is the generalization of actions,processes and events. It is composed by name, parameters, preconditions and effect.
name : str
The name of the operation.
For example: "StartMoving"parameters : list[Parameters]
The list containing the objects Parameterpreconditions : list[Precondition]
The list containing the objects Precondition.effect : list[Effect]
The list containing the ojects Effect
The constructor can take as input:
- or an antlr4 tree containing the operation
For example: Operation(node) - or the parameters for the name, parameters, preconditions and effect
For example: Operation(name= "name_string",parameters=[], preconditions=[precondition1 : Precondition, precondition2 : Precondition], effects = [effect1 : Effect, effect2 : Effect)]
The class Action represents one action of the pddl file. It is composed by name, parameters, preconditions and effect. It inherits everything by the Operation class
The class Process represents one process of the pddl file. It is composed by name, parameters, preconditions and effect.It inherits everything by the Operation class
The class Event represents one event of the pddl file. It is composed by name, parameters, preconditions and effect.It inherits everything by the Operation class