60 likes | 190 Vues
In this tutorial recap, we navigate the complexities of computing fully specified goal states in Prolog, revealing the pitfalls of traditional methods. Instead of directly computing reachable goal states, we reformulate the problem into a more manageable approach: finding a close upper-bound approximation. This involves recognizing our scenario as a Constraint Satisfaction Problem (CSP) with defined variables, domains, and constraints, particularly focusing on vehicle locations and orientations. By delving into these components, we gain a clearer understanding of how to structure our Prolog goals effectively.
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