Picat The Planner Module 5 — Questions and Answers
Question 1: When would you choose `best_plan` over `plan` in a Picat program?
- When you need the minimum-cost solution, not just any valid solution (Correct answer)
- When the state space is very small
- When actions have no associated costs
- When you want faster execution regardless of plan quality
Correct answer: When you need the minimum-cost solution, not just any valid solution
`best_plan` exhausts the search to guarantee cost optimality, while `plan` returns the first solution it finds which may not be cheapest.
Question 2: In what form does the Plan variable appear after a successful call to `plan/2`?
- A Picat list of action terms, e.g., [Action1, Action2, ...] (Correct answer)
- A comma-separated string of action names
- A tree structure
- An integer encoding the sequence
Correct answer: A Picat list of action terms, e.g., [Action1, Action2, ...]
The Plan is unified with a standard Picat list where each element is the Action term from the corresponding `action/4` call.
Question 3: What is printed when you call `writeln(Plan)` after `plan(InitState, Plan)` succeeds with a three-step plan?
- A list with three elements, one per action (Correct answer)
- A single action term
- The integer 3
- The final goal state
Correct answer: A list with three elements, one per action
Plan is a list of action terms, so `writeln` outputs something like `[action1,action2,action3]` with one element per step.
Question 4: If the initial state already satisfies `final/1`, what does `plan/2` return?
- An empty list, since no actions are needed (Correct answer)
- Failure, because no actions were taken
- An exception indicating the problem is trivial
- The single-element list containing the initial state
Correct answer: An empty list, since no actions are needed
When the start state is already a goal state, `plan/2` succeeds immediately with Plan = [], reflecting that zero actions are required.
Question 5: Which statement best describes how `plan/3` and `plan/4` differ?
- plan/4 also unifies a variable with the total plan cost; plan/3 does not (Correct answer)
- plan/3 uses BFS while plan/4 uses DFS
- plan/4 requires a heuristic; plan/3 does not
- plan/3 returns all plans; plan/4 returns only one
Correct answer: plan/4 also unifies a variable with the total plan cost; plan/3 does not
`plan(State, Limit, Plan, Cost)` adds a fourth argument that is unified with the total accumulated cost of the returned plan.
Question 6: What is the effect of giving an overly tight Limit value in `plan/3`?
- plan/3 fails even though a valid plan exists beyond the limit (Correct answer)
- It returns a partial plan up to the limit
- It throws a resource_exceeded exception
- It automatically increases the limit and retries
Correct answer: plan/3 fails even though a valid plan exists beyond the limit
If every valid plan costs more than Limit, `plan/3` fails because no solution satisfies the bound — it does not relax the limit automatically.
Question 7: Which of the following is the correct way to test a Picat planning module with a simple two-state problem?
- Define action/4 for the one transition and final/1 for the goal, then call plan/2 (Correct answer)
- Define only final/1 and call plan/1 with no action clauses
- Import planner and call solve/1 with the start state
- Use assert to add states at runtime, then call plan/0
Correct answer: Define action/4 for the one transition and final/1 for the goal, then call plan/2
A minimal planning problem needs at least one `action/4` clause defining the transition and a `final/1` clause defining the goal, then `plan/2` is called.
When would you choose `best_plan` over `plan` in a Picat program?