methods, techniques, and tools for reasoning (meteor) - *0 ... · tasks di cult for humans have...

217
Methods, techniques, and tools for reasoning (MeTeOR) PART I Emilie Morvant Laboratoire Hubert Curien Universit´ e Jean Monnet de Saint-Etienne 2014 - 2015

Upload: others

Post on 13-Aug-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Methods, techniques, and toolsfor reasoning (MeTeOR)

PART I

Emilie Morvant

Laboratoire Hubert CurienUniversite Jean Monnet de Saint-Etienne

2014 - 2015

Page 2: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Who I am?

• Associate Professor (“Maıtre de Conferences”)at University Jean Monnet, St-Etienne, Franceat the Hubert-Curien Lab in the Machine Learning team

• Research domain (AI)Main area: Machine LearningStatistical Machine Learning TheoryApplications to computer vision

• How to reach me ?By mail : [email protected]

Emilie Morvant MeTeOR — PART I 2014/15 1

Page 3: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Outline

• From me : 12h

I PART I: Introduction to AI

• From Elisa Fromont and Michael Perrot :I PART II: SimplexI PART III: PROLOG and constraint

programming

Emilie Morvant MeTeOR — PART I 2014/15 2

Page 4: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Outline of PART I

1 General Introduction to Artificial Intelligence (AI)

2 Problem Solving and Uninformed SearchI Problem representationI Depth-first search, Breadth-first search, Uniform search, Iterative

deepening. . .I Problem decomposition (AND/OR tree)

3 Heuristic (informed) Search (A*, AO*,. . . )

Emilie Morvant MeTeOR — PART I 2014/15 3

Page 5: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Introduction to AI

Page 6: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AI found on the Web. . .

• AI is the simulation of intelligent human processes

• AI is the reproduction of the methods or results of human reasoningor intuition

• AI is the study of mental faculties through the use computationalmethods

• Using computational models to simulate intelligent behavior

• Machines to emulate humans

Emilie Morvant MeTeOR — PART I 2014/15 5

Page 7: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Why AI?

Cognitive Science

As a way to understand how natural minds and mental phenomena worke.g., visual perception, memory, learning, language, etc.

Philosophy

As a way to explore some basic and interesting (and important) philo-sophical questionse.g., what is consciousness, the mind body problem, etc.

Engineering

To get machines to do a wider variety of useful thingse.g., understand spoken natural language, recognize individual people in visual

scenes, find the best travel plan for your vacation, etc.

Emilie Morvant MeTeOR — PART I 2014/15 6

Page 8: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Weak Vs. Strong AI

Weak AIMachines can be made to behave as if they were intelligent

Strong AI

Machines can have consciousness

Subject of fierce debate, usually among philosophers and nay-sayers,not so much among AI researchers!e.g., http://groups.yahoo.com/group/webir/message/1002

Emilie Morvant MeTeOR — PART I 2014/15 7

Page 9: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AI characterizations

Charaterizations of AI

Discipline that systematizes and automates intellectualtasks to create machines that

Act like humans Act rationally

Think like humans Think rationally

Emilie Morvant MeTeOR — PART I 2014/15 8

Page 10: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Act like humans

• AI is the art of creating machines that perform functions that requireintelligence when performed by humans

• Methodology: Take an intellectual task at which people are betterand make a computer do it

• Turing test (next slide) Prove a theoremPlay chess

Plan a surgical operationDiagnose a disease

Navigate in a building

Emilie Morvant MeTeOR — PART I 2014/15 9

Page 11: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Turing test

• Interrogator interacts with a computer and a person via a teletype

• Computer passes the Turing test if interrogator cannot determinewhich is which

• Loebner contest:I Modern version of Turing Test, held annually, with a $ 100, 000 prizeI a Set of humans, and a set of computers, and a set of judgesI Scoring: Rank from least human to most humanI Highest median rank wins $2, 000I If better than a human, win $100, 000 (Nobody yet. . . )

Emilie Morvant MeTeOR — PART I 2014/15 10

Page 12: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Chess

Garry Kasparov Vs Deep Blue

Emilie Morvant MeTeOR — PART I 2014/15 11

Page 13: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Perspective on Chess

Pro

“Saying Deep Blue doesn’t really think about chess is like saying anairplane doesn’t really fly because it doesn’t flap its wings”

Drew McDermott

Con

“Chess is the Drosophila of artificial intelligence. However, computerchess has developed much as genetics might have if the geneticists had

concentrated their efforts starting in 1910 on breeding racingDrosophila. We would have some science, but mainly we would have

very fast fruit flies.”

John McCarthy

Emilie Morvant MeTeOR — PART I 2014/15 12

Page 14: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Think like humans

• How the computer performs functions does matter

• Comparison of the traces of the reasoning steps

• Cognitive science

→ testable theories of the workings of the human mind

• Connection with Psychology• General Problem Solver(Newell and Simon)

• Neural networks• Reinforcement learning

But• Role of physical body, senses, andevolution in human intelligence?• Do we want to duplicate human im-perfections?

Emilie Morvant MeTeOR — PART I 2014/15 13

Page 15: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Think/Act rationally

• Always make the best decision given what is available (knowledge,

time, resources)

• Perfect knowledge, unlimited resources → logical reasoning

• Imperfect knowledge, limited resources → (limited) rationality

• Connection to economics, operational research, and control theory

• But ignores role of consciousness, emotions, fear of dying on intelligence

Emilie Morvant MeTeOR — PART I 2014/15 14

Page 16: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AI characterizations

Charaterizations of AI

Discipline that systematizes and automates intellectualtasks to create machines that

Act like humans Act rationally

Think like humans Think rationally

Emilie Morvant MeTeOR — PART I 2014/15 15

Page 17: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

History of AI

“I personally think that AI is (was?) a rebellion against some form ofestablishment telling us ”Computers cannot perform certain tasks

requiring intelligence””

Jean-Claude Latombe

Emilie Morvant MeTeOR — PART I 2014/15 16

Page 18: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A little bit of history

• 1956: The name “Artificial Intelligence” was coined by JohnMcCarthy(would “computational rationality” have been better?)

• Early period (50’s to late 60’s): basic principles and generalityI General problem solvingI Theorem provingI GamesI Formal calculus

Emilie Morvant MeTeOR — PART I 2014/15 17

Page 19: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A little bit of history

1969-1971: Shakey the robot(Fikes, Hart, Nilsson)

• Logic-based planning (STRIPS)

• Motion planning (visibility graph)

• Inductive learning (PLANEX)

• Computer vision

Emilie Morvant MeTeOR — PART I 2014/15 18

Page 20: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A little bit of history

Knowledge-is-Power period (late 60’s to mid 80’s):

• Focus on narrow tasks require expertise

• Encoding of expertise in rule form:

If: the car has off-highway tires and

4-wheel drive and

high ground clearance

Then: the car can traverse difficult terrain (0.8)

• Knowledge engineering

• 5th generation computer project

• CYC system (Lenat)

Emilie Morvant MeTeOR — PART I 2014/15 19

Page 21: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A little bit of history

AI becomes an industry (80’s—present):

• Expert systems:Digital Equipment, Teknowledge, Intellicorp, Du Pont, oil industry,. . .

• Lisp machines: LMI, Symbolics,. . .

• Constraint programming: ILOG

• Robotics: Machine Intelligence Corporation, Adept, GMF (Fanuc), ABB,. . .

• Speech understanding

• Information Retrieval: Google,. . .

Emilie Morvant MeTeOR — PART I 2014/15 20

Page 22: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Where are we now?

• SKICAT: a system for automatically classifying the terabytes of data from

space telescopes and identifying interesting objects in the sky

(94% classification accuracy, exceeds human abilities)

• Deep Blue: the first computer program to defeat champion Garry Kasparov

• Pegasus: a speech understanding program that is a travel agent

• Jupiter: a weather information

• HipNav: a robot hip-replacement surgeon

• Navlab: a Ford escort that steered itself from Washington DC to San Diego

98% of the way on its own!

• google news: autonomous AI system that assembles “live” newspaper

• DS1: a NASA spacecraft that did an autonomous flyby an asteroid

• Credit card fraud detection and loan approval

• Search engines: citeseer.com, auto. classif. and indexing of research papers

• Proverb: solves NYT puzzles as well as the best humans

Emilie Morvant MeTeOR — PART I 2014/15 21

Page 23: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Surprises in AI research

Tasks difficult for humans have turned out to be “easy”

Chess

Checkers, Othello, Backgammon

Logistics planning

Airline scheduling

Fraud detection

Sorting mail

Proving theorems

Crossword puzzles

Emilie Morvant MeTeOR — PART I 2014/15 22

Page 24: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Surprises in AI research

Tasks easy for humans have turned out to be hard

Speech recognition

Face recognition

Composing music/art

Autonomous navigation

Motor activities (walking)

Language understanding

Common sense reasoning(eg, how many legs does a fish have?)

image source: http://xkcd.com

Emilie Morvant MeTeOR — PART I 2014/15 23

