pddl4j icon indicating copy to clipboard operation
pddl4j copied to clipboard

Is it possible to get intermediate states rather than just action sequences through the API

Open jack2200 opened this issue 2 years ago • 5 comments

As stated above, please let me know which function can be implemented if possible, thanks

jack2200 avatar Mar 21 '22 09:03 jack2200

From the coded problem, you can obtain the initial state with the method getInit(). It returns a BitExp. You have to create a BitState from this BitExp. Then, you have to apply the actions of the plan to get the intermediate states with method apply().

pellierd avatar Mar 21 '22 11:03 pellierd

Is this the case with the latest PDDL4j 4.0.0? Is there an easy way to do this? I think there is a big difference between 4.0.0 and 3.8.3

jack2200 avatar Mar 22 '22 01:03 jack2200

I didn't change this point. The intermediate states are not stored in the plan.

pellierd avatar Mar 30 '22 19:03 pellierd

From the coded problem, you can obtain the initial state with the method getInit(). It returns a BitExp. You have to create a BitState from this BitExp. Then, you have to apply the actions of the plan to get the intermediate states with method apply().

Could you provide an example? I couldn't effectively navigate the code to do this.

khanetor avatar Sep 22 '23 19:09 khanetor

In case anyone else need to get the intermediate states, here is the solution in Scala:

val planner = new FF()
// ...
val problem = planner.instantiate(parsedProblem)
val plan = planner.solve(problem)
val state = new State(problem.getInitialState())

val states = plan.actions.asScala.toList.foldLeft(List(problem.toString(state)))((iStates, action) =>
  state.apply(action.getConditionalEffects())
  problem.toString(state) :: iStates
)

You can adapt this to Java as needed.

khanetor avatar Sep 28 '23 15:09 khanetor