CSE 571 Advanced Artificial Intelligence Oct 22 2003

  • Slides: 9
Download presentation
CSE 571 Advanced Artificial Intelligence Oct 22, 2003 Class Notes Transcribed By: Jon Lammers

CSE 571 Advanced Artificial Intelligence Oct 22, 2003 Class Notes Transcribed By: Jon Lammers 10/22/2003 CSE 571 - Advanced Artificial Intelligence

Ch 8 – Smodels, DLV, Pure Prolog • Smodels & DLV – Compute answer

Ch 8 – 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 Ans. Prolog in cases where the answer sets are not computable (i. e. lists, ask a question). 10/22/2003 CSE 571 - Advanced Artificial Intelligence 2

Graph Colorability (8. 1. 5) • Can you color a graph so that no

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). 10/22/2003 CSE 571 - Advanced Artificial Intelligence 3

Knapsack Problem (8. 1. 8) • Items with size and value. Optimize the value

Knapsack Problem (8. 1. 8) • Items with size and value. Optimize the value of items that fit in a limited size sack. Item 1 2 3 4 5 10/22/2003 Value 5 6 3 8 2 Cost 4 5 6 5 3 CSE 571 - Advanced Artificial Intelligence 4

Knapsack Problem (8. 1. 8) • Weight – similar to 1 { a, b,

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 weight value(1) value(2) value(3) value(4) value(5) = = = 5. 6. 3. 8. 2. weight weight cost(1) cost(1) = = = 4. 5. 6. 5. 3. %Limit to the size of the bag (cost). : - 13[ cost(X) : item( X ) ]. 10/22/2003 CSE 571 - Advanced Artificial Intelligence 5

Knapsack Problem (8. 1. 8) inbag(X) : - item(X), not n_inbag(X) : - item(X),

Knapsack Problem (8. 1. 8) inbag(X) : - item(X), not n_inbag(X) : - item(X), not inbag(X). % iterate items 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) ]. 10/22/2003 CSE 571 - Advanced Artificial Intelligence % Find max value. 6

Single Unit Auction (8. 1. 9) • Auctioneer putting bundle of items up for

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 10/22/2003 CSE 571 - Advanced Artificial Intelligence 7

Pure Prolog (8. 3. 1) • Smodels doesn’t support general lists. – It cannot

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_true. 10/22/2003 CSE 571 - Advanced Artificial Intelligence 8

Pure Prolog Weight_sold(X, Y, Z) = Y. Total_sold(I, N) : - item(I), number(N), N[sold(I,

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. 10/22/2003 CSE 571 - Advanced Artificial Intelligence 9