840 likes | 1.11k Views
CS347 – Introduction to Artificial Intelligence. CS347 course website: http://web.mst.edu/~tauritzd/courses/cs347/. Dr. Daniel Tauritz (Dr. T) Department of Computer Science tauritzd@mst.edu http://web.mst.edu/~tauritzd/. What is AI?. Systems that… act like humans (Turing Test)
E N D
CS347 – Introduction toArtificial Intelligence CS347 course website: http://web.mst.edu/~tauritzd/courses/cs347/ Dr. Daniel Tauritz (Dr. T) Department of Computer Science tauritzd@mst.edu http://web.mst.edu/~tauritzd/
What is AI? Systems that… • act like humans (Turing Test) • think like humans • think rationally • act rationally Play Ultimatum Game
Rational Agents • Environment • Sensors (percepts) • Actuators (actions) • Agent Function • Agent Program • Performance Measures
Rational Behavior Depends on: • Agent’s performance measure • Agent’s prior knowledge • Possible percepts and actions • Agent’s percept sequence
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.”
Task Environments PEAS description & properties: • Fully/Partially Observable • Deterministic, Stochastic, Strategic • Episodic, Sequential • Static, Dynamic, Semi-dynamic • Discrete, Continuous • Single agent, Multiagent • Competitive, Cooperative
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.
Problem-solving steps • Problem-formulation (actions & states) • Goal-formulation (states) • Search (action sequences) • Execute solution
Well-defined problems • Initial state • Action set • Transition model: RESULT(s,a) • Goal test • Path cost • Solution / optimal solution
Example problems • Vacuum world • Tic-tac-toe • 8-puzzle • 8-queens problem
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!
Search node datastructure • n.STATE • n.PARENT-NODE • n.ACTION • n.PATH-COST States are NOT search nodes!
Frontier • Frontier = Set of leaf nodes • Implemented as a queue with ops: • EMPTY?(queue) • POP(queue) • INSERT(element,queue) • Queue types: FIFO, LIFO (stack), and priority queue
Problem-solving performance • Completeness • Optimality • Time complexity • Space complexity
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
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)
Breadth First Tree Search (BFTS) • Frontier: FIFO queue • Complete: if b and d are finite • Optimal: if path-cost is non-decreasing function of depth • Time complexity: O(b^d) • Space complexity: O(b^d)
Uniform Cost Tree Search (UCTS) • Frontier: priority queue ordered by g(n)
Depth First Tree Search (DFTS) • Frontier: LIFO queue (a.k.a. stack) • Complete: no • Optimal: no • Time complexity: O(bm) • Space complexity: O(bm) • Backtracking version of DFTS has a space complexity of: O(m)
Depth-Limited Tree Search (DLTS) • Frontier: LIFO queue (a.k.a. stack) • Complete: not when l < d • Optimal: no • Time complexity: O(b^l) • Space complexity: O(bl) • Diameter: min # steps to get from any state to any other state
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)
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 frontier with priority queue sorted in ascending order of f-values
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]
Heuristics • h(n) is a heuristic function • Heuristics incorporate problem-specific knowledge • Heuristics need to be relatively efficient to compute
Important BeFS algorithms • UCS: f(n) = g(n) • GBeFS: f(n) = h(n) • A*S: f(n) = g(n)+h(n)
GBeFTS • Incomplete (so also not optimal) • Worst-case time and space complexity: O(bm) • Actual complexity depends on accuracy of h(n)
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
Admissible heuristics • h(n) admissible if: Example: straight line distance A*TS optimal if h(n) admissible
Consistent heuristics • h(n) consistent if: Consistency implies admissibility A*GS optimal if h(n) consistent
A* search notes • Optimally efficient for consistent heuristics • Run time is a function of the heuristic error • Suboptimal variants • Not strictly admissible heuristics • A* Graph Search not scalable due to memory requirements
Memory-bounded heuristic search • Iterative Deepening A* (IDA*) • Recursive Best-First Search (RBFS) • IDA* and RBFS don’t use all avail. memory • Memory-bounded A* (MA*) • Simplified MA* (SMA*) • Meta-level learning aims to minimize total problem solving cost
Heuristic Functions • Effective branching factor • Domination • Composite heuristics • Generating admissible heuristics from relaxed problems
Sample relaxed problem • n-puzzle legal actions: Move from A to B if horizontally or vertically adjacent and B is blank Relaxed problems: • Move from A to B if adjacent • Move from A to B if B is blank • Move from A to B
Generating admissible heuristics The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem.
Adversarial Search Environments characterized by: • Competitive multi-agent • Turn-taking Simplest type: Discrete, deterministic, two-player, zero-sum games of perfect information
Search problem formulation • S0: Initial state (initial board setup) • Player(s): • Actions(s): • Result(s,a): • Terminal test: game over! • Utility function: associates player-dependent values with terminal states
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!
Iterative-Deepening Minimax • IDM(n,d) calls DLM(n,1), DLM(n,2), …, DLM(n,d) • Advantages: • Solution availability when time is critical • Guiding information for deeper searches
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
DLM w/ Alpha-Beta Pruning Time Complexity • Worst-case: O(bd) • Best-case: O(bd/2) [Knuth & Moore, 1975] • Average-case: O(b3d/4)
Move Ordering Heuristics • Knowledge based • Killer Move: the last move at a given depth that caused AB-pruning or had best minimax value • History Table