Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS621: Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 5: Power of Heuristic; nonconventional search A*: Definitions and Properties A* Algorithm – Definition and Properties f(n) = g(n) + h(n) The node with the least value of f is chosen from the OL. S s g(n) f*(n) = g*(n) + h*(n), where, g*(n) = actual cost of the optimal path (s, n) h*(n) = actual cost of optimal path (n, g) g(n) ≥ g*(n) By definition, h(n) ≤ h*(n) n h(n) goal State space graph G 8-puzzle: heuristics Example: 8 puzzle s 2 1 4 1 6 7 1 2 3 7 8 3 4 3 2 4 5 6 5 6 8 7 8 g 5 n h*(n) = actual no. of moves to transform n to g 1. 2. h1(n) = no. of tiles displaced from their destined position. h2(n) = sum of Manhattan distances of tiles from their destined position. h1(n) ≤ h*(n) and h1(n) ≤ h*(n) h* h2 h1 Comparison A* Algorithm- Properties Admissibility: An algorithm is called admissible if it always terminates and terminates in optimal path Theorem: A* is admissible. Lemma: Any time before A* terminates there exists on OL a node n such that f(n) <= f*(s) Observation: For optimal path s → n1 → n2 → … → g, 1. h*(g) = 0, g*(s)=0 and 2. f*(s) = f*(n1) = f*(n2) = f*(n3)… = f*(g) A* Properties (contd.) f*(ni) = f*(s), ni ≠ s and ni ≠ g Following set of equations show the above equality: f*(ni) = g*(ni) + h*(ni) f*(ni+1) = g*(ni+1) + h*(ni+1) g*(ni+1) = g*(ni) + c(ni , ni+1) h*(ni+1) = h*(ni) - c(ni , ni+1) Above equations hold since the path is optimal. Admissibility of A* A* always terminates finding an optimal path to the goal if such a path exists. Intuition S (1) In the open list there always exists a node n such that f(n) <= f*(S) . g(n) n (2) If A* does not terminate, the f value of the nodes expanded become unbounded. h(n) G 1) and 2) are together inconsistent Hence A* must terminate Lemma Any time before A* terminates there exists in the open list a node n' such that f(n') <= f*(S) Optimal path S n1 n2 G For any node ni on optimal path, f(ni) = g(ni) + h(ni) <= g*(ni) + h*(ni) Also f*(ni) = f*(S) Let n' be the fist node in the optimal path that is in OL. Since all parents of n' have gone to CL, g(n') = g*(n') and h(n') <= h*(n') => f(n') <= f*(S) If A* does not terminate Let e be the least cost of all arcs in the search graph. Then g(n) >= e.l(n) where l(n) = # of arcs in the path from S to n found so far. If A* does not terminate, g(n) and hence f(n) = g(n) + h(n) [h(n) >= 0] will become unbounded. This is not consistent with the lemma. So A* has to terminate. 2nd part of admissibility of A* The path formed by A* is optimal when it has terminated Proof Suppose the path formed is not optimal Let G be expanded in a non-optimal path. At the point of expansion of G, f(G) = g(G) + h(G) = g(G) + 0 > g*(G) = g*(S) + h*(S) = f*(S) [f*(S) = cost of optimal path] This is a contradiction So path should be optimal Better Heuristic Performs Better Theorem A version A2* of A* that has a “better” heuristic than another version A1* of A* performs at least “as well as” A1* Meaning of “better” h2(n) > h1(n) for all n Meaning of “as well as” A1* expands at least all the nodes of A2* h*(n) h2*(n) h1*(n) For all nodes n, except the goal node Proof by induction on the search tree of A2*. A* on termination carves out a tree out of G Induction on the depth k of the search tree of A2*. A1* before termination expands all the nodes of depth k in the search tree of A2*. k=0. True since start node S is expanded by both Suppose A1* terminates without expanding a node n at depth (k+1) of A2* search tree. Since A1* has seen all the parents of n seen by A2* g1(n) <= g2(n) (1) Since A1* has terminated without expanding n, f1(n) >= f*(S) (2) S k+1 G Any node whose f value is strictly less than f*(S) has to be expanded. Since A2* has expanded n f2(n) <= f*(S) (3) From (1), (2), and (3) h1(n) >= h2(n) which is a contradiction. Therefore, A1* has to expand all nodes that A2* has expanded. Exercise If better means h2(n) > h1(n) for some n and h2(n) = h1(n) for others, then Can you prove the result ? A list of AI Search Algorithms A* AO* IDA* (Iterative Deepening) Minimax Search on Game Trees Viterbi Search on Probabilistic FSA Hill Climbing Simulated Annealing Gradient Descent Stack Based Search Genetic Algorithms Memetic Algorithms Evolutionary search: Genetic and Memetic Algoritms Evolution – Fundamental Laws Survival of the fittest. Change in species is due to change in genes over reproduction or/and due to mutation. An Example showing the concept of survival of the fittest and reproduction over generations. Evolutionary Computation Evolutionary Computation (EC) refers to computer-based problem solving systems that use computational models of evolutionary process. Terminology: Chromosome – It is an individual representing a candidate solution of the optimization problem. Population – A set of chromosomes. gene – It is the fundamental building block of the chromosome, each gene in a chromosome represents each variable to be optimized. It is the smallest unit of information. Objective: To find a best possible chromosome to a given optimization problem. Evolutionary Algorithm: A meta-heuristic Let t = 0 be the generation counter; create and initialize a population P(0); repeat Evaluate the fitness, f(xi), for all xi belonging to P(t); Perform cross-over to produce offspring; Perform mutation on offspring; Select population P(t+1) of new generation; Advance to the new generation, i.e., t = t+1; until stopping condition is true; On Overview of GAs GA emulate genetic evolution. A GA has distinct features: A string representation of chromosomes. A selection procedure for initial population and for offspring creation. A cross-over method and a mutation method. A fitness function be to minimized. A replacement procedure. Parameters that affect GA are initial population, size of the population, selection process and fitness function. Anatomy of GA Selection Selection is a procedure of picking parent chromosome to produce off-spring. Types of selection: Random Selection – Parents are selected randomly from the population. Proportional Selection – probabilities for picking each chromosome is calculated as: P(xi) = f(xi) /Σf(x ) for all j j Rank Based Selection – This method uses ranks instead of absolute fitness values. P(xi) = (1/β)(1 – er(xi)) Roulette Wheel Selection Let i = 1, where i denotes chromosome index; Calculate P(xi) using proportional selection; sum = P(xi); choose r ~ U(0,1); while sum < r do i = i + 1; i.e. next chromosome sum = sum + P(xi); end return xi as one of the selected parent; repeat until all parents are selected Reproduction Reproduction is a processes of creating new chromosomes out of chromosomes in the population. Parents are put back into population after reproduction. Cross-over and Mutation are two parts in reproduction of an off-spring. Cross-over : It is a process of creating one or more new individuals through the combination of genetic material randomly selected from two or parents. Cross-over Uniform cross-over : where corresponding bit positions are randomly exchanged between two parents. One point : random bit is selected and entire sub-string after the bit is swapped. Two point : two bits are selected and the substring between the bits is swapped. Uniform Cross-over One point Cross-over Two point Cross-over Parent1 Parent2 00110110 11011011 00110110 11011011 00110110 11011011 Off-spring1 Off-spring2 01110111 10011010 00111011 11010110 01011010 10110111 Mutation Mutation procedures depend upon the representation schema of the chromosomes. This is to prevent falling all solutions in population into a local optimum. For a bit-vector representation: random mutation : randomly negates bits in-order mutation : performs random mutation between two randomly selected bit position. Random Mutation In-order Mutation Before mutation 1110010011 1110010011 After mutation 1100010111 1110011010