PDDL4J is an open source library under LGPL license whose purpose of PDDL4J is to facilitate the development of JAVA tools for Automated Planning based on PDDL language (Planning Domain Description Language).
Both files are written in PDDL 1.2 (I cannot use the newer version of the language for several purpose). Based on the guide available on the site for pddl4j, I first tried instantiating the planning problem with the code
package fr.uga.pddl4j.examples;
import fr.uga.pddl4j.parser.DefaultParsedProblem;
import fr.uga.pddl4j.parser.ErrorManager;
import fr.uga.pddl4j.parser.Message;
import fr.uga.pddl4j.parser.Parser;
import fr.uga.pddl4j.problem.DefaultProblem;
import fr.uga.pddl4j.problem.Problem;
import fr.uga.pddl4j.problem.operator.Action;
import java.io.FileNotFoundException;
/**
* The class is an example class. It shows how to use the library to create to ground planning problem.
*
* @author D. Pellier
* @version 4.0 - 06.12.2021
*/
public class ProblemInstantiationExample {
/**
* The main method the class. The first argument must be the path to the PDDL domain description and the second
* argument the path to the PDDL problem description.
*
* @param args the command line arguments.
*/
public static void main(final String[] args) {
// Checks the number of arguments from the command line
if (args.length != 2) {
System.out.println("Invalid command line");
return;
}
try {
// Creates an instance of the PDDL parser
final Parser parser = new Parser();
// Parses the domain and the problem files.
final DefaultParsedProblem parsedProblem = parser.parse(args[0], args[1]);
// Gets the error manager of the parser
final ErrorManager errorManager = parser.getErrorManager();
// Checks if the error manager contains errors
if (!errorManager.isEmpty()) {
// Prints the errors
for (Message m : errorManager.getMessages()) {
System.out.println(m.toString());
}
} else {
// Prints that the domain and the problem were successfully parsed
System.out.print("\nparsing domain file \"" + args[0] + "\" done successfully");
System.out.print("\nparsing problem file \"" + args[1] + "\" done successfully\n\n");
// Create a problem
final Problem problem = new DefaultProblem(parsedProblem);
// Instantiate the planning problem
problem.instantiate();
// Print the list of actions of the instantiated problem
for (Action a : problem.getActions()) {
//System.out.println(problem.toString(a));
}
}
// This exception could happen if the domain or the problem does not exist
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
though it gives the following error
Exception in thread "main" java.lang.NullPointerException at fr.uga.pddl4j.problem.FinalizedProblem.extractRelevantFluents(FinalizedProblem.java:373) at fr.uga.pddl4j.problem.DefaultProblem.finalization(DefaultProblem.java:299) at fr.uga.pddl4j.problem.AbstractProblem.instantiate(AbstractProblem.java:444) at fr.uga.pddl4j.examples.ProblemInstantiationExample.main(ProblemInstantiationExample.java:56)
I'm pretty sure the problem is related to the domain file or problem file since I tried executing the same code on different problems and domains and it worked
I have the following domain and problem files
Both files are written in PDDL 1.2 (I cannot use the newer version of the language for several purpose). Based on the guide available on the site for pddl4j, I first tried instantiating the planning problem with the code
though it gives the following error
Exception in thread "main" java.lang.NullPointerException at fr.uga.pddl4j.problem.FinalizedProblem.extractRelevantFluents(FinalizedProblem.java:373) at fr.uga.pddl4j.problem.DefaultProblem.finalization(DefaultProblem.java:299) at fr.uga.pddl4j.problem.AbstractProblem.instantiate(AbstractProblem.java:444) at fr.uga.pddl4j.examples.ProblemInstantiationExample.main(ProblemInstantiationExample.java:56)
I'm pretty sure the problem is related to the domain file or problem file since I tried executing the same code on different problems and domains and it worked