Page 25: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Why is AI hard?

simple syntactic manipulation is not enough

Machine Translation

• Big project in 1957 following Sputnik launch

• Translation of Russian documents

“The spirit is willing but the flesh is weak”“The vodka is strong but the meat is rotten”

Emilie Morvant MeTeOR — PART I 2014/15 24

Page 26: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

ELIZA: a “psychoterapist” programm

ELIZA simulates a psychotherapist interacting with a patient

• Coded at MIT during 1964-1966 by Joel Weizenbaum

• First script was DOCTORI simple collection of syntactic patterns not unlike regular expressionsI each pattern had a reply which might include bits of the input after

simple transformations s.t. my → your

• Weizenbaum was shocked at reactions:I Psychiatrists thought it had potentialI People unequivocally anthropomorphizedI Many thought it solved the NL problem

• Try typing Meta-x doctor in Emacs

• Recent Loebner Prize winner, http://www.alicebot.org/

Emilie Morvant MeTeOR — PART I 2014/15 25

Page 27: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Colby’s PARRY

• Kenneth Colby modeled aparanoid using the sametechniques circa 1968

• PARRY has basic emotions

If it gets angry, its repliesbecome more hostile

• In a Turing test, expertpsychiatrists were unable todistinguish PARRY’sramblings from those of realparanoids

H: Good afternoon. My name is DoctorJones.P: Pleased to meet you.H: How are you?P: All right I guess.H: Could you tell me your name?P: Pat Smith.H: I though you might have some prob-lems.P: I’ve been upset lately.H: By what?P: People get on my nerves sometimes.H: Tell me more.P: Do you know anything about bookies?. . .

Emilie Morvant MeTeOR — PART I 2014/15 26

Page 28: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

PARRY meets ELIZA. . .

P: I don’t understand your motives.E: Why don’t you understand my motives?P: Shouldn’t I be?E: Why do you say that just now?P: That’s just the way it is.E: Suppose that’s the way it were not.P: So?E: I am not sure I understand you fully.P: You harp on the same questions too much.E: What does that similarity suggest to you?P: I don’t get you.E: Do you wish that you did get I?. . .

Please tell methis is not AI!!

Emilie Morvant MeTeOR — PART I 2014/15 27

Page 29: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Why is AI hard?

Mainly because of the computational intractability

AI goal defined before notion of NP-completeness• people thought to solve larger problems we simply need larger and fastercomputers• didn’t understand the notion of exponential growth

ALL of the algorithms we will study will be computational intractable(NP-complete as best) in the WORST case. . .

How does the fact that we are dealing with the REAL WORLD make solving

these computationally challenging problems feasible IN PRACTICE?

Emilie Morvant MeTeOR — PART I 2014/15 28

Page 30: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Little recall about complexity

• Polynomial P (sort, shortest path...)

• Neither polynomial, nor exponential NP(planning, TSP, diagnostic. . . )

• Exponential by nature E (search for the subsets of a set)

Emilie Morvant MeTeOR — PART I 2014/15 29

Page 31: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Complexity class P

• Deterministic in nature

• Solved by conventional computers in worst-case polynomial time

O(1) ConstantO(log n) Sub-linearO(n) LinearO(n log n) Nearly LinearO(n2) Quadratic

• Polynomial upper and lower bounds

Emilie Morvant MeTeOR — PART I 2014/15 30

Page 32: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Complexity class NP

• Problems that can be non-deterministically solved un apolynomial time

• choose(b):choose a bit in a non-deterministic way and assign to b

• If someone tells us the solution to a problem,then we can verify it in polynomial time

• Two properties:I non-deterministic method to generate possible solutionsI deterministic method to verify in polynomial time that the solution is

correct

Emilie Morvant MeTeOR — PART I 2014/15 31

Page 33: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Relation between P and NP

• P is a subset of NP

• The big question: P? =?NP

• If a language L is in NP ,then the complement of L is in co − NP

• co − NP 6= NP

• P 6= co − NP

Emilie Morvant MeTeOR — PART I 2014/15 32

Page 34: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Polynomial-time reducibility

A language L is polynomial-time reducible to languageM if there is a function computable in polynomial timethat takes an input x to L and transforms it to an inputf (x) to M , s.t. x ∈ L if and only if f (x) ∈ M

Notation

Lpoly−→ M means L is polynomial-time reducible to M

Emilie Morvant MeTeOR — PART I 2014/15 33

Page 35: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

NP-hard and NP-complete

• A language M is NP-hard if every other language L in NP ispolynomial-time reducible to M

• For every L that is a member of NP , Lpoly−→ M

• If language M isI NP-hardI and also in the class of NP itself,⇒ then M is NP-complete

Emilie Morvant MeTeOR — PART I 2014/15 34

Page 36: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Little recall about complexity

Emilie Morvant MeTeOR — PART I 2014/15 35

Page 37: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Examples of typical AI problems

• Problems that involve combinatorics

Example

SEND + MORE = MONEY =⇒ 10!/2 = 1, 814, 400 possibilities!!!

Solution: O=0, M=1, Y=2, E=5, N=6, D=7, R=8 et S=9

• Problems which need a heuristic (heuriskein = find) tointegrate some knowledge, some know-how. . .

Example: Chess =⇒ 10160 possibilities!!!

Emilie Morvant MeTeOR — PART I 2014/15 36

Page 38: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

The mission: a tour around the world

Emilie Morvant MeTeOR — PART I 2014/15 37

Page 39: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

The problem: Traveling costs money

Emilie Morvant MeTeOR — PART I 2014/15 38

Page 40: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

TSP : Traveling Salesman Problem

Traveling Salesman Problem

Instance: a complete weighted undirected graph G = (V ,E )(all weights are non-negative)

Problem: to find a Hamiltonian cycle of minimal cost

c©D.Moshkovitz, Complexity

Emilie Morvant MeTeOR — PART I 2014/15 39

Page 41: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Polynomial algorithm for TSP?

One possible solution?

What about the greedy strategy?At any point, choose the closest vertex not explored yet?

Answer

The greedy strategy fails!!!Example:

c©D.Moshkovitz, Complexity

Emilie Morvant MeTeOR — PART I 2014/15 40

Page 42: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

TSP is a difficult problem

TSP is NP-hard andits corresponding decision problem is NP-complete

The corresponding decision problem

Instance: a complete weighted undirected graph G = (V ,E )and a number k

Problem: to find a Hamiltonian cycle whose cost is at most k

Remarks:

• A TSP with 10 cities has 181, 000 possibles circuits

• A TSP with 20 cities has 10, 000, 000, 000, 000, 000 possibles circuits

• A TSP with 50 cities has 1062 possibles circuits(There is 1021 litres of water on earth. . . )

Emilie Morvant MeTeOR — PART I 2014/15 41

Page 43: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem solving?

Page 44: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Well defined problems

• A problem is generally stated informally (in natural language), ithas to be “formalized” before being presented to a machine

• This problem representation has to be “good” because themachine cannot come back on this step

Examples in math

• Informal utterance/statement: Find the solution for x2 − 9

• Formal utterance: Find {x |x2 − 9 = 0}

• Don’t you already give the solution?

• What about {x |(x − 3)(x + 3) = 0}?

Emilie Morvant MeTeOR — PART I 2014/15 43

Page 45: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Four horses

Informal utterance :

Swap (whenever possible) the twowhite horses with the black oneswith as few movement as possible

Emilie Morvant MeTeOR — PART I 2014/15 44

Page 46: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Four horses

Well defined problem:

• Get rid of the board

• Model the move

• Name the different states

Emilie Morvant MeTeOR — PART I 2014/15 45

Page 47: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Four horses

Another representation:

−→

Emilie Morvant MeTeOR — PART I 2014/15 46

Page 48: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Four horses

Another representation:

• Adjacent points

⇔ position reachable in 1 move

• Swap the positions in circle

Emilie Morvant MeTeOR — PART I 2014/15 47

Page 49: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Four horses

Another representation:

SolutionMake all the pieces do half a turn

=⇒ 4 moves per horse = 16 moves

Emilie Morvant MeTeOR — PART I 2014/15 48

Page 50: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Well defined problems and solutions

A problem• Initial state

• Actions and Successor functionaction might have precondistions to be applicable

• Goal test (to identify if the current state is the goal to reach)

• Path cost

Emilie Morvant MeTeOR — PART I 2014/15 49

Page 51: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Water pouring

Given a 4 gallon bucket and a 3 gallon bucket, how can we measureexactly 2 gallons into one bucket?

• There are no markings on the bucket

• You can empty a bucket completely

• You must fill each bucket completely

• Initial state:The buckets are empty, represented by the tuple (0, 0)

• Goal state:One of the buckets has two gallons of water in itRepresented by either (x , 2) of (2, x)

• Path cost: 1 per unit step

Emilie Morvant MeTeOR — PART I 2014/15 50

Page 52: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Water Pouring

• Actions and Sucessor function:

Fill a bucket(x , y) → (3, y)(x , y) → (x , 4)

Empty a bucket(x , y) → (0, y)(x , y) → (x , 0)

For contents of one bucket into another(x , y) → (0, x + y) or (x + y − 4, 4)(x , y) → (x + y , 0) or (3, x + y − 3)

What about preconditions ?

Emilie Morvant MeTeOR — PART I 2014/15 51

Page 53: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Production rules for Water Jug problem

The operators to be used to solve the problem can be described as follows:

Current state Next State Description

1 (x , y) if x<4 (4, y) Fill the 4 gallon jug

2 (x , y) if y<3 (x , 3) Fill the 3 gallon jug

3 (x , y) if x>0 (x−d , y) For some water out of the 4-gallon jug

4 (x , y) if y>0 (x , y−d) For some water out of the 3-gallon jug

5 (x , y) if x>0 (0, y) Empty the 4 gallon jug

6 (x , y) if y>0 (x , 0) Empty the 3 gallon jug on the ground

7 (x , y) if x+y≥4 (4, y−(4−x)) For water from the 3-gallon jug intoand y>0 the 4-gallon jug until the 4-gallon jug is full

8 (x , y) if x+y≥3 (x−(3−y), 3) For water from the 4-gallon jug into theand x>0 3-gallon jug until the 3-gallon jug is full

9 (x , y) if x+y≤4 (x+y , 0) For all the water from the 3-gallon jugand y>0 into the 4-gallon jug

10 (x , y) if x+y≤3 (0, x+y) For all the water from the 4-gallon jugand x>0 into the 3-gallon jug

11 (0, 2) (2, 0) For the 2 gallons from 3-gallon juginto the 4-gallon jug

12 (2, y) (0, y) Empty the 2 gallons in the 4-gallon jug

Emilie Morvant MeTeOR — PART I 2014/15 52

Page 54: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: To solve the water jug problem

• Required a control structure that loops through asimple cycle in which some rule whose left-sidematches the current state is chosen, the appropriatechange to the state is made as described in thecorresponding right-side, and the resulting state ischecked to see if it corresponds to goal state

• One solution to the problem:Shortest such sequence will have an impact on thechoice of appropriate mechanism to guide the searchfor solution

Emilie Morvant MeTeOR — PART I 2014/15 53

Page 55: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Water Pouring

Gallons in theGallons in the Rule

4-gallon jug 3-gallon jug applied

0 0 2

0 3 9

3 0 2

3 3 7

4 2 5 or 12

0 2 9 or 11

2 0

Emilie Morvant MeTeOR — PART I 2014/15 54

Page 56: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Puzzle

• States:Description of the 8 tiles and location of the blank tile

• Successor Function:Generates the legal states from trying the four actions{Left, Right, Up, Down}

• Goal Test:Checks if the state matches the goal configuration

• Path Cost:Each step costs 1

7 2 4

5 6

8 3 1

Goal config:

1 2 3

4 5 6

7 8

Emilie Morvant MeTeOR — PART I 2014/15 55

Page 57: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Puzzle

Emilie Morvant MeTeOR — PART I 2014/15 56

Page 58: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Eight Puzzle: More formally (exercise)

• 3× 3 Matrix M

• Blank tile: (lv , cv)

• Function UPI Precondition: lv > 1I Effect:

M[lv , cv ]← M[lv − 1, cv ]lv ← lv − 1

• Write DOWN, LEFT, RIGHT

4 3 5

1 6 2

7 8

1 2 3

8 4

7 6 5

Emilie Morvant MeTeOR — PART I 2014/15 57

Page 59: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Puzzle

Eight puzzle is from a family of “sliding-block puzzles”

• NP-Complete

• 8-puzzle has 9!2 = 181, 440 states

• 15-puzzle has approx. 1.3× 1012 states

• 24-puzzle has approx. 1× 1025 states

Emilie Morvant MeTeOR — PART I 2014/15 58

Page 60: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Queens

• Place eight queens on a chess board suchthat no queen can attack another queen

• No path cost because only the final statecounts!

• Incremental formulations

• Complete state formulations

Emilie Morvant MeTeOR — PART I 2014/15 59

Page 61: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Queens

• States:Any arrangement of 0 to 8 queens

• Initial state:No queen on the board

• Successor function:Add a queen to an empty square

• Goal test:8 queens on the board and none are at-tacked

• 64×63×· · ·×57 = 1.8×1014 possiblesequences. . . OUCH!!!!

Emilie Morvant MeTeOR — PART I 2014/15 60

Page 62: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Eight Queens

• States:Arrangements of n queens, one per col-umn in the leftmost n columns, with noqueen attacking another are states

• Successor function:Add a queen to any square in theleftmost empty column such that itis not attacked by any other queenTo be formalized!

• 2, 057 sequences to investigate

Emilie Morvant MeTeOR — PART I 2014/15 61

Page 63: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Map Planning

• Initial state: e.g., “At Arad”• Successor function: A set of action state pairs

e.g., S(Arad) = {(Arad → Zerind ,Zerind)}• Goal test: e.g., “x=At Bucharest”• Path Cost: Sum of the distances traveled

Emilie Morvant MeTeOR — PART I 2014/15 62

Page 64: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Searching for solutions

• Having formulated some problems. . . how do we solvethem?

• Search through a state space

• Use a search tree that is generated with an initial stateand successor functions that define the state space

Emilie Morvant MeTeOR — PART I 2014/15 63

Page 65: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Searching the state space

• Representing the entire space of problems as state space providesa powerful tool for measuring the structure and complexity ofproblems and analyis of the efficiency, correctness and generalityof solution strategies

• Problem solving is a process of searching the state spacefor a path to a solution

• The choice of which state to expand is determined by the searchstrategy

• The corresponding sequences of state expanifon is represented bya data structure known as a search tree

Emilie Morvant MeTeOR — PART I 2014/15 64

Page 66: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search trees

DefinitionA tree is a graph that:

1 is connected but becomes disconnected on removing any edge

2 is connected and acyclic

3 has precisely one path between any two nodes

Property 3 makes them much easier to search and so we will startwith search on (rooted) trees

Example: Graph/Tree

Graph:

A

B

CD

E

F

G Tree:

A

B

CD

E

F

G

Emilie Morvant MeTeOR — PART I 2014/15 65

Page 67: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Trees — Terminologies

A

B C

D

E

I G

H

F

J

d=0

d=1

d=2

d=3

d=4

• NodesI Root NodeI Children NodeI Parent NodeI Leaves

• Branching FactorI Average number of children

for the nodes of a tree

• The depth, d , of a node isjust the number of edgesaway from the root node

• The depth of a tree is thedepth of the deepest node

I in this case, depth = 4

Emilie Morvant MeTeOR — PART I 2014/15 66

Page 68: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search tree — Romania

Emilie Morvant MeTeOR — PART I 2014/15 67

Page 69: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search tree — Romania

Emilie Morvant MeTeOR — PART I 2014/15 68

Page 70: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search tree — Romania

Emilie Morvant MeTeOR — PART I 2014/15 69

Page 71: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search tree — Romania

Emilie Morvant MeTeOR — PART I 2014/15 70

Page 72: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Ex: the return of the water pouring problem

• Measure 7 litters from these 3 buckets(put 7L in the 9L bucket)

• Same restrictions as before

• The buckets are empty

• Formalize the problem (with precondition for theactions) and show the first level of the search tree

Emilie Morvant MeTeOR — PART I 2014/15 71

Page 73: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

What is the best solution?

• Multiple branches lead to a possible solution

• The best solution depends on the cost function:

I You might not want to spoil waterI You may not be strong enough (or it might make

you more tired to weigh a bucket)I . . .

Emilie Morvant MeTeOR — PART I 2014/15 72

Page 74: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: missionaries and cannibals

Three missionaries and three cannibals are on one side of a river, witha canoe. They all want to get to the other side of the river. Thecanoe can only hold one or two people at a time. At no time shouldthere be more cannibals than missionaries on either side of the river,as this would probably result in the missionaries being eaten.

Formulate this problem and with appropriate representation and drawthe state space.

Emilie Morvant MeTeOR — PART I 2014/15 73

Page 75: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Finding Goals in Trees

• Does the following tree contain a node “I”?

A

B

C

D

EI

G

H

F

J

• Yes. How did you know that? “read it”?

• “Trivial!”: so why the big deal about search?

Emilie Morvant MeTeOR — PART I 2014/15 74

Page 76: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Why is Goal Search Not Trivial?

• Because the graph is not given in a nice picture

• At the start of the search, the search algorithm does not knowI the size of the treeI the shape of the treeI the depth of the goal states

• How big can a search tree be?I say there is a constant branching factor bI and one goal exists at depth dI search tree which includes a goal can have bd different branches

in the tree (worst case)

• Examples:

b = 2, d = 10 : bd = 210 = 1, 024

b = 10, d = 10 : bd = 1010 = 10, 000, 000, 000

Emilie Morvant MeTeOR — PART I 2014/15 75

Page 77: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Finding Goals in Trees: Reality

Does the tree under a given root contain a node “G”?

All you get to see at first is the root nodeand a guarantee that it is a treeThe rest is up to you to discover during the process ofsearch → discover/create “on the fly”

Emilie Morvant MeTeOR — PART I 2014/15 76

Page 78: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Properties of Search

Complete search methodWe will say a search method is “complete” if it has boththe following properties:• if a goal exists then the search will always find it• if no goal exists then the search will eventually finishand be able to say for sure that no goal exists

We only look at complete search methods

Remark: incomplete search methods often work better in practice,but are the topics related to evolutionary algorithms

Emilie Morvant MeTeOR — PART I 2014/15 77

Page 79: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Implementation: Representation

• A node is a bookkeeping data structure from which a search tree isconstructed. It contains information such as: state, parent node,action, path cost g(x), depth• A state is the configuration in the state space to which the nodecorresponds• The Successor-Fn(x) (successor function) returns all states thatcan be reached from state x• Fringe is the collection of nodes that have been generated but not(yet) expanded. Each node of the fringe is a leaf node

Emilie Morvant MeTeOR — PART I 2014/15 78

Page 80: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Implementation: Node representation

Datatype NODE

Components:

STATE,

PARENT-NODE,

OPERATOR,

DEPTH,

PATH-COST

• STATE: This represents the state in the statespace to which a node corresponds

• Parent-Node: This points to the node that gen-erated this node. In a data structure representing atree it is usual to call this the parent node

• OPERATOR: The operator that was applied togenerate this node

• DEPTH: The number of nodes from the root

• PATH-COST: The path cost from the initial stateto this node

Emilie Morvant MeTeOR — PART I 2014/15 79

Page 81: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

How good is a solution?

• Does our search method actually find a solution?

• Is it a good solution?

I Path CostI Search Cost (Time and Memory)

• Does it find the optimal solution?

I But what is optimal?

Emilie Morvant MeTeOR — PART I 2014/15 80

Page 82: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Evaluating a search

• CompletenessIs the strategy guaranteed to find a solution?

• Time ComplexityHow long does it take to find a solution?

• Space ComplexityHow much memory does it take to perform the search?

• OptimalityDoes the strategy find the optimal solution where there areseveral solutions?

Emilie Morvant MeTeOR — PART I 2014/15 81

Page 83: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem Characteristics

In order to choose the most appropriate method for a particular problem,it is necessary to analyze the problem along several key dimensions

1 Is the problem decomposable into a set of independent smaller oreasier subproblems?

2 Can solution steps be ignored or at least undone if they prove unwise?3 Is the problem’s universe predictable?4 Is a good solution to the problem obvious without comparison to all

other possible solutions?5 Is the desired solution a state of the world or a path to a state?6 Is a large amount of knowledge absolutely required to solve the

problem or is knowledge important only to constrain the search?7 Can a computer that is simply given the problem return the solution

or will the solution of the problem require interaction between thecomputer and a person?

Emilie Morvant MeTeOR — PART I 2014/15 82

Page 84: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Uninformed/BLIND SearchStrategies

Page 85: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Outline

Uninformed strategies use only the information availablein the problem definitionAlso known as blind searching

• Breadth-first search

• Uniform-cost search

• Depth-first search

• Depth-limited search

• Iterative deepening search

Key issue: type of queue used for the fringe of the search tree

Emilie Morvant MeTeOR — PART I 2014/15 84

Page 86: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Comparing Uninformed Search Strategies

• CompletenessI Will a solution always be found if one exists?

• TimeI How long does it take to find the solution?I Often represented as the number of nodes searched

• SpaceI How much memory is needed to perform the search?I Often represented as the maximum number of nodes stored at

once

• OptimalI Will the optimal (least-cost) solution be found?

• Time and space complexity are measured inI b — maximum branching factor of the search treeI m — maximum depth of the state spaceI d — depth of the least-cost solution

Emilie Morvant MeTeOR — PART I 2014/15 85

Page 87: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Modified search algorithm

INSERT(initial-node,FRINGE)loop

if FRINGE = ∅ thenreturn FAILURE

end ifCURRENT ← REMOVE(FRINGE)s ← STATE(CURRENT)if GOAL?(s) then

return path or goal stateend iffor state s’ in SUCCESSORS(s) do

Create a node NINSERT(N,FRINGE)

end forend loop

Emilie Morvant MeTeOR — PART I 2014/15 86

Page 88: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Avoiding Repeated States

Complication of wasting time by expanding states that have alreadybeen encountered and expanded before

• Failure to detect repeated states can turn a linear problem intoan exponential one

Sometimes, repeated states are unavoidable

• Problems where the actions are reversable (e.g. Route finding,Sliding blocks puzzles)

Emilie Morvant MeTeOR — PART I 2014/15 87

Page 89: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Avoiding Repeated States

CLOSED ← ∅FRINGE ← INSERT(initial-node,FRINGE)loop

if FRINGE = ∅ then return FAILURECURRENT ← REMOVE-FRONT(FRINGE)if GOAL?(CURRENT) then return CURRENTif STATE(CURRENT) /∈ CLOSED then

CLOSED ← CLOSED ∪ STATE(CURRENT)FRINGE ← INSERTALL(EXPAND(CURRENT),FRINGE)

end ifend loop

Emilie Morvant MeTeOR — PART I 2014/15 88

Page 90: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Running example

Emilie Morvant MeTeOR — PART I 2014/15 89

Page 91: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Breadth-First Search

• Recall from Data Structures the basic algorithm for abreadth-first search on graph or tree

• Expand the shallowest unexpanded node

• Place all new successors at the end of a FIFO queue

Emilie Morvant MeTeOR — PART I 2014/15 90

Page 92: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Breadth-First Search

1

2 3 4

5 6 7 8 9 10

11 12 13 14 15 16 17

Emilie Morvant MeTeOR — PART I 2014/15 91

Page 93: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Properties of the Breadth-First Search

• Complete: Yes if the max branching factor b is finite

• Time:

I 1 + b + b2 + . . . + bd + b(bd − 1) = O(bd+1)I exponential in d

• Space:I O(bd+1)I keeps every node in memory⇒ This is the big probleman: an agent that generates nodes at 10

MB/sec will produce 864, 000 MB in 24 hours

• Optimal: Yes, if cost is 1 per step(not optimal in general)

Emilie Morvant MeTeOR — PART I 2014/15 92

Page 94: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Breadth-first

Travel in romania from S. Russel and P. Norvig

Emilie Morvant MeTeOR — PART I 2014/15 93

Page 95: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Breadth-first

• Try to reach Bucharest from Arad

• Try out the breath-first algorithm in this example(without using the distances)

↪→ evolution of FRINGE and CLOSED

• How many cities did you visit? How many kilometersdid you travel?

Emilie Morvant MeTeOR — PART I 2014/15 94

Page 96: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Lessons From Breadth First Search

The memory requirements are a bigger problem forbreadth-first search than is execution time

Exponential-complexity search problems cannot be solvedby uninformed methods for any but the smallest instances

Emilie Morvant MeTeOR — PART I 2014/15 95

Page 97: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Uniform-Cost Search

Same idea as the algorithm for breadth-first search. . .

but. . .

• Expand the least-cost unexpanded node

• FIFO queue is ordered by cost

• Equivalent to regular breadth-first search if all stepcosts are equal

Emilie Morvant MeTeOR — PART I 2014/15 96

Page 98: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Uniform-Cost Search

1

2 4

3 5 7

6

3616

3 9 50

1

50

421

81822

52

73

8

Emilie Morvant MeTeOR — PART I 2014/15 97

Page 99: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Uniform-Cost Search

• Complete: Yes if the cost is greater than somethreshold ε

• Time:I Complexity cannot be determinated easily by d or bI Let C∗ be the cost of the optimal solution

⇒ O(b1+bC∗/εc

)

• Time: O(b1+bC∗/εc

)• Optimal: Yes, nodes are expanded in increasing order

Emilie Morvant MeTeOR — PART I 2014/15 98

Page 100: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Uniform-Cost Search

Same question as before but with as few kilometers aspossible

Emilie Morvant MeTeOR — PART I 2014/15 99

Page 101: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-First Search

• Recall from Data Structures the basic algorithm for adepth-first search on a graph or tree

• Expand the deepest unexpanded node

• Unexplored successors are placed on a stack (LIFOqueue) until fully explored

Emilie Morvant MeTeOR — PART I 2014/15 100

Page 102: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-First Search

1

2

12

3 11

13

4 10

5

76

8

9

Emilie Morvant MeTeOR — PART I 2014/15 101

Page 103: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-First Search

Emilie Morvant MeTeOR — PART I 2014/15 102

Page 104: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-First Search

• Complete:I No: fails in infinite-depth spaces, spaces with loops

Modify to avoid repeated spaces along pathI Yes: in finite spaces

• Time:I O(bm)I Not great if the maximum depth of state space m is much larger than

the max. branching factor of the search tree dI But if the solutions are dense, this may be faster than breadth-first

search

• Space: O(bm) . . . linear space

• Optimal: No

Emilie Morvant MeTeOR — PART I 2014/15 103

Page 105: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Depth-First Search

Same question as before but with as few kilometers aspossible

Emilie Morvant MeTeOR — PART I 2014/15 104

Page 106: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-Limited Search

• A variation of depth-first search that uses a depthlimit

I Alleviates the problem of unbounded treesI Search to a predetermined depth lI Nodes at depth l have no successors

• Same as depth-first search if l =∞

• Can terminate for FAILURE and CUTOFF

Emilie Morvant MeTeOR — PART I 2014/15 105

Page 107: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-Limited Search—Recursive implementation

function DEPTH-LIMITED-SEARCH(problem,limit)RECURSIVE-DLS(MAKE-NODE(INITIAL-STATE[problem]),problem,limit)

end functionfunction RECURSIVE-DLS(CURRENT,problem,limit)

cutoff-occurred? ← FALSEif GOAL?[problem](STATE(CURRENT)) then

return CURRENTelse if DEPTH(CURRENT) = limit then

return CUTOFFelse

for each SUCCESSOR in EXPAND(CURRENT,problem) doresult ← RECURSIVE-DLS(SUCCESSOR,problem,limit)if result = CUTOFF then

cutoff-occurred? ← TRUEelse if result 6= FAILURE then

return resultend if

end forend ifif cutoff-occurred? then return CUTOFF else return FAILURE

end functionEmilie Morvant MeTeOR — PART I 2014/15 106

Page 108: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Depth-Limited Search

• Complete: Yes if l < d

• Time: O(bl)

• Space: O(bl)

• Optimal: No if l > d

Emilie Morvant MeTeOR — PART I 2014/15 107

Page 109: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Iterative Deepening Search

Iterative deepening depth-first search

• Uses depth-first search

• Finds the best depth limit

• Gradually increases the depth limit:0, 1, 2, . . . until a goal is found

function ITERATIVE-DEEPENING-SEARCH(problem)for depth ← 0 to ∞ do

result ← DEPTH-LIMITED-SEARCH(problem,depth)if result 6= CUTOFF then return result

end forend function

Emilie Morvant MeTeOR — PART I 2014/15 108

Page 110: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Iterative Deepening Search

Emilie Morvant MeTeOR — PART I 2014/15 109

Page 111: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Iterative Deepening Search

Emilie Morvant MeTeOR — PART I 2014/15 110

Page 112: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Iterative Deepening Search

• Complete: Yes

• Time: db1 + (d − 1)b2 + . . . + bd = O(bd)

• Space: O(bd)

• Optimal: Yes if step cost = 1Can be modified to explore uniform cost tree

Emilie Morvant MeTeOR — PART I 2014/15 111

Page 113: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Lessons from Iterative Deepening Search

Faster than Breadth-First Search (BFS) even though IDS generatesrepeated states• BFS generates nodes up to level d + 1• IDS only generates nodes up to level d

In general, iterative deepening search is the preferred uninformedsearch method when there is a large search space and the depth ofthe solution is not known(the redundancies are less expensive than developing the last levels of the tree)

Emilie Morvant MeTeOR — PART I 2014/15 112

Page 114: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Decomposing the problem(or problem reduction)

Page 115: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem reduction (is the problem decomposable?)

Sometimes problems only seem hard to solve.

A hard problem may be one that can be reduced to anumber of simple problems. . .and, when each of the simple problems is solved, thenthe hard problem has been solved.

This is the basic intuition behind the method of problemreduction.

Emilie Morvant MeTeOR — PART I 2014/15 114

Page 116: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: How to get to London?

Planning a trip to London:

• You probably don’t want to search through all the possiblesequences of actions that might get you to London.

• You’re more likely to decompose the problem into simpler ones- such as getting to the station, then getting a train to London.

• There may be more than one possible way of decomposing theproblem - an alternative strategy might be to get to the airport,fly to Heathrow, and get the tube from Heathrow into London.

• These different possible plans would have different costs (andbenefits) associated with them, and you might have to choosethe best plan.

Emilie Morvant MeTeOR — PART I 2014/15 115

Page 117: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem reduction

• The simple state-space search techniques described in the aboveslides could all be represented using a tree where each successor noderepresents an alternative action to be taken

• The graph structure being searched is referred to as an OR graph

• In OR graph we want to find a single path to a goal

• To represent problem reduction techniques we need to use anAND-OR graph/tree

Emilie Morvant MeTeOR — PART I 2014/15 116

Page 118: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem statement

Given• A goal• Operators to decompose the goal into sub-goals• Elementary goals (facts)

Decompose the problem into smaller simplest problemuntil reaching the elementary goals

Emilie Morvant MeTeOR — PART I 2014/15 117

Page 119: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AND/OR graph representation

• Decomposition intosub-problems• (Pi ,O,Psol)• AND/OR graph• Solved node• Unsolvable node• Problem solution

You can have:

AND nodes whose successors must all be achieved: One AND arc maypoint to a number of successor nodes, all of which must be solved in orderfor the arc to point to a solution.

OR nodes where one of the successors must be achieved (ie, they arealternatives): several arcs may emerge from a single node, indicating thevariety of ways in which the original problem might be solved.

Emilie Morvant MeTeOR — PART I 2014/15 118

Page 120: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Tower of Hanoı

Pb: 64 size (in the original pb) ordered disks occupy oneof 3 pegs and must be transferred to one of the otherpegs. But, only one disk can be moved at a time; and alarger disk may never be placed on a smaller disk.

We start at 3 size. . .

Emilie Morvant MeTeOR — PART I 2014/15 119

Page 121: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Notations

Let OP : p ← sp1, sp2,. . . , spn

• The spi are AND-brothers

• OP is their AND-parent

• p is their OR-parent

Emilie Morvant MeTeOR — PART I 2014/15 120

Page 122: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

State space for the 3-Disk Tower of Hanoı problem

Emilie Morvant MeTeOR — PART I 2014/15 121

Page 123: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About the Hanoı state space

• Recall that in state space search the generators correspond tomoves in the state space.

• Thus, the two states below the top state in the triangle of statescorresponds to the movement of the smallest disk either to therightmost peg or to the middle peg.

• The shortest solution to this problem corresponds to the pathdown the right side of the state space.

Emilie Morvant MeTeOR — PART I 2014/15 122

Page 124: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem representation with AND/OR graph

• In problem reduction, searching the problem spaceconsists of an AND/OR graph of (partial) state pairs.These pairs are referred to as (sub)problems.

• The first element of the pair is the starting state ofthe (sub)problemand the second element of the pair is the goal state(sub)problem.

Emilie Morvant MeTeOR — PART I 2014/15 123

Page 125: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Problem reduction

• The symmetry of the state space shown above may have led youto suspect that the Tower of Hanoi problem can be elegantlysolved using the method of problem decomposition.

• AND Tree Showing the Problem Reduction Solution to the3-Disk Tower of Hanoi Problem

• The yellow states are primitive problems

Emilie Morvant MeTeOR — PART I 2014/15 124

Page 126: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise

• Elementary goals : B, C, E, J, L• Decomposition operator

I R1 : A ← B,CI R2 : D ← A,E,FI R3 : D ← A,KI R4 : F ← II R5 : F ← C,JI R6 : D ← G,HI R7 : K ← E,L

• Solve D

• Draw the AND/OR graph

• Draw the solution subgraphs (OR paths)

Emilie Morvant MeTeOR — PART I 2014/15 125

Page 127: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search in AND/OR graphs

NB: solutions are sub-graphs (OR-PATH)

• With graph: we construct an implicit sub-graphcorresponding to the problem

• AND/OR search graph and OR-path as a solution

• With backtracking: we keep only a OR-path inmemory.

Emilie Morvant MeTeOR — PART I 2014/15 126

Page 128: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AND/OR search backtracking algorithm

• 2 types of backtrackI backtrack on ORs (similar to standard depth-first search):

when one branch of the OR fails, we need to try another oneor gives a failure if there are no more branch.

I backtrack on ANDs: if one of the sub-problem fails, thewhole branch fails (there is not need to try theAND-brothers)

• At each choice point (OR branch), one needs tochose:

I the operator to applyI The order in which the sub problems should be explored.

Emilie Morvant MeTeOR — PART I 2014/15 127

Page 129: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Backtracking Algorithm

function SEARCH-AND/OR(pb)if TERMINAL(pb) then return EMPTYif IMPASSE(p) OR DEPTH(pb)>Limit then return FAIL (2)List-op ← OP-APPL(pb) (3)repeat

if List-op = ∅ then return FAILOp ← FRONT(List-op){sp1, . . . , spn} ← OP(p)List-op ← QUEUE(List-op)ESC ← FALSEfor i from 1 to n AND not(ESC) do

DEPTH(spi ) ← DEPTH(p)+1Gri ← SEARCH-AND/OR(spi )if Gri=FAIL then ESC ← TRUE

end foruntil ESC=FALSEreturn OR-path(p,Op,and(Gr1,. . . ,Grn)))

end function

Remarks• Simple implementation

• The algorithm may not terminate (cycles)⇒ need to include a loop detection or limitthe recursion depth arbitrarily

• Line (2) is optional but can avoid to ex-plore a partial solution known to be bad

• We can add a heuristic on Line (3) to“smartly” sort the possible operators

Emilie Morvant MeTeOR — PART I 2014/15 128

Page 130: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Notations for the graph algorithm

• FRINGEset of nodes (sub-problems) that still need to be delt with.

• CLOSEDset of nodes already seen.

• p0initial problem

• Gr-Solpartial solution (OR-path from the root)

• DURINGsubset of FRINGE which contains the current leaves of Gr-Sol

Emilie Morvant MeTeOR — PART I 2014/15 129

Page 131: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AND/OR search with a graph

FRINGE ← {p0}; CLOSED ← { }; Gr-Sol ← OR-path(p0)repeat

choice 1: choice of Gr-Sol1; DURING ← leaves of Gr-Solchoice 2: choice of a node p not primitive in DURING and not in CLOSEDDevelop pTake2 p from FRINGE and DURING, and add it to CLOSEDfor all Op s.t. p → sp1, . . . , spk do

Create a AND-node OP (successor of p)Create k OR-nodes sp1, . . . , spkFRINGE ← FRINGE ∪ {sp1, . . . , spk}

end foruntil DURING = ∅ OR all pbs in DURING are primitivesif DURING = ∅ then return FAIL

1Depends on the heuristic2Can be done depth of breadth or best-first

NB: we can also use pointers on the parents

Emilie Morvant MeTeOR — PART I 2014/15 130

Page 132: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise

• S → A ; S → B ; A → C,D ; B → D,I ; C → F ; F → H ;H → t1 ; F → G ; G → H,I ; I → t2 ; D → G ; D → F

• Draw the AND/OR-graph, S is the initial problem, t1 and t2 areprimitives.

• Show the evolution of FRINGE, DURING, CLOSED for adepth-first and a breadth-first search.

Emilie Morvant MeTeOR — PART I 2014/15 131

Page 133: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Heuristic search

Page 134: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Search Algorithms

• Blind search — BFS, DFS, uniform costI no notion concept of the “right direction”I can only recognize goal once it’s achieved

• Heuristic searchwe have rough idea of how good various states are,and use this knowledge to guide our search

Emilie Morvant MeTeOR — PART I 2014/15 133

Page 135: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Best-first search

• Idea: use an evaluation function f (n) for ech nodeI Estimate of desirability

• Expand most desirable unexpanded node

• Implementation: FRINGE is queue sorted bydecreasing order of desirability

I Greedy searchI A* search

Emilie Morvant MeTeOR — PART I 2014/15 134

Page 136: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Heuristic

Webster’s Revised Unabridged Dictionary (1913) (web1913)

Heuristic \Heu*ris”tic\, a. [Greek. to discover.] Serving to discover or find out.

The Free On-line Dictionary of Computing (15Feb98)

heuristic 1. <programming> A rule of thumb, simplification or educated guessthat reduces or limits the search for solutions in domains that are difficult andpoorly understood. Unlike algorithms, heuristics do not guarantee feasible solu-tions and are often used with no theoretical guarantee. 2. <algorithm> approx-imation algorithm.

From WordNet (r) 1.6

heuristic adj 1: (computer science) relating to or using a heuristic rule 2: ofor relating to a general formulation that serves to guide investigation [ant:algorithmic] n : a commonsense rule (or set of rules) intended to increase theprobability of solving some problem [syn: heuristic rule, heuristic program]

Emilie Morvant MeTeOR — PART I 2014/15 135

Page 137: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Informed search

• Add domain-specific information to select the best path alongwhich to continue searching

• Define a heuristic function, h(n), that estimates the “goodness”of a node n

• Specifically, h(n) = estimated cost (or distance) of minimalcost path from n to a goal state

• The heuristic function is an estimate, based on domain-specificinformation that is computable from the current statedescription, of how close we are to a goal

Emilie Morvant MeTeOR — PART I 2014/15 136

Page 138: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Greedy search

Greedy best-first

Tries to expand the node that is closest to the goal, on thegrounds that is likey to lead to a solution quickly

f (n) = h(n)

FRINGE ← {initiale-node}while FRINGE 6= ∅ do

CURRENT ← REMOVE-FRONT(FRINGE)if GOAL(CURRENT) then return PATH TO(CURRENT)for all op ∈ List op(CURRENT) do

SUCCESSOR←op(CURRENT)FRINGE ← INSERT-ORDERED(FRINGE,SUCCESSOR) 1

end forend whilereturn FAILURE

1 Order the nodes in the fringe in increasing values of h(n)

Emilie Morvant MeTeOR — PART I 2014/15 137

Page 139: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Robot navigation

Emilie Morvant MeTeOR — PART I 2014/15 138

Page 140: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Robot navigation

f (n) = h(n), with h(n) = Manhattan distance to the goal

Emilie Morvant MeTeOR — PART I 2014/15 139

Page 141: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Robot navigation

f (n) = h(n), with h(n) = Manhattan distance to the goal

Emilie Morvant MeTeOR — PART I 2014/15 140

Page 142: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Greedy Search

• f (n) = h(n) → Greedy best-first

• Is it complete?

↪→ If we eliminate endless loops, yes

• Is it optimal?

↪→ In general, no

Emilie Morvant MeTeOR — PART I 2014/15 141

Page 143: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About Heuristics

• Heuristics are intended to orient the search along promising paths

• The time spent computing heuristics must be recovered by abetter search

• After all, a heuristic function could consist of solving theproblem; then it would perfectly guide the search

• Deciding which node to expand is sometimes calledmeta-reasoning

• Heuristics may not always look like numbers and may involvelarge amount of knowledge

Emilie Morvant MeTeOR — PART I 2014/15 142

Page 144: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example with the n queens

A possible heuristic?

From one configuration, we canmove a queen to have the less aspossible attacks

⇔ we move the less forked one

Emilie Morvant MeTeOR — PART I 2014/15 143

Page 145: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Heuristic for the glass problem

• One possible action: flip 2 adjacent glasses

• Show the search space usingf 1 = “the number of misplaced glasses”

• Show the search space withf 2 = “the distance between the two furthest misplaced glasses”

Nb: f (e0) = 4, f (ef ) = 0

Emilie Morvant MeTeOR — PART I 2014/15 144

Page 146: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

More informed search

• We kept looking at nodes closer and closer to the goal,but were accumulating costs as we got further from the initialstate

• Our goal is not to minimize the distance from the current headof our path to the goal,we want to minimize the overall length of the path to thegoal!

• Let g(n) be the cost of the best path found so far between theinitial node and N

f (n) = g(n) + h(n)

Emilie Morvant MeTeOR — PART I 2014/15 145

Page 147: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Robot navigation

f (n) = g(n) + h(n), with h(n) =“Manhattan distance to goal”

Emilie Morvant MeTeOR — PART I 2014/15 146

Page 148: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Can we Prove Anything?

• If the state space is finite and we avoid repeatedstates,

⇒ the search is complete, but in general is not optimal

• If the state space is finite and we do not avoidrepeated states,

⇒ the search is in general not complete

• If the state space is infinite,

⇒ the search is in general not complete

Emilie Morvant MeTeOR — PART I 2014/15 147

Page 149: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Admissible Heuristic

Admissible heuristic

Let h∗(N) be the true cost of the optimal path from N to a goal.

We way that the heuristic h(n) is admissible if:

0 ≤ h(n) ≤ h∗(N)

NB: An admissible heuristic is always optimistic

Emilie Morvant MeTeOR — PART I 2014/15 148

Page 150: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A* Search

A* SearchLet f (n) be the evaluation function defined as

f (n) = g(n) + h(n)

where:• g(n) is the cost of the best path found so far to N• h(n) is an admissible heuristic

Then, best-first search with this evaluation function iscalled A* search

Important AI algorithm developed by Fikes and Nilsson in early 70s(Originally used in Shakey robot)

Emilie Morvant MeTeOR — PART I 2014/15 149

Page 151: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Components of A*

Emilie Morvant MeTeOR — PART I 2014/15 150

Page 152: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

A* Algorithm

FRINGE ← {e0}; CLOSED ← {}loop

if FRINGE = ∅ then return FAILURECURRENT ← argmin

X∈FRINGE(f (X )) (X s.t. f (X ) is minimum)

if CURRENT is a solution then return CURRENTFRINGE ← FRINGE − {CURRENT}CLOSED ← CLOSED ∪ {CURRENT}for all op ∈ List op(CURRENT) do

SUCCESSOR←op(CURRENT)if SUCCESSOR ∈ (FRINGE ∪ CLOSED) ANDg(SUCCESSOR) > g(CURRENT) + cost(op) 1 then

parent(SUCCESSOR) =CURRENTg(SUCCESSOR) = g(CURRENT) + cost(op)FRINGE ← FRINGE ∪ {SUCCESSOR}

