Artificial intelligence Informed Search - PowerPoint PPT Presentation

1 / 108
About This Presentation
Title:

Artificial intelligence Informed Search

Description:

A heuristic function ... hSLD=straight-line distance heuristic. ... Memory-bounded heuristic search ... – PowerPoint PPT presentation

Number of Views:1208
Avg rating:3.0/5.0
Slides: 109
Provided by: ikk4
Category:

less

Transcript and Presenter's Notes

Title: Artificial intelligence Informed Search


1
Artificial intelligenceInformed Search
Many slides from Tom Lenaerts, Dan Klein, Stuart
Russell or Andrew Moore
2
Outline
  • Informed use problem-specific knowledge
  • Which search strategies?
  • Best-first search and its variants
  • Heuristic functions?
  • How to invent them
  • Local search and optimization
  • Hill climbing, local beam search, genetic
    algorithms,
  • Local search in continuous spaces
  • Online search agents

3
Problem Graphs vs Search Trees
Each NODE in in the search tree is an entire PATH
in the problem graph.
We almost always construct both on demand and
we construct as little as possible.
4
Previously tree-search
  • function TREE-SEARCH(problem,fringe) return a
    solution or failure
  • fringe ? INSERT(MAKE-NODE(INITIAL-STATEproblem)
    , fringe)
  • loop do
  • if EMPTY?(fringe) then return failure
  • node ? REMOVE-FIRST(fringe)
  • if GOAL-TESTproblem applied to STATEnode
    succeeds
  • then return SOLUTION(node)
  • fringe ? INSERT-ALL(EXPAND(node, problem),
    fringe)
  • A strategy is defined by picking the order of
    node expansion

5
Best-first search
  • General approach of informed search
  • Best-first search node is selected for expansion
    based on an evaluation function f(n)
  • Idea evaluation function measures distance to
    the goal.
  • Choose node which appears best
  • Implementation
  • fringe is queue sorted in decreasing order of
    desirability.
  • Special cases greedy search, A search

6
A heuristic function
  • dictionaryA rule of thumb, simplification, or
    educated guess that reduces or limits the search
    for solutions in domains that are difficult and
    poorly understood.
  • h(n) estimated cost of the cheapest path from
    node n to goal node.
  • If n is goal then h(n)0
  • More information later.

7
Euclidean Heuristic
h0
h8
h4
h5
h11
h8
h4
h6
h12
h11
h6
h9
8
Romania with step costs in km
  • hSLDstraight-line distance heuristic.
  • hSLD can NOT be computed from the problem
    description itself
  • In this example f(n)h(n)
  • Expand node that is closest to goal
  • Greedy best-first search

9
Greedy search example
Arad (366)
  • Assume that we want to use greedy search to solve
    the problem of traveling from Arad to Bucharest.
  • The initial stateArad

10
Greedy search example
Arad
Zerind(374)
Sibiu(253)
Timisoara (329)
  • The first expansion step produces
  • Sibiu, Timisoara and Zerind
  • Greedy best-first will select Sibiu.

11
Greedy search example
Arad
Sibiu
Arad (366)
Rimnicu Vilcea (193)
Fagaras (176)
Oradea (380)
  • If Sibiu is expanded we get
  • Arad, Fagaras, Oradea and Rimnicu Vilcea
  • Greedy best-first search will select Fagaras

12
Greedy search example
Arad
Sibiu
Fagaras

Sibiu (253)
Bucharest (0)
  • If Fagaras is expanded we get
  • Sibiu and Bucharest
  • Goal reached !!
  • Yet not optimal (see Arad, Sibiu, Rimnicu Vilcea,
    Pitesti)

13
Greedy best-first search example
14
Greedy best-first search example
15
Greedy best-first search example
16
Greedy best-first search example
17
Greedy search, evaluation
  • Complete NO (cfr. DF-search)
  • Check on repeated states
  • Minimizing h(n) can result in false starts, e.g.
    Iasi to Fagaras.

Problem From Iasi to Fagaras
18
Greedy search, evaluation
  • Complete? No can get stuck in loops, e.g., Iasi
    ? Neamt ? Iasi ? Neamt ?
  • Time? O(bm), but a good heuristic can give
    dramatic improvement
  • Space? O(bm) -- keeps all nodes in memory
  • Optimal? No

19
A search
  • Best-known form of best-first search.
  • Idea avoid expanding paths that are already
    expensive.
  • Evaluation function f(n)g(n) h(n)
  • g(n) the cost (so far) to reach the node.
  • h(n) estimated cost to get from the node to the
    goal.
  • f(n) estimated total cost of path through n to
    goal.

20
A search
  • A search uses an admissible heuristic
  • A heuristic is admissible if it never
    overestimates the cost to reach the goal
  • Are optimistic
  • Formally
  • 1. h(n) lt h(n) where h(n) is the true cost
    from n
  • 2. h(G)0 for any goal G.
  • e.g. hSLD(n) never overestimates the actual road
    distance

21
Romania example
22
A search example
  • Find Bucharest starting at Arad
  • f(Arad) c(??,Arad)h(Arad)0366366

23
A search example
  • Expand Arrad and determine f(n) for each node
  • f(Sibiu)c(Arad,Sibiu)h(Sibiu)140253393
  • f(Timisoara)c(Arad,Timisoara)h(Timisoara)11832
    9447
  • f(Zerind)c(Arad,Zerind)h(Zerind)75374449
  • Best choice is Sibiu

24
A search example
  • Expand Sibiu and determine f(n) for each node
  • f(Arad)c(Sibiu,Arad)h(Arad)280366646
  • f(Fagaras)c(Sibiu,Fagaras)h(Fagaras)239179415
  • f(Oradea)c(Sibiu,Oradea)h(Oradea)291380671
  • f(Rimnicu Vilcea)c(Sibiu,Rimnicu Vilcea)
  • h(Rimnicu Vilcea)220192413
  • Best choice is Rimnicu Vilcea

25
A search example
  • Expand Rimnicu Vilcea and determine f(n) for each
    node
  • f(Craiova)c(Rimnicu Vilcea, Craiova)h(Craiova)3
    60160526
  • f(Pitesti)c(Rimnicu Vilcea, Pitesti)h(Pitesti)3
    17100417
  • f(Sibiu)c(Rimnicu Vilcea,Sibiu)h(Sibiu)300253
    553
  • Best choice is Fagaras

26
A search example
  • Expand Fagaras and determine f(n) for each node
  • f(Sibiu)c(Fagaras, Sibiu)h(Sibiu)338253591
  • f(Bucharest)c(Fagaras,Bucharest)h(Bucharest)450
    0450
  • Best choice is Pitesti !!!

27
A search example
  • Expand Pitesti and determine f(n) for each node
  • f(Bucharest)c(Pitesti,Bucharest)h(Bucharest)418
    0418
  • Best choice is Bucharest !!!
  • Optimal solution (only if h(n) is admissible)
  • Note values along optimal path !!

28
A search example
29
A search example
30
A search example
31
A search example
32
A search example
33
A search example
34
Optimality of A(standard proof)
  • Suppose suboptimal goal G2 in the queue.
  • Let n be an unexpanded node on a shortest to
    optimal goal G.
  • f(G2 ) g(G2 ) since h(G2 )0
  • gt g(G) since G2 is suboptimal
  • gt f(n) since h is admissible
  • Since f(G2) gt f(n), A will never select G2 for
    expansion

35
BUT graph search
  • Discards new paths to repeated state.
  • Previous proof breaks down
  • Solution
  • Add extra bookkeeping i.e. remove the more
    expensive of two paths.
  • Ensure that optimal path to any repeated state is
    always first followed.
  • Extra requirement on h(n) consistency (or
    monotonicity)

36
Consistency
  • A heuristic is consistent if
  • If h is consistent, we have
  • i.e. f(n) is nondecreasing along any path.

