AI Revision Flashcards
Cons of Hill Climbing:
- No Guarantee to be COMPLETE or OPTIMAL
- Can get stuck on local maxima & plateaus
(RUN FOREVER IF NOT PROPERLY FORMULATED)
Pros of Hill Climbing:
- Rapidly find good solutions by Improving over bad initial state (GREEDY)
- Lower Time & Space Complexity compared to search algorithms
- No Requirements of problem-specific heuristics
(UNINFORMED) - Start from Candidate Solution, instead of building up step-by-step
(UNLIKELY BUT POSSIBLE, SOLUTION PICKED AT RANDOM )
Run algorithm for a Maximum number of iterations m
Variants of Hill climbing can sort out getting stuck on local maxima/ plateaus
Variants of Hill Climbing:
- Stochastic Hill Climbing
- First - Choice Hill Climbing
- Random - Restart Hill Climbing
Stochastic Hill Climbing :
- Variants Randomly selects a neighbour that involves an uphill move
- Probability of picking a specific move can depend on the steepness
- Converges slower than steepest ascent but can find higher solutions
First - Choice Hill Climbing
-Randomly generates a single SUCCESSOR neighbour solution & moves to it if it’s better than current solution
- No UPHILL, keeps randomly generating solutions until there is an uphill move
- After MAX num of tries OR generating all neighbours, hasn’t found UPHILL move, it gives up & assumes that it’s now at Optimal solution.
- Time complexity of this is lower as not all neighbours need to be generates before 1 is picked
(GOOD WHEN THERE ARE LOADS OF NEIGHBOURS FOR EACH SOLUTIONS)
Random - Restart Hill Climbing:
- Generates a series of different hill climbing searches of the same problem from random to initial states
- Stops when goal is found
- Can be parallelised / Threaded easily so does not take much time on modern Computers
- RARE to have to wait for this to happen
What is the only Complete variant of Hill Climbing?
Random - Restart Hill Climbing
It generates a solution if one exists, as eventually random start solution will be OPTIMAL SOLUTION
Pros of Simulating Annealing:
- Find near Optimal Solutions in reasonable time
(High Chance of going to GLOBAL MAX, But only
Good as the formulation of Optimisation Problem) - Avoids getting stuck in poor LOCAL MAX & PLATEAU by combining EXPLORATION & EXLIOTATION
(many solutions we concurrently work with at the end of EXPLORATION )
Cons of Simulating Annealing:
- Not Guaranteed to be complete OR OPTIMAL
(SENSITIVE TO FORMUALTION) - NOT reliable = can’t guarantee completeness
- Time & Space Complexity is problem & Representation- dependent
Formulating Optimisation Problems:
min / max f(x) => min/max objective functions
s.t g_i(x) <= 0, i = 1,…,m
h_i(x) <= 0, i = 1,…,n => Feasibility Constraint
==> x is the DESIGN VARAIBLE (can be anything)
SEARCH SPACE is space of all possible x values
What is Search Space of a Problem:
is the space of all possible x values ALLOWED by constraints in CANDIDATE SOLUTIONS
Define Explicit Constraint:
Explicitly mentioned
CANNOT BE ASSUMED
Define Implicit Constraint:
Rules that must be in place by the problem definitions in order for solutions to be CONSIDERED FEASIBLE
e.g: x,y > 0
Define A*:
Heuristic path finding algorithm & most used example of Informed Search
What is the Evaluation Function:
f(n) = g(n) + h(n)
g(n) cost to reach node n
h(heuristic from node n to goal)
It determines which node to expand next
Steps of A*:
BASIC
1) Expand the shallowest node in frontier with SMALLEST EVALUATION FUNCTION
2) Node is in the list of visited nodes, DON’T ADD TO FRONTIER
3) Stop when a GOAL node is visited
(KEEP EXPANDING OTHERWISE)
What is the Final Cost of A*?
Sum of g(n) along the paths
- DON’T INCLUDE HEURSITICS
Dijkstra’s:
- UNINFORMED
- Goes Through all the nodes of the graph
- No Heuristics / ADDITIONAL INFO
- Basic Attempt to find shortest distance from the nodes on the graph to the destination
what is h(n)?
Euclidean Distance from each node to destination
Heuristics measure of cost as if a node is physically closer to destination
Good Assumption the cost to the destination will be lower
Pros & Cons of A* :
Pros:
- Doesn’t go through all nodes
- safer to assume to expand node with lower straight line distance (LEAVE OUT OTHER NODES )
Cons:
- Can lead to non-optimal paths (UNLIKELY)
Uninformed Search ?
Define the set of strategies having no additional information about the State Space beyond what is give during Problem formulation
What does Uninformed Search do?
-Only generates successors
-Distinguish a goal state from a non goal-state
What is Breadth First Search ?
-An Uninformed Searching Strategy
FRONTIER NODES ARE EXPANDED LAYER BY LAYER
Expanding shallowest unexpanded node in frontier
Similar to a QUEUE (FIFO)
- Unless State otherwise, never add children that are already in the Frontier
Steps for BFS?
-Root node is expanded
- Then the successors of the root
- Repeatedly expand all the successors of the all children, till goal node reached
What are the 3 Quantities used to measure the Performance?
- Branching Factor (b):
Max No. of successor of any Node - Depth (d):
Depth of Shallowest goal Node - Max Length (m):
MAX length of any path in state space
4 quantities that Determine the Performance?
Completeness=>Guarantees finding solution, if 1?
Optimality =>Capability of finding Optimal Solution
Time Complexity => How long to find solution
Space Complexity => Memory space required?
Performance of BFS
Complete:
Yes, if goal node is at some finite d and will find goal node. b must also be finite
Optimal:
Yes, if path cost is a non-decreasing function of the depth of the node
(ALL ACTIONS HAVE SAME COST)
Time: O(b^(d))
Assume Uniform Tree, each node has b successors
Space: O(b^(d))
Stores all Expanded nodes
Frontier is O(b^(d)) AND in Memory it is O(b^(d-1))
What does
I
Always
Take
Goal
Path
stand for?
I = Initial State (agent starts its search)
A=Action Set
(Actions that can be executed in any state)
T = Transition Model
(Mapping between States and Actions )
G = Goal Test (Determine if State is a Goal State)
P= Path Cost Function (Assigns values to each cost)
What is the Solution?
Sequence of Actions from initial state to Goal
What is Cost of Solution?
Sum of the cost of actions from initial to goal
What is the Path?
Sequence of states connected by a sequence of actions
Does goal node appear in Order of nodes visited in BFS?
NO
Does goal node appear in Order of nodes visited in DFS?
YES
What is Depth First search?
-An Uninformed Searching Strategy
==> Expanding the deepest unexpanded node in Frontier
Stack LIFO is used for expansion
Most recently generated node is expanded
- Usually just do the left most node
Steps for DFS?
-Expand the Root first
- Then expand the first successor of root node
(CAN DO IT RANDOMLY)
- Repeat Expanding deepest node until goal is found otherwise go back to try alternative paths
Performance of DFS?
Completeness:
Not complete if search space is Infinite or we
don’t avoid infinite loops.
Yes, only is search space is finite
Optimality:
Not Optimal, because it will expand entire left
subtree, even if goal is first level of subtree
Time: O(b^m)
Depends on the Max length of the path is
Search space
Space: O(b^m)
Store all the nodes from each path from Root
to leaf
Variants of DFS:
b) what performance attribute stays the same for all of these variants?
-Less Memory Usage (LMU)
- Depth LIMITED Search (DLS)
- DLS with LMU
b) Optimality is ALWAYS NO
What is LMU?
If u reach the leaf node for the left-subtree and there is no GOAL node u can remove the entire subtree from memory
Space Complexity become O(bm)
- Store a single path with siblings for each node on the path
- COMPLETE IF the search space is finite
What is DLS?
- has a DEPTH LIMIT L
once limit is reached we go find an alternate path
if L<d may be incomplete if goal node is L+1 position
if L>d it is not optimal
Time complexity reduces to O(b^L) , when L<d
What is DLS with LMU?
Once we reach our DEPTH LIMIT L and if we have found NO goal node we remove the subtree from our memory
Space Complexity = O(bL)
COMPLETE if L => d
What are Informed Search Strategies?
Use problem-specific knowledge beyond problem definition
Can find solutions more efficiently compared to uniformed
General Approach for Informed?
Best-First search:
-Determines which node to expand based on an
evaluation function f(n).
f(n) - acts as cost estimate =>
Lowest cost expanded first
What is Best First Search?
-Determines which node to expand based on an
evaluation function f(n).
Most include a heuristic h(n), which is the estimated cost of the cheapest path from current node to goal
goal node h(n) = 0
Known as GREEDY as will always pick cheapest path
What is the f(n) for A*?
f(n) = g(n)+h(n)
g(n)=> cost to reach node n
h(n) => heuristic from n to goal
Steps for A*?
COMPLEX
-Expand the node in the frontier with smallest f(n)
- Repeated States & Loopy Paths.
- Node already in frontier don’t add
- If the state of a given child is in the Frontier:
-if frontier node has large g(n), replace child
& remove node with the larger g(n)
- Stop when goal is visited
Performance of A*?
A* is Complete & Optimal if h(n) is consistent
- A* is exponential in the length of the solution
CONSTANT STEPS COSTS : O(b^(Σd))
h* is actual cost from root to goal, Σ = (h-h)/h
Σ is RELATIVE ERROR
Space: O(b^d)
is Main Issue with A*
-Keeps all generated nodes in memory
- Keep ALL expanded & ALL nodes in frontier
-NOT suitable for LARGE SCALE PROBLEMS
What does Consistent mean in terms of h(n)?
If the estimate is no greater than the estimated distance from any neighbouring node n’ to the goal, + the cost of reaching the neighbour:
h(n) <= cost(n, n’) + h(n’)
cost is just distance from n to n’ (g(n))
What do design variables represent?
-Candidate solutions of a Problem
-Are variables belonging to pre-defined domains
-There may be one or more design variable in
a given optimisation problem.
- These can be possible decision needed to be made in the problem
What is the objective function?
-Takes design variables as an Input
- Outputs a NUMERICAL value that problem aims to MININMISE OR MAXIMISE
CAN have Multiple Objective functions in Formulation
Defines the Cost or Quality of a Solution
What are Constraints in Formulating Operation Problems?
-Constraints that design variables must satisfy for the solution to be FEASIBLE
-Usually depicted by functions that take
the design variables as input and output a numeric value.
-They specify the values that these functions are allowed to take for the solution to be feasible.
-There may be zero or more constraints in a problem
DEFINES THE FEASIBILITY OF THE SOLUTION
Benefits of Local Search?
DO NOT keep track of the paths or States that have been visited
NOT systematic ,but PROS are:
- Use very little Memory
- Find Reasonable solutions in Large or Infinite
State Space
What are Local Search Algorithms?
Optimisation Algorithms that operate by searching from initial state to neighbouring states
What is The Aim Of a MAXIMISING problem?
Reaching the HIGHEST PEAK/ Global Maximum
What is The Aim Of a MINIMISING problem?
Reaching the LOWEST TROUGH/ Global Minimum
Purpose Of Hill Climbing?
TO find & Reach Global Maximum
Purpose of Gradient Descent
TO find & Reach Global Minimum
Why is Hill Climbing Greedy?
Does not look beyond the immediate neighbours of the current state
What are the 3 Components of Hill Climbing we must design?
-Representation
-Initialisation Procedure
-Neighbourhood Operator
What is Representation?
How to store Design variables in the problem(s)
Should facilitate the Application of the Initialisation Procedure
What is Initialisation Procedure?
How to pick initial solution.
USUALLY RANDOM, Can Be Heuristic
What is Neighbourhood Operator?
How to generate Neighbourhood Solutions
(INCREMENT/STEP SIZE)
Performance of Hill Climbing:
Completeness:
No, Depends on problem formulation & design of the algorithms (GET STUCK ON LOCAL MINIMA)
OPTIMALITY:
Not Optimal, (GET STUCK ON LOCAL MINIMA)
Time: O(mnp)
m = MAX no. of iteration,
n = MAX no. of neighbours,
EACH take O(p) to generate
Space: O(nq+r) ==> r is a constant so ==> O(nq)
n = MAX no. of neighbours,
Variable takes O(q) and
r represents the space to generate the neighbours sequentially(NEGLIGIBLE COMPARED TO n & q)