Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jack2200 opened this issue Mar 21, 2022 · 5 comments
Labels

Comments

@jack2200
Copy link

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

@pellierd
Copy link
Owner

pellierd commented Mar 21, 2022

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().

@jack2200
Copy link
Author

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

@pellierd
Copy link
Owner

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

@khanetor
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants