You are on page 1of 17

Evolutionary Computing

Techniques
Marx. R
Associate professor
Department of Computer Science and
Engineering

PROBLEMS AND EXAMPLES

Hill Climbing Example - 1

Heuristic function
f(n) = - (number of tiles out of place)

Hill Climbing Example - 2

Local Optimum
f(n) = - (the sum of the horizontal + vertical distance that each tile
is away from its final destination)

Hill Climbing Example 3 (Tic Tac Toe)


Black squares are placed randomly (no intelligence)
Black Circles use a heuristic function
h(x) = 1 if the spot allows the player to win
h(x) = 0.5 if the spot prevents the other player
from winning
h(x) = 0.2 for the center spot
h(x) = 0.1 for middle spots (non-corners)
h(x) = 0 for corners
The score for each spot is the sum of the possible
values of h(x) for that spot. The spot with the
highest score is chosen as the next spot to use.

Hill Climbing Example Tic Tac Toe

Tic Tac Toe (Black ovals with logic)

Hill climbing Blocks world Local


search - Disadvantages

Hill climbing Blocks world

Hill climbing Blocks world Global


heuristic

Hill climbing Blocks world Global


heuristic

Hill Climbing Example Home work 1


Using only four colours, you have to colour a
planar map in such a way that no two
adjacent regions have the same colour.

Hill Climbing Example Home work 2


You have two jugs, a 4 litre one and a 3-litre one, and a
water faucet. No measuring marks on jugs.
You can fill the jugs up or empty them out from one to
another or onto the ground.
You need to measure out exactly 2 litres of water in 4
litre jug!
State: (x, y)

x = 0, 1, 2, 3, or 4

y = 0, 1, 2, 3

Start state: (0, 0)


Goal state: (2, n) for any n.
Attempting to end up in a goal state.

Hill Climbing Example Home work 2

Hill Climbing Example Home work 3


On one bank of a river are three missionaries and three cannibals.
There is one boat available that can hold up to two people and that
they would like to use to cross the river. If the cannibals ever
outnumber the missionaries on either of the rivers banks, the
missionaries will get eaten.
How can the boat be used to safely carry all the missionaries and
cannibals across the river?
Hueristic: h(n) = Number of People on starting side 1
-1 as in every trip, one person has to paddle back, but the number
of people on starting side should reduce to 0.
Boat can take two at a time, black Missonary, red - cannibal
h(n) = 0 is not a heuristic, it is the solution!

Hill Climbing Example Home work 3

Hill Climbing Example Home work 4


Travelling salesman problem
A salesman has a list of cities, each of which he
must visit exactly once. There are direct roads be
tween each pair of cities on the list. Find the rou
te the salesman should follow for the shortest p
ossible round trip that both starts and finishes at
any one of the cities

Hill Climbing Example Home work 4


A good heuristic is
Nearest neighbour heuristic:
1. Select a starting city.
2. Select the one closest to the current city.

3. Repeat step 2 until all cities have been visited.


O(n2) vs. O(n!)

You might also like