cs347 introduction to artificial intelligence

58
CS347 Introduction to Artificial Intelligence Dr. Daniel Tauritz (Dr. T) [email protected] http://web.umr.edu/ ~tauritzd

Upload: annona

Post on 19-Jan-2016

44 views

Category:

Documents


3 download

DESCRIPTION

CS347 Introduction to Artificial Intelligence. Dr. Daniel Tauritz (Dr. T) [email protected] http://web.umr.edu/~tauritzd. What is AI?. Systems that… think like humans act like humans think rationally act rationally Play Ultimatum Game. Key historical events for AI. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CS347 Introduction to  Artificial Intelligence

CS347Introduction to

Artificial Intelligence

Dr. Daniel Tauritz (Dr. T)[email protected]://web.umr.edu/~tauritzd

Page 2: CS347 Introduction to  Artificial Intelligence

What is AI?

Systems that…think like humansact like humansthink rationallyact rationally

Play Ultimatum Game

Page 3: CS347 Introduction to  Artificial Intelligence

Key historical events for AI

1600’s Descartes mind-body connection 1805 First programmable machine Mid 1800’s Charles Babbage’s “difference

engine” & “analytical engine” Lady Lovelace’s Objection 1943 McCulloch & Pitts: Neural Computation 1976 Newell & Simon’s “Physical Symbol

System Hypothesis”

Page 4: CS347 Introduction to  Artificial Intelligence

Rational Agents

Environment Sensors (percepts) Actuators (actions) Agent Function Agent Program Performance Measures

Page 5: CS347 Introduction to  Artificial Intelligence

Rational Behavior

Depends on: Agent’s performance measure Agent’s prior knowledge Possible percepts and actions Agent’s percept sequence

Page 6: CS347 Introduction to  Artificial Intelligence

Rational Agent Definition

“For each possible percept sequence, a rational agent selects an action that is expected to maximize its performance measure, given the evidence provided by the percept sequence and any prior knowledge the agent has.”

Page 7: CS347 Introduction to  Artificial Intelligence

Task Environments PEAS description PEAS properties:

Fully/Partially ObservableDeterministic, Stochastic, StrategicEpisodic, SequentialStatic, Dynamic, SemidynamicDiscrete, ContinuousSingle agent, MultiagentCompetitive, Cooperative

Page 8: CS347 Introduction to  Artificial Intelligence

Problem-solving agents

A definition:

Problem-solving agents are goal based agents that decide what to do based on an action sequence leading to a goal state.

Page 9: CS347 Introduction to  Artificial Intelligence

Problem-solving steps

Problem-formulation Goal-formulation Search Execute solution

Play Three Sisters Puzzle

Page 10: CS347 Introduction to  Artificial Intelligence

Well-defined problems

Initial state Successor function Goal test Path cost Solution Optimal solution

Page 11: CS347 Introduction to  Artificial Intelligence

Example problems

Vacuum world Tic-tac-toe 8-puzzle 8-queens problem

Page 12: CS347 Introduction to  Artificial Intelligence

Search trees

Root corresponds with initial state Vacuum state space vs. search tree Search algorithms iterate through goal

testing and expanding a state until goal found

Order of state expansion is critical! Water jug example

Page 13: CS347 Introduction to  Artificial Intelligence

Search node datastructure

STATE PARENT-NODE ACTION PATH-COST DEPTH

States are NOT search nodes!

Page 14: CS347 Introduction to  Artificial Intelligence

Fringe

Fringe = Set of leaf nodes Implemented as a queue with ops:

MAKE-QUEUE(element,…) EMPTY?(queue) FIRST(queue) REMOVE-FIRST(queue) INSERT(element,queue) INSERT-ALL(elements,queue)

Page 15: CS347 Introduction to  Artificial Intelligence

Problem-solving performance

Completeness Optimality Time complexity Space complexity

Page 16: CS347 Introduction to  Artificial Intelligence

Complexity in AI

b – branching factor d – depth of shallowest goal node m – max path length in state space Time complexity: # generated nodes Space complexity: max # nodes stored Search cost: time + space complexity Total cost: search + path cost

Page 17: CS347 Introduction to  Artificial Intelligence

Tree Search

