aimacode / aima-python

Python implementation of algorithms from Russell And Norvig's "Artificial Intelligence - A Modern Approach"
MIT License
8.07k stars 3.81k forks source link

reproducibility issues for planning_partial_order_planner.ipynb - prints "Probably Wrong" or "Couldn't find a solution" #1273

Open ellemcfarlane opened 1 year ago

ellemcfarlane commented 1 year ago

Problem: PartialOrderPlanner.execute() sometimes either 1. finds no plan: "Couldn't find a solution" 2. finds an incorrect one in which it prints beforehand "Probably Wrong"

According to this, the following code should have this output:

st = spare_tire()
pop = PartialOrderPlanner(st)
pop.execute()
Causal Links
(Action(PutOn(Spare, Axle)), At(Spare, Axle), Action(Finish))
(Action(Start), Tire(Spare), Action(PutOn(Spare, Axle)))
(Action(Remove(Flat, Axle)), NotAt(Flat, Axle), Action(PutOn(Spare, Axle)))
(Action(Start), At(Flat, Axle), Action(Remove(Flat, Axle)))
(Action(Remove(Spare, Trunk)), At(Spare, Ground), Action(PutOn(Spare, Axle)))
(Action(Start), At(Spare, Trunk), Action(Remove(Spare, Trunk)))
(Action(Remove(Flat, Axle)), At(Flat, Ground), Action(Finish))

Constraints
Action(Remove(Flat, Axle)) < Action(PutOn(Spare, Axle))
Action(Start) < Action(Finish)
Action(Remove(Spare, Trunk)) < Action(PutOn(Spare, Axle))
Action(Start) < Action(Remove(Spare, Trunk))
Action(Start) < Action(Remove(Flat, Axle))
Action(Remove(Flat, Axle)) < Action(Finish)
Action(PutOn(Spare, Axle)) < Action(Finish)
Action(Start) < Action(PutOn(Spare, Axle))

Partial Order Plan
[{Action(Start)}, {Action(Remove(Flat, Axle)), Action(Remove(Spare, Trunk))}, {Action(PutOn(Spare, Axle))}, {Action(Finish)}]

However, sometimes when I run it (from restarted kernel, i.e. no variables), I get:

Probably Wrong
Causal Links
(PutOn(Spare, Axle), At(Spare, Axle), Finish)
(Start, Tire(Spare), PutOn(Spare, Axle))
(Remove(Flat, Axle), NotAt(Flat, Axle), PutOn(Spare, Axle))
(Start, Tire(Flat), Remove(Flat, Axle))
(Start, At(Flat, Axle), Remove(Flat, Axle))
(Remove(Spare, Flat), At(Spare, Ground), PutOn(Spare, Axle))
(Start, Tire(Spare), Remove(Spare, Flat))
(Remove(Flat, Axle), At(Flat, Ground), Finish)

Constraints
Remove(Flat, Axle) < Finish
Start < Remove(Spare, Flat)
Start < Finish
Start < Remove(Flat, Axle)
Remove(Flat, Axle) < PutOn(Spare, Axle)
PutOn(Spare, Axle) < Finish
Remove(Spare, Flat) < PutOn(Spare, Axle)
Start < PutOn(Spare, Axle)

Partial Order Plan
[{Start}, {Remove(Spare, Flat), Remove(Flat, Axle)}, {PutOn(Spare, Axle)}, {Finish}]

or just no plan at all: Couldn't find a solution (None, None)

I can't find any pattern that would indicate why this should happen. Also, if other plans are run in the same session (with no other code run in between) sometimes they appear to randomly fail (incorrect or not found) despite the success of other plans, e.g. I have found success for spare_tire but then a fail for simple_blocks_world:

sbw = simple_blocks_world()
pop = PartialOrderPlanner(sbw)
pop.execute()
Couldn't find a solution
(None, None)

Have also tried:

My environment:

If issues like this could be avoided by pinning package versions in requirements.txt or at least printing and saving the versions used in the travis ci builds, that would be nice.