Theorem If h(n) is consistent, A using
GRAPH-SEARCH is optimal.
37
Optimality of A(more useful)
  • A expands nodes in order of increasing f values
  • Contours can be drawn in state space
  • Uniform-cost search adds circles.
  • F-contours are gradually
  • added
  • 1) Expands nodes with f(n)ltC
  • 2) Might expand some nodes on
  • the goal Contour (f(n)C)
  • before selecting a goal node.
  • Contour I has all
  • Nodes with ffi, where
  • fi lt fi1.

38
Properties of A
  • Complete? Yes, since bands of increasing f are
    added
  • (unless there are infinitely many nodes
  • with f f(G) )
  • if b is finite and step costs exceed some finite
    e, then this problem will not happen
  • Time? Exponential in the length of the solution
  • Space? Keeps all nodes in memory (runs out of
    space long before it runs out of time)
  • Optimal? Yes

39
A search, evaluation
  • Optimality YES
  • Cannot expand fi1 until fi is finished.
  • A expands all nodes with f(n)lt C
  • A expands some nodes with f(n)C
  • A expands no nodes with f(n)gtC
  • Also optimally efficient (not including ties)

40
A without admissibility
B
4
5
5
A
D
9
0
C
4
5
200
Never explored!
41
A with admissibility
B
4
5
5
A
D
9
0
C
4
5
1
42
Another A without admissibility
B
1
5
5
A
D
9
0
C
4
5
6
Never explored!
43
Memory-bounded heuristic search
  • Some solutions to A space problems (maintain
    completeness and optimality)
  • Iterative-deepening A (IDA)
  • Here cutoff information is the f-cost (gh)
    instead of depth
  • Recursive best-first search(RBFS)
  • Recursive algorithm that attempts to mimic
    standard best-first search with linear space.
  • (simple) Memory-bounded A ((S)MA)
  • Drop the worst-leaf node when memory is full

44
Iterative Deepening A
Iterative-Deepening A (IDA) Korf, 1985
performs a series of independent depth-first
searches, each with the cost-bound increased by
the minimal amount. Following the lines of the
well-known A heuristic search algorithm Pearl,
1985Nilsson, 1980, the total cost of a node
is made up of the cost already spent in reaching
that node , plus a lower bound on the estimated
cost of the path to a goal state . At the
beginning, the cost bound is set to the heuristic
estimate of the initial state, then, for each
iteration, the bound is increased to the minimum
value that exceeded the previous bound, as shown
in the following pseudo code
http//www.informatik.uni-osnabrueck.de/papers_htm
l/ai_94/node2.html
45
Iterative Deepening A
Source Reinfeld, (1994) Enhanced Iterative
Deepening Search, the original article
46
A vs. IDA
  • A - memory-intensive
  • IDA- faster, but more node-intensive recursive
    best-first search algorithm
  • - on the average requires bh/(bh - 1) times as
    many operations as A.
  • - with an admissible heuristic estimate function
    (i.e., one that
  • never overestimates), IDA is guaranteed to find
    the shortest
  • solution path.

bh - heuristic branching - factor
47
Summary Iterative Deepening
  • Iterative deepening searches mimic a
    breadth-first node expansion with a series of
    depth-first searches that operate with
    successively extended search horizons.
  • They provide a simple way to reduce the space
    complexity of best first searches like A from
    exponential to linear in the search depth.

48
Recursive best-first search
  • function RECURSIVE-BEST-FIRST-SEARCH(problem)
    return a solution or failure
  • return RFBS(problem,MAKE-NODE(INITIAL-STATEprobl
    em),8)
  • function RFBS( problem, node, f_limit) return a
    solution or failure and a new f-cost limit
  • if GOAL-TESTproblem(STATEnode) then return
    node
  • successors ? EXPAND(node, problem)
  • if successors is empty then return failure, 8
  • for each s in successors do
  • f s ? max(g(s) h(s), f node)
  • repeat
  • best ? the lowest f-value node in successors
  • if f best gt f_limit then return failure, f
    best
  • alternative ? the second lowest f-value among
    successors
  • result, f best ? RBFS(problem, best,
    min(f_limit, alternative))
  • if result ? failure then return result