Breadth First Tree Search (BFTS) Uniform Cost Tree Search (UCTS) Depth-First Tree Search (DFTS) Depth-Limited Tree Search (DLTS) Iterative-Deepening Depth-First

Tree Search (ID-DFTS)

Page 18: CS347 Introduction to  Artificial Intelligence

Graph Search

Breadth First Graph Search (BFGS) Uniform Cost Graph Search (UCGS) Depth-First Graph Search (DFGS) Depth-Limited Graph Search (DLGS) Iterative-Deepening Depth-First

Graph Search (ID-DFGS)

Page 19: CS347 Introduction to  Artificial Intelligence

Example state space

Page 20: CS347 Introduction to  Artificial Intelligence

Diameter example 1

Page 21: CS347 Introduction to  Artificial Intelligence

Diameter example 2

Page 22: CS347 Introduction to  Artificial Intelligence

Best First Search (BeFS)

Select node to expand based on evaluation function f(n)

Typically node with lowest f(n) selected because f(n) correlated with path-cost

Represent fringe with priority queue sorted in ascending order of f-values

Page 23: CS347 Introduction to  Artificial Intelligence

Path-cost functions

g(n) = lowest path-cost from start node to node n

h(n) = estimated path-cost of cheapest path from node n to a goal node [with h(goal)=0]

Page 24: CS347 Introduction to  Artificial Intelligence

Important BeFS algorithms

UCS: f(n) = g(n)

GBeFS: f(n) = h(n)

A*S: f(n) = g(n)+h(n)

Page 25: CS347 Introduction to  Artificial Intelligence

Heuristics

h(n) is a heuristic function Heuristics incorporate problem-

specific knowledge Heuristics need to be relatively

efficient to compute

Page 26: CS347 Introduction to  Artificial Intelligence

GBeFS

Incomplete (so also not optimal) Worst-case time and space

complexity: O(bm) Actual complexity depends on

accuracy of h(n)

Page 27: CS347 Introduction to  Artificial Intelligence

A*S

f(n) = g(n) + h(n) f(n): estimated cost of optimal

solution through node n if h(n) satisfies certain conditions,

A*S is complete & optimal

Page 28: CS347 Introduction to  Artificial Intelligence

Admissible heuristics

h(n) admissible if:

Example: straight line distance

A*TS optimal if h(n) admissible

Page 29: CS347 Introduction to  Artificial Intelligence

Consistent heuristics

h(n) consistent if:

Consistency implies admissibility

A*GS optimal if h(n) consistent

Page 30: CS347 Introduction to  Artificial Intelligence

Example graph

Page 31: CS347 Introduction to  Artificial Intelligence

Adversarial Search

Environments characterized by: Competitive multi-agent Turn-taking

Simplest type: Discrete, deterministic, two-player, zero-sum games of perfect information

Page 32: CS347 Introduction to  Artificial Intelligence

Search problem formulation

Initial state: board position & starting player

Successor function: returns list of (legal move, state) pairs

Terminal test: game over! Utility function: associates player-

dependent values with terminal states

Page 33: CS347 Introduction to  Artificial Intelligence

Minimax

Page 34: CS347 Introduction to  Artificial Intelligence

Depth-Limited Minimax

State Evaluation Heuristic estimates Minimax value of a node

Note that the Minimax value of a node is always calculated for the Max player, even when the Min player is at move in that node!

Page 35: CS347 Introduction to  Artificial Intelligence

Iterative-Deepening Minimax

IDM(n,d) calls DLM(n,1), DLM(n,2), …, DLM(n,d)

Advantages:Solution availability when time is

criticalGuiding information for deeper

searches

Page 36: CS347 Introduction to  Artificial Intelligence

Time Per Move

Constant Percentage of remaining time State dependent Hybrid

Page 37: CS347 Introduction to  Artificial Intelligence

Redundant info example

Page 38: CS347 Introduction to  Artificial Intelligence

Alpha-Beta Pruning α: worst value that Max will accept at this

point of the search tree β: worst value that Min will accept at this

point of the search tree Fail-low: encountered value <= α Fail-high: encountered value >= β Prune if fail-low for Min-player Prune if fail-high for Max-player

Page 39: CS347 Introduction to  Artificial Intelligence

Example game tree

Page 40: CS347 Introduction to  Artificial Intelligence

Example game tree

