CPCS 482 (Artificial Intelligence)
Properties for Good Knowledge Representation
1. Expressive and unambiguous - adequate for use 2. Succinct - small size aids search 3. Allows for the correct level of representation. Granularity: high-level = superficial answers low-level = detailed, idiomatic 4. Modify Details 5. Deductive ability (inference) 6. Search Efficiency - Ability to add heuristics. Able to organize the knowledge to speed up search.
Applications of AI (9)
1. Games: GO, Poker 2. Problem solving: common sense + planning 3. Expert systems: expert problem solving 4. Understanding natural languages: English 5. Pattern Recognition: Visual, speech. 6. Deductive reasoning: 7. Inductive reasoning: 8. Learning 9. Art and Music
State-Space Representation of a Problem (6)
1. General description of a legal state | (n-tuple) set 2. Initial State description | member in set 3. Goal State description | member in set 4. Set of legal operators and descriptions of how they affect states + constraints 5. (Optional) Solution with minimal # of operators required 6. (Optional) Solution with minimal cost of the total operators required (Traveling Agent)
Learning Paradigms
(From hardest to easiest) 0. Reformulate problem. 1. Feature learning: (program is able to learn new features that should be added to the h/e function. 2. Structural Learning (signature tables): Program is able to modify the structure of h/e function. 3. Parametric Learning (adjust weights): Program is able to adjust the weights of the features in h/e. 4. Rote learning: Program memorizes what to do in form of specific cases easiest. When a known case comes up, it knows what to do.
Representation of Games
- 2 person - perfect info - zero-sum (wins/losses) - +/- = us/them (OR/AND nodes)
Better (Learning)
- Find a better h in an informed search - Find a better e to rate game positions - Improve the representation of the problem/game (genius)
Modification: Forward Pruning (n-best, tapered n-best)
- When each state has lots of successors - Limit successors at each expansion by eliminating any stupid successors (nodes with "large" f/h values) - n-best: where n is chosen number, order all nodes, keep only n-best - tapered n-best: n gets smaller as n-gets deeper (delete more as you get deeper and deeper)
Futile (Problem Decomposition)
1. A tip/leaf node with no successors - a deadend (not in the set of terminal nodes) 2. An interior node with OR successors and all successors are futile 3. An interior node with AND successors and any one of the successors is futile
Divide & Conquer Approach
1. Each node is a complete problem description (not a state) 2. This is an AND graph, not an OR graph. 3. Search will involve both AND-branches and OR-branches
Turing Test
A, B, are random persons. A talks to 1 and 2 until it can decide which is the machine and which is the human B. This needs to be done for a large number of A and B. If A's right ~ 50% & A's wrong ~ 50%, then the program has AI. AI researchers have devoted little effort to passing the Turing Test, believing that it is more important to study the underlying principles of intelligence than to duplicate an example.
Learning
Add to game playing or problem solving programs. Program improves its own performance using: A) Set of standard examples - feed in a set of 'good' examples and program learns what to do B) Own experience - after playing/solving it discovers ways to do things better (feedback loop)
Heuristic Function h(n)
Additional knowledge of the problem is imparted to the search algorithm with h(n) providing an estimated cost of the cheapest path from the state at node n to a goal state.
State-space Constraints
An operator may be inapplicable in certain states.
Solving the Game
BFS, DFS, AO* for AND/OR graph
Blind Depth-First Search (AND/OR graph)
Complete: NO Admissible: NO Time/Space: Algorithm:
Blind Depth-First Search (State-space)
Complete: NO Admissible: NO Time/Space: O(b^m) / O(bm) Algorithm: 1. Put start node on OPEN (LIFO queue). If start node is goal node, return solution. 2. If OPEN is empty return fail. 3. Remove node n from OPEN and put on CLOSED. 4. If the depth of node n is equal to maximum depth, go to (2). 5. Expand n, if it has no successors go to (2). 6. Put successors of n on OPEN. If any successor is goal node return solution. 7. Go to (2).
Informed Best-First Search (State-space)
Complete: NO (tree) Admissible: NO Time/Space: O(b^m) Algorithm: 1. Put the start node s on a list, called OPEN (priority queue), of unexpanded nodes. Calculate h(s) and associate its value with node s. 2. If OPEN is empty, exit with failure; no solution exists. 3. Select from OPEN a node i at which h is minimum. If several nodes qualify, choose a goal node if there is one, and otherwise choose among them arbitrarily. 4. Remove node i from OPEN and place it on a list, called CLOSED, of expanded nodes. 5. If i is a goal node, exit with success; a solution has been found. 6. Expand node i, creating nodes for all its successors. For every successor node j of i: a. Calculate h(j). b. If j is neither in list OPEN nor in list CLOSE, then add it to OPEN, with its h value. Attach a pointer from j back to its predecessor I (in order to trace back a solution path once a goal node is found). c. If j was already on either OPEN or CLOSED, compare the h value just calculated for j with the value previously associated with the node. If the new value is lower, then: i. Substitute it for the old value. ii. Point j back to I instead of to its previously found predecessor. iii. If node j was on the CLOSED list, move it back to OPEN. 7. Go to (2).
Informed IDA* Search (State-space)
Complete: YES Admissible: YES Time/Size: O(b^d) / O(bd) Algorithm: At each iteration, perform a depth-first search, cutting off a branch when its total cost (g + h) exceeds a given threshold. This threshold starts at the estimate of the cost of the initial state, and increases for each iteration of the algorithm. At each iteration, the threshold used for the next iteration is the minimum cost of all valued that exceeded the current threshold.
Informed A* Search (State-space)
Complete: YES Admissible: YES Time/Space: O(b^d) Algorithm: 1. Place start node on OPEN and store its value f(n). 2. Remove node n from OPEN. If goal node, return solution. If OPEN is empty, return fail. 3. Find successors of node n, for each successor t compute f(t) value. 4. If successor t is on CLOSED and f(t) < f(old node), replace and propagate new values up, else discard successor and move to next successor. 5. If successor t is on OPEN, and f(t) < f(old node), update and propagate values. Else discard successor and move to next. 6. Push successor t on OPEN. 7. Go to (2).
Blind Breadth-First Search (State-space)
Complete: YES Admissible: YES Time/Space: O(b^d) / O(b^d) Algorithm: 1. Put start node on OPEN (FIFO queue). If start node is goal node return solution. 2. If OPEN is empty, return fail. 3. Remove node n from OPEN and put it on CLOSED. 4. Expand n. If it has no successors go to (2). 5. Put all successors of n on OPEN. If any successors is a goal node return solution. 6. Go to (2).
Blind Iterative Deepening Search (State-space)
Complete: YES Admissible: YES Time/Space: O(b^d) / O(bd) Algorithm: For k = 0, 1, 2,..., do: - Perform depth-first search with depth cut-off k
Blind Breadth-First Search (AND/OR graph)
Complete: YES Admissible: YES Time/Space: O(b^d)/ O(b^d) Algorithm: 1. Put root (= original position) on OPEN, put label = ? 2. Pick top node on OPEN(call it n), put n on CLOSED. For n: Case1: n = primitive 3. Label n 'solved' and call solved(n). 4. If root = 'solved' then exit with solution 5. (Optimization) Recurse from OPEN all nodes that have ancestors that are 'solved' 6. Go to (2). Case2: n = deadend: 3. Label n 'futile' and call futile(n). 4. If root = 'futile' then exit with failure. 5. Remove from OPEN all nodes with ancestors that are 'futile' 6. Go to (2). Case3: Otherwise: 3. Expand n, put successors on bottom of OPEN(queue) with pointer to n. Set labels = ?. 4. Go to (2).
Learning Implementation: Parametric Learning
Program is able to adjust the weight of the features in h/e. Simpler learning level. Use a fixed form for e/h function: e(state) = WiXi(s) + W2X2(s) + .... + WnXn(s) Xi = features that are included Wi = weights, are not fixed (to be learned) (A) From Example: Tic Tac Toe static evaluation function. Put in two examples (from expects). 1. 0 => e(#1) = w1 * 8 + w2 * 8 = 0 2. 10 max => e(#2) = w1 * 2 + w2 * 0 = 10 => w1 = 5, w2 = -5. (B) From Experience: 1. Compare direct evaluation with backed up value. 2. Adjust weights replace with new function to reduce this difference. (Updating weights via experience)
Learning Implementation: Featured/Heuristic Learning
Program is able to learn new features that should be added to the h/e function. Hardest.
Evaluation: P Penetrance
Good: Easy to calculate, independent of machine/OS Bad: Only compare problems of same complexity L, forecast total number of nodes. P = L/T: (Length of Solution) / (Total Nodes Generated) 1 is perfect, Larger P is better.
Evaluation: B Branching Factor
Good: More independent of L, can use to compare between problems Bad: Not easy to calculate Average # of successors generated at each node (assuming a full tree of solution depth L). (Never count initial state factor). B = f(L,T) = NOT POSSIBLE! | The lower the B value the better. B = 1 = perfect search.
Admissibility of A*
Hart-Nilsson-Raphael Theorem (1968): Let ĥ(s) be the real distance from s to a goal. if 0 ≤ h(s) is between 0 AND ĥ(s) ( 0 ≤ h(s) ≤ ĥ(s) ) for all states s AND g > 0 is included, then A* is admissible. 0 ≤ h1 ≤ ĥ 0 ≤ h2 ≤ ĥ (admissible) (admissible)
e-static evaluation function
If a partial tree contains any nodes that are terminal for the entire tree it returns negative infinity for loss, positive infinity for win and 0 for a draw. At other tip nodes, the evaluation function returns finite values; a positive value favorable to max and a negative value favorable to min. By definition, a function that estimates the value of a board position without looking at any of that position's successors.
Modification: Staged Search
If memory was exhausted before a solution was found do the following: a) Keep the best node(s) on OPEN, and keep the best path(s) to those nodes on CLOSED. b) Delete all other nodes on OPEN or CLOSED c) Start up the search again Each redo is a stage, can't count on this being complete or admissible.
Modification: Book Moves
Information on how to play from human experts is copied from books and entered into tables for the computer's use. Usually after ten moves, we end up in a rarely seen position, and the program must switch from table lookup to search.
State-space Operators
Means of transforming the problem from one state to another. function(): state -> state.
Alpha-Beta Algorithm
Never Use BFS (use DFS, AO*, etc). 1. Search until generate a pre-determined tip node. 2. Evaluate the tip node (apply Alpha to exit) and give it a FV. 3. Backup FV's as far as possible using Minimax. If root has a FV then stop to pick best. 4. Advance/update a threshold value to next level(only one level up). 5. Check for Alpha/Beta cutoffs: If there is one, change the threshold to FV and go to (3). Else, go to (1).
General Problem Solver (GPS)
Newell, Shaw, Simon. One divide and conquer approach to solve all state-space problems. Call GPS(IS, GS) + operators.
State-space Search Space
Normal human representation: labeled OR-graph with: nodes = states edges = application of an operator
Modification: Forward Pruning (Problem Reduction)
Not states -> subproblems. If n value at a problem is past a limit, then delete it.
Adversarial Search
Problems: 1. Moves involve uncertainty (what opponent will do) 2. Cannot complete the search down to solved nodes (wins/losses) Make a move without knowing it's the "correct" move "best" next = move algorithms (ie AlphaBetas, min max)
Modification: Imperfect Information (chance, hidden)
We represent what a player does not know within a game using an information set: a collection of nodes among which the player cannot distinguish.
Modification: Staged Search (Problem Reduction)
When space is exhausted, keep best AND subtrees (according to f) in OPEN/CLOSE. Throw rest of nodes away. Start search again.
Definition win+
win+ = solved = 1 = loss-
Complete Search
Given enough time and space, you are guaranteed to get a goal state.
Minimax Algorithm
1. Generate game tree down to some level using one of the search methods (BFS, DFS, AO*). Limit can depend on: - down to win+ / loss+ - to a preset time limit - to a space limit - to a depth limit 2. Apply an evaluation function to all tip nodes. for e = static evaluation function. for e = positive = good for + for e = negative = good for - for e = ~0 = equally good for both 3. e-values are backed up to the top level for OR = + level. For AND = - level. 4. Select move at top level that gives the max value Goodness of Minimax: 1. More plys searched (machine) 2. Intelligence of e (humans)
Solved (Problem Decomposition)
1. It is a terminal node (no successors) that represents a primitive problem 2. It is a non-terminal node with OR successors and at least one is solved 3. It is a non-terminal node with AND successors and all successors are solved
Game Tree
1. States = (x+) or (x-) - x is configuration(n-tuple) + {+ our turn next (us) | - opponents turn next (them)} 2. IS 3. Description of winning states {win for + (loss-) | win for - (loss+)} 4. Operators: state state moves + constraints.
Needs of AI (3)
1. Symbolic representation 2. Requires a search (choices to be made) 3. Knowledge of the problem that will guide the search
Admissible Search
A complete search that also guarantees to return minimal length path.
State-Space Representation Definition
A problem solving system whose operators each work by producing a single new state. Gives you OR-graph (= search space). Solution = path.
Best next-move search
A search that provides the best move from node n, in a full or partial game tree, by evaluating every node in the tree that descends from node n.
Informed Search
A search that uses problem-specific knowledge beyond the definition of the problem itself-can find solutions more efficiently than can an uninformed strategy.
Informed AO* Search (AND/OR graph)
Complete: YES Admissible: YES Time/Space: O(d) 3 Algorithms: - solved() - futile() - cost() Algorithm: 1. Store start node (original problem) on open; a) Calculate f(start); 2. Call Cost(); select best (minimal cost at root) AND-subtree; a) Call the AND-subtree T. 3. Select a tip node from T(call it n) and have n from OPEN to CLOSE: Case 1: n is primitive: 4. Label n 'solved' and call solved(n); 5. If root = 'solved' then exit with answer (T); 6. (Optimize) Remove nodes from OPEN whose ancestors were labeled 'solved'; 7. Go to (2). Case 2: n is deadend: 4. Label n 'futile', call futile(n); 5. If root = 'futile' exit with failure 6. Remove nodes from OPEN whose ancestors were labeled 'futile' 7. Go to (2). Case 3: n is neither primitive or deadend: 4. Expand n, put successors on OPEN with back-pointers to n. 5. Compute f values of successors = h, 0, . 6. Go to (2). 4. Which tip node to select in Step 3: 1. If T = actual solution subtree, then order is not important 2. If T = not solution subtree then show T is not right and get off of it; Raise cost of T to move to another one - pick the worst node in T (largest h value using sum cost) tip node or longest path (max cost).
State-space States
Data, data structures giving "snapshots" of the condition of the problem: (ordered n * tuple) - list.
Example Programs of AI
Deep Blue, MYCiN (expert system), Watson, Alphago, Self-driving cars
Blind Search Algorithms
Expand enough of search space until solution is found (path from IS to GS).
Learning Implementation: Structural Learning
Program is able to modify the structure of h/e function. More difficult. Programmer - gives all features to be included in h/e(Xi,...,Xn) Program - learns what is correct form of h/e Signature table with all legal combinations for (Xi, ..., Xn). (A) From Example: Book Training (use of examples). On conflicts, use a correlation coefficient. (B) From Experience: ie program playing itself. (Old table playing new table). Have a version of the game play itself with new version making corrections.
Learning Implementation: Rote Learning
Program memorizes what to do in specific cases - when a known case comes up, it knows what to do. Crudest form of learning. (A) From Example: Store position(look up) + correct move = open book. In problem solving store the IS + solution path. (B) From Experience: In games, store the position + best move (calculated). ->0 -> solution -> feedback -> 0... (feedback loop)
British Museum
Randomly pick a tip node to expand (random walk algorithm).
Game Tree Solution
Solution of a game-tree = AND-subtree = winning strategy.
State-space Solution
Solution of a state-space problem is a sequence of operators: op1, op2,...,opn such that: opn(...(op2(op1(IS)))...) = GS.
Evaluation: Experimentations
Solved vs. not solved => "cooked examples" Time/Space efficiency => machine/OS dependent
Heuristic h
Specialized knowledge about a problem which can improve the solving of the problem.
Modification: Backward Search (State-space)
Start with GS (goal state). Requires: 1. Operators are invertible (L R) && (L R) by op-1 2. Small/Unique # of GS Always work smaller to larger
Modification: Forward Search (State-space)
Start with IS (initial state).
Problem Decomposition Representation
State-space + problem reduction operators + primitive problems Search space = AND-OR graph Solution = AND-subgraph 1. The given problem description: IS GS + operators (state-space/operator representations) 2. Set of problem reduction operators. Reduction-operator: problem desc {problem desc} (AND'ed together). 3. Set of primitive problems - 'known solutions'
Blind Search
Strategies have no additional information about the states beyond that provided in the problem definition.
Modification: Bi-directional Search
Two simultaneous searches-one forward from the initial state and the other backward from the goal-hoping that the two searches meet in the middle. The motivation is that bd/2 + bd/2 is much less than bd. Cuts out a lot of the computations and states. For example, on 15-Puzzle, do both directional searches, usually alternating IS and GS. Go until OPEN sets merge/matching node.
Definition of AI
The study of methods for accomplishing rational tasks that normally require human intelligence. This definition changes over time. AI is not modeling human behavior/brain.
Sum Cost
The sum of all arc costs in the solution tree.
Max Cost
The sum of arc costs along the most expensive path from the root to a terminal node in the solution tree.
Definition loss+
loss+ = futile = win-