1 / 17

Set Based Search Modeling Examples II

Learn about the 0-1 Knapsack Problem, its set-based search modeling, states, extension rules, Genetic Algorithm approach, and operators. Explore mutation and combination examples with a focus on modeling and optimization.

Download Presentation

Set Based Search Modeling Examples II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Set Based Search Modeling Examples II Andrew Kuipers amkuiper@cpsc.ucalgary.ca Please include [CPSC433] in the subject line of any emails regarding this course. CPSC 433 Artificial Intelligence

  2. Example: 0-1 Knapsack 0-1 Knapsack Problem • For a given list of n items: • with weights W = <w1, …, wn> • and values V = <v1, …, vn> • we want to maximize the value of a knapsack with capacity C by either placing, or not placing, items from I into C CPSC 433 Artificial Intelligence

  3. Example: 0-1 Knapsack Facts • The items in our knapsack, which we can simply represent by their index F = { 1, …, n } States • A state is a set of items, where the sum of the weight of the items is less than or equal to capacity C S = { F’  F | fF’ wf  C } CPSC 433 Artificial Intelligence

  4. Example: 0-1 Knapsack Extension Rules Ext = { A  B | sS  AS | ((s-A)  B)  S } • This basic extension rule definition allows us to perform all sorts of set manipulation, so long as the result is a valid state • ie: adding and removing either single or multiple items from the knapsack, as long as the result weighs less than the maximum capacity C CPSC 433 Artificial Intelligence

  5. Example: 0-1 Knapsack Example: W = { 20, 7, 13, 5 } V = { 50, 30, 25, 15 } C = 25 s0 = { } s1 = { 2, 3 } by A = { }  B = { 2, 3 } s2 = { 2, 3, 4 } by A = { }  B = { 4 } s3 = { 1, 4 } by A = { 2, 3 }  B = { 1 } CPSC 433 Artificial Intelligence

  6. Example: 0-1 Knapsack Problems with this Model • The control must select between a large number of possible extension rules to apply • Only a single possible solution being manipulated: how can we compare solutions? • How might we define the goal? • While we have correctly modeled the problem, this model does not lend well to a search process • Remember: for a given problem, there are many ways to construct a model CPSC 433 Artificial Intelligence

  7. Example: 0-1 Knapsack GA Another approach: Genetic Algorithm Brief Definition: A genetic algorithm (GA) is a search model that mimics the process of natural evolution. • A population of potential solutions (individuals) • Mutate and combine to create new individuals • Use a fitness function to evaluate individuals CPSC 433 Artificial Intelligence

  8. Example: 0-1 Knapsack GA GA Operators Brief Introduction Mutation Crossover CPSC 433 Artificial Intelligence

  9. Example: 0-1 Knapsack GA Genetic Algorithm Approach I = (w1, v1), …, (wn, vn), C = capacity where w((wi, vi)) = wi and v((wi, vi)) = vi Facts F = { { i1, …, im } | 1  j  m ij  I  (j=1..m w(ij))  C } CPSC 433 Artificial Intelligence

  10. Example: 0-1 Knapsack GA States S  2F * do we need to get any more specific? Extension Rules Ext = { A → B | sS  AS | (s-A)BS  (Mutation(A,B)  Combination(A,B) } CPSC 433 Artificial Intelligence

  11. Example: 0-1 Knapsack GA Mutation(A,B)  A = { P }  B = { P, (P – K)  J } where K  P , J  I and (K  J) =  • Remove some subset K from the fact P randomly • Replace it with some set of items J that does not contain any items in K • We don’t want to replace the fact, just create a new fact that is a mutationof original fact. CPSC 433 Artificial Intelligence

  12. Example: 0-1 Knapsack GA Mutation Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8)  C = 25 A = { (3,4), (7,3), (6,9) } = P K = { (3,4), (6,9) }  P J = { (9,7), (11,8) }  I (K  J) =  CPSC 433 Artificial Intelligence

  13. Example: 0-1 Knapsack GA Mutation Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8)  C = 25 A = { (3,4), (7,3), (6,9) } = P K = { (3,4), (6,9) }  P J = { (9,7), (11,8) }  I (K  J) =  B = { P, (P – K)  J } = { P, { (7,3), (9,7), (11,8) } } CPSC 433 Artificial Intelligence

  14. Example: 0-1 Knapsack GA Combination(A,B)  A = { P, Q }  B = { P, Q, K } where: K  (P  Q)  (K  P)  (K  Q)  min(|P|,|Q|)  |K|  max(|P|, |Q|) • Use existing facts P and Q to generate a new fact K, which is a combination of P & Q, yet not equal to P or Q, and of size between that of P and Q CPSC 433 Artificial Intelligence

  15. Example: 0-1 Knapsack GA Combination Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8)  C = 25 P = { i1, i3 } Q = { i2, i3, i4 } P  Q = {i1, i2, i3, i4 } K = { i2, i3 }  (P  Q) CPSC 433 Artificial Intelligence

  16. Example: 0-1 Knapsack GA Combination Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8)  C = 25 P = { i1, i3 } Q = { i2, i3, i4 } P  Q = {i1, i2, i3, i4 } K = { i2, i3 }  (P  Q) B = {P, Q, { i2, i3 } } CPSC 433 Artificial Intelligence

  17. Example: 0-1 Knapsack GA How does search proceed in a GA? • What does a search instance look like? • Should a search control only select the best individuals in the state? • Population control, genocide CPSC 433 Artificial Intelligence

More Related