49
Recursive best-first search
  • Keeps track of the f-cost value of the
    best-alternative path available.
  • If current f-values exceeds this alternative
    f-value then backtrack to alternative path.
  • Upon backtracking, change f-value to best f-value
    of its children.
  • Re-expansion of this result is thus still
    possible.

50
Recursive best-first search, ex.
  • Path until Rumnicu Vilcea is already expanded
  • Above node f-limit for every recursive call is
    shown on top.
  • Below node f(n)
  • The path is followed until Pitesti which has an
    f-value worse than the f-limit.

51
Recursive best-first search, ex.
  • Unwind recursion and store best f-value for
    current best leaf Pitesti
  • result, f best ? RBFS(problem, best,
    min(f_limit, alternative))
  • best is now Fagaras. Call RBFS for new best
  • best value is now 450

52
Recursive best-first search, ex.
  • Unwind recursion and store best f-value for
    current best leaf Fagaras
  • result, f best ? RBFS(problem, best,
    min(f_limit, alternative))
  • best is now Rimnicu Viclea (again). Call RBFS for
    new best
  • Subtree is again expanded.
  • Best alternative subtree is now through
    Timisoara.
  • Since the alternative path costs 447 gt 417,
    expansion continues to Bucharest.

53
RBFS evaluation
  • RBFS is a bit more efficient than IDA
  • Still excessive node generation (mind changes)
  • Like A, optimal if h(n) is admissible
  • Space complexity is O(bd).
  • IDA retains only one single number (the current
    f-cost limit)
  • Time complexity difficult to characterize
  • Depends on accuracy of h(n) and how often best
    path changes.
  • IDA and RBFS suffer from too little memory
  • - RBFS does not take advantage of extra memory
    available

54
(simplified) memory-bounded A
  • SMA
  • uses available memory
  • avoids repeated expansions
  • Expands newest best node and deletes oldest worst
    leaf (node with high f-cost )
  • remembers f-cost values of dropped subtrees
  • Returns best reachable solution if memory is not
    enough for the problem

55
(simplified) memory-bounded A
  • Use all available memory.
  • I.e. expand best leafs until available memory is
    full
  • When full, SMA drops worst leaf node (highest
    f-value)
  • Like RFBS backup forgotten node to its parent
  • What if all leafs have the same f-value?
  • Same node could be selected for expansion and
    deletion.
  • SMA solves this by expanding newest best leaf
    and deleting oldest worst leaf.
  • SMA is complete if solution is reachable,
    optimal if optimal solution is reachable
  • -if (depth of shallowest goal node) lt memory size
    (expressed in nodes)

56
Enhanced Iterative Deepening Search
57
Learning to search better
  • All previous algorithms use fixed strategies.
  • Agents can learn to improve their search by
    exploiting the meta-level state space.
  • Each meta-level state is an internal
    (computational) state of a program that is
    searching in the object-level state space.
  • In A such a state consists of the current search
    tree
  • A meta-level learning algorithm from experiences
    at the meta-level.

58
Heuristic functions
  • E.g for the 8-puzzle
  • Avg. solution cost is about 22 steps (branching
    factor /- 3)
  • Exhaustive search to depth 22 3.1 x 1010 states.
  • A good heuristic function can reduce the search
    process.

59
Heuristic functions
  • E.g for the 8-puzzle knows two commonly used
    heuristics
  • h1 the number of misplaced tiles
  • h1(s)8
  • h2 the sum of the distances of the tiles from
    their goal positions (manhattan distance).
  • h2(s)3122233218