end ifend for

end loop1 if SUCCESSOR is already seen then the new path to SUCCESSOR must be shorter

Emilie Morvant MeTeOR — PART I 2014/15 151

Page 153: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example A*

Emilie Morvant MeTeOR — PART I 2014/15 152

Page 154: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Completness and Optimality of A*

Claim 1If there is a path from the initial to a goal node, A* (withno removal of repeated states) terminates by finding thebest path, hence is:

• complete

• optimal

Requirements

0 < ε < c(N ,N ′)

Each node has a finite number of successors

Emilie Morvant MeTeOR — PART I 2014/15 153

Page 155: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Completness and Optimality of A*

Theorem — Completness of A*

If there is a finite path from the initial state to a goal node, A* will find it

Proof• Let g∗ be the cost of a best path to a goal node• No path in search tree can get longer than g∗

ε , before the goal node is expanded

Theorem — Optimality of A*

If h(n) is admissible, then A* is optimal

Proof

Emilie Morvant MeTeOR — PART I 2014/15 154

Page 156: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Heuristic function

Function h(n) that estimates the cost of the cheapest path fromnode N to goal node

Example: 8-puzzle

7 2 45 68 3 1

−→1 2 34 5 67 8

initial state goal state

h(n) = number of misplaced tiles = 6

OR h(n) = sum of the distances of every tile to its goal position

= 4 + 0 + 3 + 3 + 1 + 0 + 2 + 1 = 14

Emilie Morvant MeTeOR — PART I 2014/15 155

Page 157: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: 8-puzzle

f (n) = h(n) = number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 156

Page 158: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: 8-puzzle

f (n) = g(n) + h(n) with h(n) = number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 157

Page 159: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: 8-puzzle

f (n) = h(n) =∑

distances of tiles to goal

Emilie Morvant MeTeOR — PART I 2014/15 158

Page 160: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: 8 puzzle

Another Heuristic

h(n) = (sum of the distances of each tile to its goal position)

+ 3 × (sum of score functions for each tile)

where score function for a non-central tile is 2 if it is not followed bythe correct tile in clockwise order and 0 otherwise

5 84 3 17 3 6

−→1 2 34 5 67 8

initial state goal state

h(n) = (2 + 3 + 0 + 1 + 3 + 0 + 3 + 1)

+ 3× (2 + 2 + 2 + 2 + 2 + 0 + 2)

= 49

Emilie Morvant MeTeOR — PART I 2014/15 159

Page 161: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: 8 puzzle

What can we say about the previous heuristic functions?

• h1(N) = number of misplaced tiles

↪→ is admissible

• h2(N) = sum of distances of each tile to goal

↪→ is admissible

• h3(N) = (sum of distances of each tile to goal) +3× (sum ofscore functions for each tile)

↪→ is not admissible

Emilie Morvant MeTeOR — PART I 2014/15 160

Page 162: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

The return of the robot

f (n) = g(n) + h(n), with h(n) = straight-line distance from N to goal

Cost of one horizontal/vertical step = 1

Cost of one diagonal step = 2

Emilie Morvant MeTeOR — PART I 2014/15 161

Page 163: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About repeated states

The heuristic h is clearly admissible

Emilie Morvant MeTeOR — PART I 2014/15 162

Page 164: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About repeated states

If we discard this new node, then the search algorithm expands thegoal node next and returns a non-optimal solution

Emilie Morvant MeTeOR — PART I 2014/15 163

Page 165: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About repeated states

Instead, if we do not discard nodes revisiting states, the searchterminates with an optimal solution

Emilie Morvant MeTeOR — PART I 2014/15 164

Page 166: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

About repeated states

But

If we do not discard nodes revisiting states,⇒ the size of the search tree can be exponential in the number ofvisited states

2n + 1 states O(2n) nodes

Emilie Morvant MeTeOR — PART I 2014/15 165

Page 167: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Consistent Heuristic

Consistent HeuristicThe admissible heuristic h is consistent (or satisfies the monotonerestriction) if for every node N and every successor N’of N:

h(n) ≤ c(N ,N ′) + h(N ′)

NB: A consistent heuristic is also admissible

IntuitionA consistent heuristic becomes more precise as we get deeper in thesearch tree

Emilie Morvant MeTeOR — PART I 2014/15 166

Page 168: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Examples

h(n) = 0

• h(n) = 0 for all nodes is admissible and consistent

⇒ Hence, breadth-first and uniform-cost are particular cases ofA*!!!

8-puzzle

• h1(N) = number of misplaced tiles

• h2(N) = sum of distances of each tile to goal

⇒ are both consistent

Robot Navigation

• h(n) = straight-line distance from N to goal

⇒ is consistent

Emilie Morvant MeTeOR — PART I 2014/15 167

Page 169: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Claims on Consistent Heuristic

Claim 1If h is consistent,⇒ the function f along any path is non-decreasing:

f (n) = g(n) + h(n)f (N ′) = g(n) + c(N ,N ′) + h(N ′)h(n) ≤ c(N ,N ′) + h(N ′)f (n) ≤ f (N ′)

Claim 2If h is consistent, then whenever A* expands a node it has alreadyfound an optimal path to the state associated with this node

Emilie Morvant MeTeOR — PART I 2014/15 168

Page 170: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Avoiding Repeated States in A*

If the heuristic h is consistent, then:• Let CLOSED be the list of states associated with expanded nodes

When a new node N is generated:• If its state is in CLOSED, then discard N

• If it has the same state as another node in the fringe,then discard the node with the largest f

Emilie Morvant MeTeOR — PART I 2014/15 169

Page 171: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Heuristic Accuracy

Let h1 and h2 be two admissible and consistent heuristicssuch that for all nodes N:

h1(N) ≤ h2(N)

⇒ Then, every node expanded by A* using h2 is alsoexpanded by A* using h1

h2 is said more informed (or more accurate) than h1

Emilie Morvant MeTeOR — PART I 2014/15 170

Page 172: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Travel in Romania with A*

• We want to travel the least number of kilometers from Arad toBucharest

• What is g ? What is h ? Run A*

Emilie Morvant MeTeOR — PART I 2014/15 171

Page 173: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise: Travel in Romania with A*

Emilie Morvant MeTeOR — PART I 2014/15 172

Page 174: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Iterative Deepening A* (IDA*)

Principle of IDA*

Use f (n) = g(n) + h(n)where h is admissible and consistent

Each iteration corresponds to depth-first with cutoff onthe value of f of expanded nodes

cutoff ← f (initial-node)loop

DEPTH-FIRST by expanding all nodes N s.t. f (n) ≤cutoffcutoff ← smallest value f of non-expanded (leaf) nodes

end loop

Emilie Morvant MeTeOR — PART I 2014/15 173

Page 175: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 174

Page 176: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 175

Page 177: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 176

Page 178: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 177

Page 179: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 178

Page 180: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 179

Page 181: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 180

Page 182: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 181

Page 183: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 182

Page 184: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 183

Page 185: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 184

Page 186: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

IDA* on 8-puzzle

f (n) = g(n) = h(n), with h(n) =number of misplaced tiles

Emilie Morvant MeTeOR — PART I 2014/15 185

Page 187: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Advantages and Drawbacks of IDA*

• Pros

I Still complete and optimalI Requires less memory than A*I Avoid the overhead to sort the fringe

• Cons

I Can’t avoid revisiting states not on the currentpath

I Available memory is poorly used

Emilie Morvant MeTeOR — PART I 2014/15 186

Page 188: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

AO* = A* for AND/OR graphs

• Recursive definition of the cost of a solution graph g(p)

I if p is terminal, c(g(p)) = 0

I if not, c(g(p)

)= cost(Op) +

∑ni=1 c

(g(spi)

)where Op is such that Op : p 7→ sp1, . . . , spn

(Ex: cost(Op) = n)

• Heuristic h such thath(p) = static estimation of the minimal cost to solve the pb p(h(t) = 0 if t is terminal)

(Ex: distance as the crow flies between 2 cities)

Emilie Morvant MeTeOR — PART I 2014/15 187

Page 189: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Principle of AO* algorithm

“best problem first”

1 Develop at each step the best problem according to the fact thatit belongs to the best known-so-far solution graph and accordingto h

2 Refine (update) the scores of each nodes according to thedevelopment done so far, i.e. replace h(p) by a dynamicalestimation which takes the cost of the decomposition applicableto p into account:

f (p) = minOp

[cost(Op) +

n∑i=1

f (spi)

]

with Op : p 7→ sp1, . . . , spnNB: when the node is not yet developed: f (spi) = h(spi)

Emilie Morvant MeTeOR — PART I 2014/15 188

Page 190: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Sketch of AO* algorithm

FRINGE ← {p0} CLOSED ← ∅ DURING ← {p0}while DURING 6= ∅ AND nodes in DURING are not primitives do

p ← REMOVE(DURING)for all opi ∈ List op(p) do

sp ← op(p)FRINGE ← INSERT(FRINGE,sp)fi ← cost(opi ) + c(spi )

