Search code examples
eclipsepddl

How to compile documents and run Jshop2 in Eclipse?


I am a student who begin to study SHOP2 from China. My teacher told me to run JSHOP2 in Eclipse.Now I can run original zenotravel problem and generate GUI and plans.Likewise, I want to put other domain and problems to SHOP2 and produce plans. But the problem is that I don't know how to compile them and My teacher only asked me to run the the main function in Internaldomain but it can't succeed.Follow is the original code:

 public static void main(String[] args) throws Exception
 {
    //compile();    
    // compile(args);

    //-- run the planning algorithm
    run(args);   
 }

This code can run zenotravel.Then I put domain and problems named pfile1 and tdepots respectively into SHOP2 folder.Change the codes to:

{
compile(domaintdepots);    
// compile(args);

//-- run the planning algorithm
run(args);

}

It warns "domainpdfiles cannot be resolved to a variable".

Or

        //--compile();    
         compile(args);

        //-- run the planning algorithm
        //run(args);    

It turns out:

"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at JSHOP2.InternalDomain.compile(InternalDomain.java:748)
    at JSHOP2.InternalDomain.main(InternalDomain.java:720)"

720 is main funcition above.And 748 is compile function:

public static void compile(String[] args) throws Exception
 {
        //-- The number of solution plans to be returned.
        int planNo = -1;

        //-- Handle the number of solution plans the user wants to be returned.
        if (args.length == 2 || args[0].substring(0, 2).equals("-r")) {
          if (args[0].equals("-r"))
            planNo = 1;
          else if (args[0].equals("-ra"))
            planNo = Integer.MAX_VALUE;
          else try {
            planNo = Integer.parseInt(args[0].substring(2));
          } catch (NumberFormatException e) {
          }
        }

Finally,according to the advice of the friend,I put the two pddls into src folder and use “java Jshop2.InternalDomain domaintdepots”in CMD commad but an error appeared:"the main class Interdomain can't be found or loaded".But I have set the class path accurately and the Zenotravel planning can run.So how and where can I use the command ? And what is written in the bracket"compile()" in Eclipse?

I am also not familiar with JAVA so it's better if there is concrete instruction.Thanks a lot.


Solution

  • Please describe what are you trying to build, what is it supposed to do, what is the expected end result.

    If you do have a valid PDDL domain and problem file, you could try to load them into the online http://editor.planning.domains/ editor using the File > Load menu. Then press the Solve button and confirm which of the file is the domain and which is problem. If the PDDL model is valid (and the underlying solver can handle the requirements), you will get a plan back.

    If you are trying to build a software solution that needs a PDDL-based planning engine as one of its component, perhaps you could use one of the available implementations: https://nergmada.github.io/pddl-reference/guide/whatisplanner.html#list-of-planners

    If you are trying to build your own planning engine in Java using the Eclipse IDE, you probably need a Java-based PDDL parser. Here is a tutorial, how to use pddl4j for that purpose:

    https://github.com/pellierd/pddl4j/wiki/A-tutorial-to-develop-your-own-planner

    If you need to use Jshop2 in particular, it looks from their documentation (http://www.cs.umd.edu/projects/shop/description.html) that you need to indeed compile the domain and problem PDDL into Java code using following commands:

    java JSHOP2.InternalDomain domainFileName
    
    java JSHOP2.InternalDomain -r problemFileName
    

    Edited on June 19th

    Java package names (e.g. JSHOP2) and class names (InternalDomain) are case sensitive, so make sure you type them as per the documentation. That is probably why you are getting the "main class not found error".

    It is difficult to say what the lines numbers 748 and 720 exactly correspond to, because in the GitHub repo https://github.com/mas-group/jshop2/blob/master/src/JSHOP2/InternalDomain.java the code is different from yours. Can you indicate in your questions which lines those are exactly?

    The make file shows how to execute an out-of-the-box example in the distribution:

    cd examples\blocks
    java JSHOP2.InternalDomain blocks
    java JSHOP2.InternalDomain -r problem300
    

    Does that work for you?