Solution to the given figure is 26 steps long
60
Characterising Heuristic Quality
  • Effective branching factor b
  • the branching factor that a uniform tree of depth
    d (solution depth) would have in order to contain
    N1 nodes.
  • Measure is fairly constant for sufficiently hard
    problems.
  • Can thus provide a good guide to the heuristics
    overall usefulness.
  • A good value of b is 1.

61
Test from 100 runs with varying solution depths
H2 looks better as fewer nodes are expanded. But
why?
62
Effective Branching Factor
  • H2 has a lower branching factor and so fewer
    nodes are expanded
  • Therefore, one way to measure the quality of a
    heuristic is to find its average branching factor
  • H2 has a lower EBF and is therefore the better
    heuristic

63
Heuristic quality and dominance
  • 1200 random problems with solution lengths from 2
    to 24.
  • If h2(n) gt h1(n) for all n (both admissible)
  • then h2 dominates h1 and is better for search

h2 is always better than h1 in this example!
h2 will never expand more nodes than h1, (except
possibly for some nodes with f(n) C)
64
Inventing admissible heuristics
Device relaxed problems for which an optimal
solution can be found easily
Fewer restrictions on the actions
  • Admissible heuristics can be derived from the
    exact solution cost of a relaxed version of the
    problem
  • Relaxed 8-puzzle for h1 a tile can move
    anywhere
  • As a result, h1(n) gives the shortest solution
  • Relaxed 8-puzzle for h2 a tile can move to any
    adjacent square.
  • As a result, h2(n) gives the shortest solution.
  • The cost of an optimal solution to a relaxed
    problem is an admissible heuristic for the
    original problem.
  • ABSolver found a useful heuristic for the rubiks
    cube.

The cost of an optimal solution to a relaxed
problem is an admissible heuristic for the
original problem.
65
Inventing admissible heuristics
  • Admissible heuristics can also be derived from
    the solution cost of a subproblem of a given
    problem.
  • This cost is a lower bound on the cost of the
    real problem.
  • Pattern databases store the exact solution costs
    for every possible subproblem instance.
  • The complete heuristic is constructed using the
    patterns in the DB

Task get tiles 1, 2, 3, 4 into their
correct positions, without worrying about
what happens to the other tiles.
h(n)maxh1(1,2,3,4), h2(5,6,7,8), h3(2,4,6,8),
etc.
66
Inventing admissible heuristics
  • Another way to find an admissible heuristic is
    through learning from experience
  • Experience solving lots of 8-puzzles
  • An inductive learning algorithm can be used to
    predict costs for other states that arise during
    search.

Training exemplars Input-Output pair
Input state from the solution path
Output actual cost of the solution from that
cost
Features of a state number of misplaced tiles,
number of pairs of adjacent tiles that are also
in the goal state
67
Local search and optimization
  • Previously systematic exploration of search
    space.
  • Path to goal is solution to problem
  • YET, for some problems path is irrelevant.
  • E.g 8-queens
  • Different algorithms can be used
  • Local search

68
Local search and optimization
  • Local search operate on single current state
    and generally move to neighboring states.
  • Advantages
  • Use very little memory
  • Can often find reasonable solutions in large or
    infinite state spaces.
  • Are also useful for pure optimization problems.
  • Find best state according to some objective
    function.
  • e.g. survival of the fittest as a metaphor for
    optimization.

69
Local search and optimization
STATE SPACE LANDSCAPE
IF ELEVATION CORRESPONDS TO OBJ. FCN.
IF ELEVATION CORRESPONDS TO COST
an OPTIMAL ALGORITHM always finds a global
minimum/maximum.
70
Hill-climbing search
  • is a loop that continuously moves in the
    direction of increasing value
  • It terminates when a peak is reached.
  • Does not maintain a search tree
  • Current node data structure only record the state
    and its objective function value
  • Hill climbing does not look ahead beyond the
    immediate neighbors of the current state.
  • Hill-climbing chooses randomly among the set of
    best successors, if there is more than one.
  • Hill-climbing a.k.a. greedy local search