end forFRINGE ← REMOVE(FRINGE,p)CLOSED ← INSERT(CLOSED,p)f (p) ← min(f1, . . . , fn)for all PARENT ∈ GRAND-PARENTS(p) do

f (PARENT) ← UPDATE-COST(PARENT)end forfor all node ∈ CLOSED ∩ Gr-Sol do

update the pointer associated to nodeend forfor all LEAVE ∈ Gr-Sol do

DURING ← INSERT(DURING,LEAVE)end for

end while

Emilie Morvant MeTeOR — PART I 2014/15 189

Page 191: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Properties of AO*

Hypothesesno cycle and independent sub-problems

• If h is admissible and consistent,⇒ AO* finds the optimal solution (according to the

cost function)

• AO* is equivalent to A* for AND/OR graph (exceptfor the function g)

Emilie Morvant MeTeOR — PART I 2014/15 190

Page 192: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Emilie Morvant MeTeOR — PART I 2014/15 191

Page 193: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Step 1Development of p0

f (p0) = min {(5 + 50 + 0), (19 + 28), (8 + 40)} = min(55, 47, 48)

⇒ we choose to develop p3Emilie Morvant MeTeOR — PART I 2014/15 192

Page 194: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Step 2: f (p3) = min(50, 52), Update f (p0), and Develop p4Emilie Morvant MeTeOR — PART I 2014/15 193

Page 195: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Step 3: f (p4) = min(40, 50), Update f (p0), and Develop p10

Emilie Morvant MeTeOR — PART I 2014/15 194

Page 196: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Step 4: f (p10) = min(45), Update f (p4) and f (p0), and Develop p2

Emilie Morvant MeTeOR — PART I 2014/15 195

Page 197: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: AO*

Step 5

Emilie Morvant MeTeOR — PART I 2014/15 196

Page 198: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise : AO*

Emilie Morvant MeTeOR — PART I 2014/15 197

Page 199: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Exercise : AO*

1 What are the decomposition rules for the previous AND/ORgraph?

2 Let h be a heuristic such that h(G ) = h(T ) = h(Z ) =∞(insolvable pb) h(J) = h(K ) = h(M) = h(n) = h(O) = h(Q) =h(S) = h(U) = h(V ) = h(Y ) = 0 (trivial pb), h(R) = 1,h(W ) = 3 and h(X ) = 7.What are the solved sub-graphs? (OR-path from anywhere in thegraph)

3 If the cost k of each operator is the number of generatedsub-problems, what is the best partial solution for the previousintermediate search space, what is its cost?

4 What would be the next developed node using AO*?

Emilie Morvant MeTeOR — PART I 2014/15 198

Page 200: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Another approach. . .

• For optimization problemsI rather than constructing an optimal solution from scratch,

start with a suboptimal solution and iteratively improve it

• Local Search AlgorithmsI Hill-climbing or Gradient descentI Potential FieldsI Simulated AnnealingI Genetic Algorithms, others. . .

Emilie Morvant MeTeOR — PART I 2014/15 199

Page 201: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Hill-climbing search

Principle of Hill-climbing search:

If there exists a successor s for the current state n such that• h(s) < h(n)• h(s) ≤ h(t) for all the successors t of n⇒ then move from n to s. Otherwise, halt at n.

• Looks one step ahead to determine if any successor is better thanthe current state; if there is, move to the best successor

• Similar to Greedy search in that it uses h, but does not allowbacktracking or jumping to an alternative path since it doesn’t“remember” where it has been

• Not complete since the search will terminate at “local minima”,“plateaus”, and “ridges”

Emilie Morvant MeTeOR — PART I 2014/15 200

Page 202: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Hill climbing on a surface of states

Emilie Morvant MeTeOR — PART I 2014/15 201

Page 203: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Hill climbing

Steepest descent (∼ greedy best-first with no search)↪→ may get stuck into local minimum

Emilie Morvant MeTeOR — PART I 2014/15 202

Page 204: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Robot navigation

f (n) = h(n) = “Straight distance to the goal”

Emilie Morvant MeTeOR — PART I 2014/15 203

Page 205: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Drawbacks of hill climbing

Problems:

• Local Maxima: peaks that are not the highest point in thespace

• Plateaus: the space has a broad flat region that gives the searchalgorithm no direction (random walk)

• Ridges: flat like a plateau, but with dropoffs to the sides; stepsto the North, East, South and West may go down, but a step tothe NW may go up

Remedy:

• Introduce randomness (e.g., with random restart)

NB: Some problem spaces are great for hill climbing andothers are terrible

Emilie Morvant MeTeOR — PART I 2014/15 204

Page 206: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

What is the issue?

• Search is an iterative local procedure

• Good heuristics should provide some globallook-ahead (at low computational cost)

Emilie Morvant MeTeOR — PART I 2014/15 205

Page 207: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: Hill climbing on 8-puzzle

f (n) = −(number of tiles out of place)

Emilie Morvant MeTeOR — PART I 2014/15 206

Page 208: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example of a local maximum

Emilie Morvant MeTeOR — PART I 2014/15 207

Page 209: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Potential Fields

• Idea: modify the heuristic function

• Goal is gravity well, drawing the robot toward it

• Obstacles have repelling fields, pushing the robot away from them

• This causes robot to “slide” around obstacles

• Potential field defined as sum of attractor field which get higheras you get closer to the goal and the individual obstacle repellingfield (often fixed radius that increases exponentially closer to theobstacle)

Emilie Morvant MeTeOR — PART I 2014/15 208

Page 210: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Does it always work?

Does it always work? → NO

• But, it often works very well in practice

• Advantage 1:I can search a very large search space without maintaining

fringe of possiblitiesI Scales well to high dimensions, where no other methods workI Example: motion planning

• Advantage 2: local method. Can be done online

Emilie Morvant MeTeOR — PART I 2014/15 209

Page 211: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Example: RobotSoccer

All robots have same field: attracted to the ball

• repulsive potential to other players

• Kicking field: attractive potential to the ball and local repulsivepotential if clase to the ball, but not facing the direction of theopponent’s goalResult is tangent, player goes around the ball

• single team: kicking field + repulsive field to avoid hitting otherplayers + player position fields (parabolic if outside your area ofthe field, 0 inside)Player nearest to the ball has the largest attractive coefficient,avoids all players crowding the ball

• Two teams: identical potential fields

Emilie Morvant MeTeOR — PART I 2014/15 210

Page 212: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Simulated annealing

Principle of SA

SA exploits an analogy between the way in which a metal cools andfreezes into a minimum-energy crystalline structure (the annealingprocess) and the search for a minimum (or maximum) in a moregeneral system

• SA can avoid becoming trapped at local minima

• SA uses a random search that accepts changes that increaseobjective function f , as well as some that decrease it

• SA uses a control parameter T , which by analogy with theoriginal application is known as the system “temperature”

• T starts out high and gradually decreases toward 0

Emilie Morvant MeTeOR — PART I 2014/15 211

Page 213: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Properties of simulated annealing

• A “bad” move from A to B is accepted with a probability

exp

(f (B)− f (A)

T

)

• The higher the temperature, the more likely it is that a bad movecan be made

• As T tends to zero, this probability tends to zero, and SAbecomes more like hill climbing

• If T is lowered slowly enough, SA is complete and admissible

Emilie Morvant MeTeOR — PART I 2014/15 212

Page 214: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Simulated annealing algorithm

CURRENT ← INITIAL-NODEfor t ← 1 to ∞ doT ← SCHEDULE[t] (SCHECULE is a mapping from time totemperature)if T = 0 then return CURRENTSUCCESSOR ← a randomly selected successor of CURRENT∆E ← f (SUCCESSOR)− f (CURRENT)if ∆E > 0 then

CURRENT ← SUCCESSORelse

CURRENT ← SUCCESSOR only with probability exp(

∆ET

)end if

end for

NB: Successful application on circuit routing, TSP

Emilie Morvant MeTeOR — PART I 2014/15 213

Page 215: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Summary: Local search algorithm

• Steepest descent (∼ greedy best-first with no search)

↪→ may get stuck into local minimum

• Better Heuristics: Potential Fields

• Simulated annealing

• Genetic algorithms

Emilie Morvant MeTeOR — PART I 2014/15 214

Page 216: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

When does one have to use search techniques?

• The search space is small, and

I there is no other available techniques,or is not worth the effort to develop a more efficient

technique

• The search space is large, and

I there is no other available techniques,and there exist “good” heuristics

Emilie Morvant MeTeOR — PART I 2014/15 215

Page 217: Methods, techniques, and tools for reasoning (MeTeOR) - *0 ... · Tasks di cult for humans have turned out to be \easy" Chess Checkers, Othello, Backgammon Logistics planning Airline

Summary

• Heuristic function

• Best-first search

• Admissible heuristic and A*

• A* is complete and optimal

• Consistent heuristic and repeated states

• Heuristic accuracy

• AO*

• IDA*

Emilie Morvant MeTeOR — PART I 2014/15 216