100 likes | 228 Vues
This set of class notes from CSE 571 (Advanced Artificial Intelligence) covers key topics in AI including Smodels and DLV for answer set computation, and the application of Pure Prolog for certain logical structures. It explores graph colorability challenges, optimizing value in the knapsack problem, and strategies for maximizing auction revenues. Students will learn about using Prolog effectively without cuts and ordering, the limitations of Smodels with lists, and efficient implementations in AI programming.
E N D
CSE 571Advanced Artificial Intelligence Oct 22, 2003 Class Notes Transcribed By: Jon Lammers
Ch8 – Smodels, DLV, Pure Prolog • Smodels & DLV • Compute answer sets and compare to results. • Pure Prolog • Looks for items in result in the head. • Works if you don’t use cut or ordering. • 8.4 discusses when Prolog is faithful to the entail relationship. • Prolog may be better for AnsProlog in cases where the answer sets are not computable (i.e. lists, ask a question). CSE 571 - Advanced Artificial Intelligence
Graph Colorability (8.1.5) • Can you color a graph so that no adjacent vertices have the same color? vertex(1..4). edge(1,2). edge(1,3). edge(1,4). edge(2,3). Edge(2,4). 1{color(1,Y):col(Y)}1. % To start with. generalize to: 1{color(1,Y):col(Y)}1 :- vertex(X). :- color(X,Y), color(Z,Y), edge(X,Z). CSE 571 - Advanced Artificial Intelligence
Knapsack Problem (8.1.8) • Items with size and value. Optimize the value of items that fit in a limited size sack. CSE 571 - Advanced Artificial Intelligence
Knapsack Problem (8.1.8) • Weight • similar to 1 { a, b, c } 2 • Use 4 [ a, b, c ] 8. • Where weight a = 3, b = 5, c = 7. weight value(1) = 5. weight cost(1) = 4. weight value(2) = 6. weight cost(1) = 5. weight value(3) = 3. weight cost(1) = 6. weight value(4) = 8. weight cost(1) = 5. weight value(5) = 2. weight cost(1) = 3. %Limit to the size of the bag (cost). :- 13[ cost(X) : item( X ) ]. CSE 571 - Advanced Artificial Intelligence
Knapsack Problem (8.1.8) inbag(X) :- item(X), not n_inbag(X). % iterate items n_inbag(X) :- item(X), not inbag(X). 1 { inbag(X), n_inbag(X) } 1 :- item(X). % iterate cost(X) :- inbag(X), item(X). val(X) :- inbag(X), item(X). maximize [ val(X) : item(X) ]. % Find max value. CSE 571 - Advanced Artificial Intelligence
Single Unit Auction (8.1.9) • Auctioneer putting bundle of items up for auction. • Bidders bid on one or more items. • Auctioneer wishes to maximize his revenue from the auction. • Read this example and finish 8.1, 8.2, 8.3 CSE 571 - Advanced Artificial Intelligence
Pure Prolog (8.3.1) • Smodels doesn’t support general lists. • It cannot build arbitrarily large structures. • Can only build finite length. • Can check lists. • Is p(1..5) defined for all in set S? p(1..5). in(1, S). in(2, S). in(3, S). in(4, S). in(5, S). not_true :- in(X, S), not p(X). true :- not not_true. CSE 571 - Advanced Artificial Intelligence
Pure Prolog Weight_sold(X,Y,Z) = Y. Total_sold(I,N) :- item(I), number(N), N[sold(I,X,D) : number(X) : date(D)]N. • This is an inefficient implementation if N is grounded from 1 to 100. CSE 571 - Advanced Artificial Intelligence