...like trying to find the top of Mt.Everest in a
thick fog while suffering from amnesia.
71
Hill-climbing search
STEEPEST ASCENT VERSION
  • function HILL-CLIMBING( problem) return a state
    that is a local maximum
  • input problem, a problem
  • local variables current, a node.
  • neighbor, a node.
  • current ? MAKE-NODE(INITIAL-STATEproblem)
  • loop do
  • neighbor ? a highest valued successor of
    current
  • if VALUE neighbor VALUEcurrent then
    return STATEcurrent
  • current ? neighbor

72
Hill-climbing example
8-queens problem
  • Local search typically use a complete-state
    formulation.
  • Successor function returns all possible states
    generated by moving a single queen to another
    square in the same column.
  • Heuristic function h(n) the number of pairs of
    queens that are attacking each other (directly or
    indirectly).

73
Hill-climbing example
Best moves (best successors) typically, one
will be chosen randomly
a)
b)
  • a) shows a state of h17 and the h-value for each
    possible successor.
  • b) A local minimum in the 8-queens state space
    the state has h1, but every successor has a
    higher cost.

8817 million states
At a perfect solution, GLOBAL MINIMUM 0
74
Drawbacks
STATE SPACE LANDSCAPE
See 8-Queens, item b)
Why Hill-climbing gets stucked?
  • Local Maxima peak that is higher than each of
    its neighboring states, but lower than global
    maximum
  • Ridge sequence of local maxima difficult for
    greedy algorithms to navigate
  • Plateaux an area of the state space where the
    evaluation function is flat.
  • (For the 8 queens problem, it gets stucked 86 of
    the time ).

75
Variants of Hill-climbing
Converges more slowly than steepest ascent, but
finds better solution in some landscapes
  • Stochastic hill-climbing
  • Random selection among the uphill moves.
  • The selection probability can vary with the
    steepness of the uphill move.
  • First-choice hill-climbing
  • implements stochastic hill climbing by generating
    successors randomly until a better one is found.
  • Random-restart hill-climbing
  • Tries to avoid getting stucked in local maxima.

Good for thousands of successors
If at first you dont succeed, try, try again.
76
Genetic algorithms
  • Variant of local beam search with sexual
    recombination.

77
How GAs are different from traditional methods?
  • GAs work with a coding of the parameter set, not
    the parameter themselves.
  • GAs search from a population of points, not a
    single point.
  • GAs use payoff (objective function) information,
    not derivatives or other auxilliary knowledge.
  • GAs use probabilistic transition rules, not
    deterministic rules.

78
Genetic Algorithm
GAs APPROACH TO THE PROBLEM
  • Natural parameter set of the optimisation problem
    is represented as a finite-length string

Problem Maximise the function f(x) x2 on the
integer interval 0, 31
Traditional approach twiddle with parameter x
GA doesnt need to know the workings of the black
box.
f f(s)
Setting of five switches
f(x)
output
0
31
x
79
Main Attractions of Genetic Algorithm
GA
Traditional Optimization Approaches
  • Simplicity of operation and power of effect
  • Limitations continuity, derivative existence,
    unimodality
  • unconstrained
  • work from a rich database of points
    simultaneously, climbing many peaks in parallel
  • move gingerly from a single point in the
    decision space to the next using some transition
    rule
  • population of strings points
  • Population of well-adapted diversity

80
The Genetic Algorithm
  • Initialize the algorithm. Randomly initialize
    each individual chromosome in the population of
    size N (N must be even), and compute each
    individuals fitness.
  • Select N/2 pairs of individuals for crossover.
    The probability that an individual will be
    selected for crossover is proportional to its
    fitness.
  • Perform crossover operation on N/2 pairs selected
    in Step1. Randomly mutate bits with a small
    probability during this operation.
  • Compute fitness of all individuals in new
    population.

81
The Genetic Algorithm
  • (Optional Optimization) Select N fittest
    individuals from combined population of size 2N
    consisting of old and new populations pooled
    together.
  • (Optional Optimization) Rescale fitness of
    population.
  • Determine maximum fitness of individuals in
    population.
  • If max fitness optimum fitness lt tolerance
    Then Stop
  • Else
  • Go to Step1.

