Download presentation

Presentation is loading. Please wait.

Published byKelsey Allston Modified about 1 year ago

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

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

3
CPSC 433 Artificial Intelligence 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’ w f C }

4
CPSC 433 Artificial Intelligence 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

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

6
CPSC 433 Artificial Intelligence 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

7
CPSC 433 Artificial Intelligence 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

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

9
CPSC 433 Artificial Intelligence Example: 0-1 Knapsack GA Genetic Algorithm Approach I = (w 1, v 1 ), …, (w n, v n ) , C = capacity where w((w i, v i )) = w i and v((w i, v i )) = v i Facts F = { { i 1, …, i m } | 1 j m i j I ( j=1..m w(i j )) C }

10
CPSC 433 Artificial Intelligence Example: 0-1 Knapsack GA States S 2 F * 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) }

11
CPSC 433 Artificial Intelligence 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 mutation of original fact.

12
CPSC 433 Artificial Intelligence 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) =

13
CPSC 433 Artificial Intelligence 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) } }

14
CPSC 433 Artificial Intelligence 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

15
CPSC 433 Artificial Intelligence Example: 0-1 Knapsack GA Combination Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8) C = 25 P = { i 1, i 3 } Q = { i 2, i 3, i 4 } P Q = {i 1, i 2, i 3, i 4 } K = { i 2, i 3 } (P Q)

16
CPSC 433 Artificial Intelligence Example: 0-1 Knapsack GA Combination Example: I = (3, 4), (9, 7), (7, 3), (6, 9), (11,8) C = 25 P = { i 1, i 3 } Q = { i 2, i 3, i 4 } P Q = {i 1, i 2, i 3, i 4 } K = { i 2, i 3 } (P Q) B = {P, Q, { i 2, i 3 } }

17
CPSC 433 Artificial Intelligence 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

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google