AI-Planning / planutils

General library for setting up linux-based environments for developing, running, and evaluating planners.
MIT License
106 stars 31 forks source link

SMTPlan flags not parsed properly #98

Closed neighthan closed 2 years ago

neighthan commented 2 years ago

I installed SMTPlan some time ago, before they recommended using planutils for it. It was quite a pain to get it working, so I'm hoping using planutils will make it easier to set up on other machines. I cloned planutils + build the docker as in the README, and I'm able to do

planutils activate
smtplan car_domain_nodrag.pddl car_prob01.pddl

to get a plan for the car domain + first problem from the SMTPlan benchmarks. When I tried a very simple custom domain/problem, though, SMTPlan just hangs (I let it run several minutes before killing it). Even if I just ask for the SMTLIB constraints to be printed (smtplan domain.pddl prob.pddl -n), and not to solve for a plan, it still hangs.

If I run the same command on the same files with my own installation of SMTPlan, it prints out the constraints almost immediately. I'm happy to send more information to help debug this, but I don't use containers much, so let me know what would be useful. Is it better to raise this issue here or on the SMTPlan repo?

Domain file:

(define (domain debug)

(:requirements :numeric-fluents)

(:functions
  (x)
)

(:action xInc
  :parameters ()
  :precondition (and )
  :effect (and
    (assign (x) (+ x 1))
  )
)

(:action xDec
  :parameters ()
  :precondition (and )
  :effect (and
    (assign (x) (- x 1))
  )
)

(:action xMul
  :parameters ()
  :precondition (and )
  :effect (and
    (assign (x) (* x 1))
  )
)

(:action xDiv
  :parameters ()
  :precondition (and )
  :effect (and
    (assign (x) (/ x 1))
  )
)

)

Problem file

(define (problem debug1) (:domain debug)

(:init
  (= x 0)
)

(:goal (and
  (= x 10)
))

)
neighthan commented 2 years ago

I actually hadn't trying planning with my installation, just getting the constraints. It seems planning for this problem is expected to take a long time, if it ever finishes, so it's only printing the constraints then exiting that doesn't work as quickly in planutils. Maybe the -n flag isn't being passed correctly?

neighthan commented 2 years ago

Ah, this seems to be the case. When I run

planutils activate
smtplan car_domain_nodrag.pddl car_prob01.pddl -n

it prints the plan instead of just printing the constraints and not solving.

haz commented 2 years ago

Hrmz...what happens when you put the -n first? The run file seems to look fine for passing the arguments in: https://github.com/AI-Planning/planutils/blob/main/planutils/packages/smtplan/run

neighthan commented 2 years ago

If I run

planutils activate
smtplan -n car_domain_nodrag.pddl car_prob01.pddl

then I get

realpath: invalid option -- 'n'
Try 'realpath --help' for more information.
input in flex scanner failed

Just running smtplan shows its help string which indicates that the options need to be passed after the domain and problem paths: Usage: ./SMTPlan domain problem [options].

neighthan commented 2 years ago

Ah, smtplan wasn't actually running the planutils one. I forgot I have a script already on my path with that name. Trying to run it (with it's own docker environment) from within planutils just failed somehow, which isn't an issue. I renamed it for now, but I'm not sure how to install / run smtplan inside of planutils then. From the readme, I thought it would auto download a planner when I try to use it , but if I do

planutils activate
lama domain.pddl problem.pddl

I just get bash: lama: command not found (instead of the prompt to install). Similarly, running

docker run -it --privileged planutils bash
lama

gives bash: lama: command not found. Sorry if I'm missing something obvious, but what exactly should I do to install + run a planner (smtplan, in particular) after I've done

git clone https://github.com/AI-Planning/planutils.git
cd planutils
docker build -t planutils:latest .

?

haz commented 2 years ago

So once it's installed, you can do planutils activate. You can fetch the pre-built image with docker pull aiplanning/planutils and that is a docker image with it already installed. And so for you, it would be...

docker run -it --privileged planutils bash
planutils activate
lama

Not everyone wants all planners listed on the path, so that's why planutils activate is required. You could skip that and do planutils run lama instead, if you'd like.

neighthan commented 2 years ago

Ah, sorry I'm dense. I had somehow thought that I could either run the container or activate the environment (without running the container) if I wanted to use a planner on files outside the container. Everything is working now! Thanks for the prompt help, Christian.

One last question - what is the best way to quickly use a planner from the CLI? The method I was using before (with my own installation of smtplan) was a script smtplan like

domain=`realpath "$1"`
problem=`realpath "$2"`
docker run -v "$domain":/domain.pddl -v "$problem":/problem.pddl smtplan /SMTPlan /domain.pddl /problem.pddl

(plus some argument handling). So I could do smtplan domain.pddl problem.pddl directly. Would sticking with that sort of method be best or does planutils have some better / easier way to send files to the planner in the container and get the results back? (I mostly interact with a planner from Python code, so I need an easy way to run things in subprocesses)

haz commented 2 years ago

Interesting question! I always just run from within docker (virtually mounting whatever code I'm working on and needs to use the solvers/tools). You can run it as a server (planutils server) and then a local version of planutils could point to it for planutils remote ... calls, but you'd only get access to some of the solvers.

I think your solution is pretty slick. Only thing you might try on top is to first run the container, and then attach to it with the smtplan calls so you don't pay the penalty of spinning things up. Though, you'd need to know the virtual mount you're interested in, in advance.

Going to close the issue out, but happy to keep the conversation going here or otherwise if you have any follow-ups.