82
Main Attractions of Genetic Algorithm
GA
  • Initial Step random start using successive
    coin flips

01101 11000 01000 10011
population
GA uses coding
GAs are blind, only payoff values associated
with individual strings are required
  • blind to auxiliary information
  • Searches from a population

Uses probabilistic transition rules to guide
their search towards regions of the search space
with likely improvement
83
Genetic Algorithm
REPRODUCTION
  • Selection according to fitness

01101 11000 01000 10011
population
GA uses coding
Weighted Roulette wheel
Mating pool (tentative population)
  • Replication

CROSSOVER
  • Crossover randomized information exchange

Crossover point k 1, l-1
GA builds solutions from the past partial
solutions of the previous trials
84
Genetic Algorithm
MUTATION
  • Reproduction and crossover may become
    overzealous and lose some potentially useful
    genetic material
  • Mutation protects against irrecoverable loss it
    serves as an insurance policy against
  • Premature loss of important notions
  • mutation rates in the order of 1 mutation per a
    thousand bit position transfers

85
Genetic Algorithm
SAMPLE PROBLEM
  • Maximize f(x) x2 where x is permitted to
    vary between 0 and 31
  • Coding of decision variables as some finite
    length string

X as binary unsigned integer of length 5
0, 31 00000, 11111
  • Constant settings

Pmutation0.0333
DeJong(1975) suggests high crossover Probability,
low mutation probability (inversely proportional
to the pop.size), and A moderate population size
Pcross0.6
Population Size30
86
Genetic Algorithm
SAMPLE PROBLEM
  • Maximize f(x) x2 where x is permitted to
    vary between 0 and 31
  • Select initial population at random (use even
    numbered population size)

Sum 1170 Ave.
293 Max. 576
87
Genetic Algorithm
SAMPLE PROBLEM
  • Maximize f(x) x2 where x is permitted to
    vary between 0 and 31
  • Reproduction select mating pool by spinning
    roulette wheel 4 times.

pselect
01101 11000 01000 10011
14.4
30.9
5.5
49.2
The best get more copies The average stay
even The worst die off
Weighted Roulette wheel
88
Choosing offspring for the next generation
int Select(int Popsize, double Sumfitness,
Population Pop) partsum 0 randrandom
Sumfitness j0 Repeat j Partsum Partsum
Popj.fitness Until (Partsum gt rand) or (j
Popsize) Return j
89
Genetic Algorithm
SAMPLE PROBLEM
  • Crossover strings are mated randomly using coin
    tosses to pair the couples

- mated string couples crossover using coin
tosses to select the crossing site
Sum 1754 Ave.
439 Max. 729
90
Genetic algorithm
  • function GENETIC_ALGORITHM( population,
    FITNESS-FN) return an individual
  • input population, a set of individuals
  • FITNESS-FN, a function which determines the
    quality of the individual
  • repeat
  • new_population ? empty set
  • loop for i from 1 to SIZE(population) do
  • x ? RANDOM_SELECTION(population,
    FITNESS_FN) y ? RANDOM_SELECTION(population,
    FITNESS_FN)
  • child ? REPRODUCE(x,y)
  • if (small random probability) then child ?
    MUTATE(child )
  • add child to new_population
  • population ? new_population
  • until some individual is fit enough or enough
    time has elapsed
  • return the best individual

91
Test Problem
  • Lets see the demonstration for a GA that
    maximizes the function

n 10 c 230 -1 1,073,741,823
92
A Simple GA Example
93
Simple GA Example
  • Function to evaluate
  • coeff chosen to normalize the x parameter when
    a bit string of length lchrom 30 is chosen.
  • Since the x value has been normalized, the max.
    value of the function will be
  • when for the case
    when lchrom30

