60 likes | 181 Views
How to Think about Prolog - 2. Mike’s Prolog Tutorial 6 Oct 2011. Recap. Initial Problem: compute set of fully specified goal states reachable from initial state Discovered: counter productive to compute Reformulated problem: cheaply compute set that is a close upper bound approximation
E N D
How to Think about Prolog - 2 Mike’s Prolog Tutorial 6 Oct 2011
Recap • Initial Problem: compute set of fully specified goal states reachable from initial state • Discovered: counter productive to compute • Reformulated problem: cheaply compute set that is a close upper bound approximation • Informally verified that this is still correct for our context • From reformulation, became clear that our problem can be seen as a CSP
CSP • Set of variables with their respective domains • Set of constraints on and between variables • CSP = find a set of assignments of values to vars (from their domains) such that all constraints are satisfied. • For our problem: • What are the variables? • Their domains? • What are the constraints?
Variables • For each vehicle we have variables that state • Where its location is (X,Y) • Its orientation • Its length • For each variable type we have a finite domain
Constraints • Goal constraint: redCar must be in goal loc • Consistency constraint: no 2 vehicles can occupy the same location • Need to refine the notion of vehicles occupying same location • Refine notion of vehicle occupying a location
Vehicle Occupying a Location • Remember, that at(Vehicle, X, Y) states highest leftmost X,Y coords of where it is located occupy(Vehicle, X, Y) :- at(Vehicle, X, Y) ; at(Vehicle, X-1, Y), orientation(Vehicle, horizontal) ; at(Vehicle, X-2, Y), orientation(Vehicle, horizontal), length(Vehicle, 3) ; ... for vertical direction