pddl4j
pddl4j copied to clipboard
Is it possible to get intermediate states rather than just action sequences through the API
As stated above, please let me know which function can be implemented if possible, thanks
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().
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
I didn't change this point. The intermediate states are not stored in the plan.
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.
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.