Page 41: CS347 Introduction to  Artificial Intelligence

Example game tree

Page 42: CS347 Introduction to  Artificial Intelligence

Transposition Tables (1)

Hash table of previously calculated state evaluation heuristic values

Speedup is particularly huge for iterative deepening search algorithms!

Good for chess because often repeated states in same search

Page 43: CS347 Introduction to  Artificial Intelligence

Transposition Tables (2)

Datastructure: Hash table indexed by position

Element: State evaluation heuristic value Search depth of stored value Hash key of position (to eliminate

collisions) (optional) Best move from position

Page 44: CS347 Introduction to  Artificial Intelligence

Transposition Tables (3)

Zobrist hash key Generate 3d-array of random 64-bit numbers

(piece type, location and color) Start with a 64-bit hash key initialized to 0 Loop through current position, XOR’ing hash

key with Zobrist value of each piece found (note: once a key has been found, use an incremental apporach that XOR’s the “from” location and the “to” location to move a piece)

Page 45: CS347 Introduction to  Artificial Intelligence

Quiescence Search

When search depth reached, compute quiescence state evaluation heuristic

If state quiescent, then proceed as usual; otherwise increase search depth if quiescence search depth not yet reached

Call format: QSDLM(root,depth,QSdepth), QSABDLM(root,depth,QSdepth,α,β), etc.

Page 46: CS347 Introduction to  Artificial Intelligence

MTD(f)MTDf(root,guess,depth) {

lower = -∞;

upper = ∞;

do {

beta=guess+(guess==lower);

guess = ABMaxV(root,depth,beta-1,beta);

if (guess<beta) upper=guess; else lower=guess;

} while (lower < upper);

return guess; } // also needs to return best move

Page 47: CS347 Introduction to  Artificial Intelligence

IDMTD(f)

IDMTDf(root,first_guess,depth_limit) {

guess = first_guess;

for (depth=1; depth ≤ depth_limit; depth++)

guess = MTDf(root,guess,depth);

return guess; }

// actually needs to return best move

Page 48: CS347 Introduction to  Artificial Intelligence

Search Depth Heuristics Horizon Effect: the phenomenon of

deciding on a non-optimal principal variant because an ultimately unavoidable damaging move seems to be avoided by blocking it till passed the search depth

Singular Extensions Quiescence Search Time based State based

Page 49: CS347 Introduction to  Artificial Intelligence

Move Ordering Heuristics

Knowledge based Killer Move: the last move at a given

depth that caused an AB-pruning or had best minimax value

History Table

Page 50: CS347 Introduction to  Artificial Intelligence
Page 51: CS347 Introduction to  Artificial Intelligence

Adversarial Search inStochastic Environments

Worst Case Time Complexity: O(bmnm) with b the average branching factor, m the deepest search depth, and n the average chance branching factor

Page 52: CS347 Introduction to  Artificial Intelligence

Example “chance” game tree

Page 53: CS347 Introduction to  Artificial Intelligence

Expectiminimax & Pruning

Interval arithmetic!

Page 54: CS347 Introduction to  Artificial Intelligence

Local Search

Steepest-ascent hill-climbing Stochastic hill-climbing First-choice hill-climbing Random-restart hill-climbing Simulated Annealing Deterministic local beam search Stochastic local beam search Evolutionary Algorithms

Page 55: CS347 Introduction to  Artificial Intelligence

Null Move Forward Pruning

Before regular search, perform shallower depth search (typically two ply less) with the opponent at move; if beta exceeded, then prune without performing regular search

Sacrifices optimality for great speed increase

Page 56: CS347 Introduction to  Artificial Intelligence

Futility Pruning

If the current side to move is not in check, the current move about to be searched is not a capture and not a checking move, and the current positional score plus a certain margin (generally the score of a minor piece) would not improve alpha, then the current node is poor, and the last ply of searching can be aborted.

Extended Futility Pruning Razoring

Page 57: CS347 Introduction to  Artificial Intelligence

Particle Swarm Optimization

PSO is a stochastic population-based optimization technique which assigns velocities to population members encoding trial solutions

PSO update rules:

Page 58: CS347 Introduction to  Artificial Intelligence

Ant Colony Optimization

Population based Pheromone trail and stigmergetic

communication Shortest path searching Stochastic moves