Course Artificial Intelligence Effective Period September 2018 Local
Course : Artificial Intelligence Effective Period : September 2018 Local Search Prof. Dr. Widodo Budiharto 2018 1
Outline 1. Local Search Algorithms and Optimization Problems – Hill-climbing – Gradient methods – Simulated annealing – Genetic algorithm 2
Review 3
Review Thinking rationally: The laws of thought approach The Greek philosopher Aristotle was one of the first to attempt to codify "right thinking, " that is, irrefutable reasoning processes. His famous syllogisms provided patterns for argument structures that always gave correct conclusions given correct premises. For example: - "Socrates is a man; - all men are mortal; therefore Socrates is mortal. " 4
Review • A rational agent is one that does the right thing. 5
Local search and optimization • Path to goal is solution to problem • The goal of the 8 -queens problem is to place eight queens on a chessboard such that no queen attacks any other. In this formulation, we have 648 possible sequences to investigate • Homework! Propose a solution. 6
Search Strategies • The majority of work in the area of search has gone into finding the right search strategy for a problem. • In our study of the field we will evaluate strategies in terms of four criteria: • Completeness: is the strategy guaranteed to find a solution when there is one? • Time complexity: how long does it take to find a solution? • Space complexity: how much memory does it need to perform the search? • Optimality: does the strategy find the highest-quality solution when there are several different solutions? 7 7
Heuristic function • A function that calculates such cost estimates is called a heuristic function, and is usually denoted by the letter h: • h(n) = estimated cost of the cheapest path from the state at node n to a goal state 8
Heuristic Function 9
PERFECT DECISIONS IN TWO-PERSON GAMES A game can be formally defined as a kind of search problem with the following components: • The initial state, which includes the board position and an indication of whose move it is. • A set of operators, which define the legal moves that a player can make. • A terminal test, which determines when the game is over. States where the game has ended are called terminal states. • A utility function (also called a payoff function), which gives a numeric value for the outcome of a game. In chess, the outcome is a win, loss, or draw, which we can represent by the values +1, — 1, or 0. A game with two players, whom we will call MAX and M 1 N. MAX moves first, and then they take turns moving until the game is over. 10
Tic-Tac-Toe Game • The minimax algorithm is designed to determine the optimal strategy for MAX 11
Hill Climbing • All successors of a node are evaluated and the one that give the most improvement is selected • Choose the successor with the best solution – Highest-valued = best solution • Hill-climbing is like “climbing a mountain without compass” 12
hill-climb with h(n) = total number of violated constraints Hill Climbing 1 • Example Start state 1 3 4 2 6 7 5 8 h(x) = 3 1 7 2 4 3 6 8 7 5 2 3 1 2 4 6 4 5 6 4 6 5 8 7 5 h(x) = 1 h(x) = 3 Goal state h(x) = 2 1 2 3 4 5 6 7 8 3 8 h(x) = 3 h(x) = 0 13
Problems in Hill Climbing • Hill Climbing search often get stuck due to the following conditions: – Local maxima, ridges, and plateaux 14
Problems in Hill Climbing • Local maxima/minima – A peak that is higher than each of its neighboring states but lower than the global maximum. 15
Problems in Hill Climbing • Ridges (Sequence of local maxima) – It is very difficult for greedy algorithms to navigate 16
Problems in Hill Climbing • Plateaux – A flat area of the state-space landscape – It can be a flat local maximum or a shoulder ? Not Difference ? 17
Problems in Hill Climbing • Ways Out – Backtrack to some earlier node and try going in a different direction. – Make a big jump to try to get in a new section. – Moving in several directions at once. 18
Genetic Algorithm • shows the analogy between biological evolution and a binary GA. Bina Nusantara University 19
Genetic Algorithm • Starts with k randomly generated states, called population – Each state is an individual, represented as a string over a finite alphabet (ex. 01010100) • The objective function is called fitness function: better states have high values of fitness function 20
Genetic Algorithm • In the 8 -queen problem, an individual can be represented by a string digits 1 to 8, that represents the position of the 8 queens in the 8 columns. 21
Genetic Algorithm • Possible fitness function is the number of non-attacking pairs of queens • Fitness function of the solution – 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28 • How much? 22
Genetic Algorithm • Pairs of individuals are selected at random for reproduction w. r. t. some probabilities 23
Local Search in Continuous Space • 24
Constraint Satisfaction Problem (CSP) • Constraint satisfaction problem (CSP) – state is defined by variables Xi with values from domain Di – goal test is a set of constraints specifying allowable combinations of values for subsets of variables 25
Defining Constraint Satisfaction Problem Map coloring • • Variables WA, NT, Q, NSW, V, SA, T Domains Di = {red, green, blue} Constraints: adjacent regions must have different colors e. g. , WA ≠ NT, NT ≠ SA, (WA, NT) є {(red, green), (red, blue), (green, red), (green, blue), (blue, red), (blue, green), …} 26
Defining Constraint Satisfaction Problem • • Solution is assigning value for each variable fulfill the constraints e. g. , {WA = red, NT = green, Q = red, NSW = green, V = red, SA = blue, T = green} 27
Local Search for CSP: Example • States: 4 queens in 4 columns (44 = 256 states) • Actions: move queen in column • Goal test: no attacks • Evaluation: h(n) = number of attacks 28
- Slides: 28