Fitness Function or Objective Function
94
Test Problem Characteristics
  • With a string length30, the search space is much
    larger, and random walk or enumeration should not
    be so profitable.
  • There are 2301.07(1010) points. With over 1.07
    billion points in the space, one-at-a-time
    methods are unlikely to do very much very
    quickly. Also, only 1.05 percent of the points
    have a value greater than 0.9.

95
Comparison of the functions on the unit interval
x2
f(x)
0
31
x
x10
f(x)
0
1,073,741,823
x
96
Decoding a String
  • For every problem, we must create a procedure
    that decodes a string to create a parameter (or
    set of parameters) appropriate for that problem.

first bit
11010101
Chromosome
1073741823.0
DECODE
OBJ FCN
Parameter
Fitness or Figure of Merit
97
GA Parameters
  • A series of parametric studies De Jong, 1975
    across a five function suite of optimization
    problems suggested that good GA performance
    requires the choice of
  • High cross probability
  • Low Mutation probability (inversely proportional
    to the population size)
  • Moderate Population Size

(e.g. pmutation0.0333, pcross0.6, popsize30)
98
Limits of GA
  • GAs are characterized by a voracious appetite for
    processing power and storage capacity
  • GAs have no convergence guarantees in arbitrary
    problems

99
Limits of GAs
  • GAs sort out interesting areas of a space
    quickly, but they are a weak method, without the
    guarantees of more convergent procedures. This
    does not reduce their utility however. More
    convergent methods sacrifice globality and
    flexibility for their convergence, and are
    limited to a narrow class of problem. GAs can be
    used where more convergent methods dare not
    tread.

100
Advantages of GAs
  • Well-suited to a wide class of problems
  • Do not rely on the analytical properties of the
    function to be optimized (such as the existence
    of a derivative)

101
Advanced GA Architectures
  • GA any Local Convergent Method
  • Start search using GA to sort out the interesting
    hills in your problem. Once GA ferrets out the
    best regions, apply locally convergent scheme to
    climb the local peaks.

102
Other Applications
  • Optimization of a choice of Fuzzy Logic parameters

103
Genetic algorithms
  • Variant of local beam search with sexual
    recombination.

Fitness function number of non-attacking pairs
of queens (min 0, max 8 7/2 28)
24/(24232011) 31 23/(24232011)
29 etc
104
Fitness Scaling
scale.sga contains prescale, scale, scalepop
for scaling fitnesses procedure prescale(umax,
uavg, uminreal var a, breal) Calculate
scaling coefficients for linear scaling const
fmultiple 2.0 Fitness multiple is 2
var deltareal Divisor begin
if umin gt (fmultipleuavg - umax) / (fmultiple -
1.0) Non-negative test then begin
Normal Scaling delta umax - uavg
a (fmultiple - 1.0) uavg / delta
b uavg (umax - fmultipleuavg) / delta
end else begin Scale as much as possible
delta uavg - umin a uavg /
delta b -umin uavg / delta
end end
105
Fitness Scaling
procedure scalepop(popsizeinteger var max, avg,
min, sumfitnessreal var
poppopulation) Scale entire population var
jinteger a, breal slope intercept
for linear equation begin prescale(max, avg,
min, a, b) Get slope and intercept for
function sumfitness 0.0 for j 1 to
popsize do with popj do begin fitness
scale(objective, a, b) sumfitness
sumfitness fitness end end
function scale(u, a, breal)real Scale an
objective function value begin scale a u
b end
106
Normal Scaling
See Test-GA.xls
107
Stretch as much as possible
See Test-GA2.xls
108
References
  • Genetic Algorithms Darwin-in-a-box
  • Presentation by Prof. David E. Goldberg
  • Department of General Engineering
  • University of Illinois at Urbana-Champaign
  • deg_at_uiuc.edu
  • Neural Networks and Fuzzy Logic Algorithms
  • by Stephen Welstead
  • Soft Computing and Intelligent Systems Design
  • by Fakhreddine Karray and Clarence de Silva
Write a Comment
User Comments (0)
About PowerShow.com