Exam Flashcards
Whats the difference between DFS and BFS?
BFS = guaranteed shortest path from start to goal
DFS = may get lost in search and depth-bound may be imposed
BFS = bad branching factor
DFS = may be long and not optimal
DFS = more efficient for big search spaces (high branching factor)
DFS Alg
def dfs (in Start, out State)
open = [Start];
closed = [];
State = failure;
while (open <> []) AND (State <> success)
begin
remove the leftmost state from open, call it X;
if X is the goal, then
State = success
else begin
generate children of X;
put X on closed
eliminate the children of X on open or closed
put remaining children on left end of open
end else
endwhile
return State;
enddef
BFS alg
def bfs (in Start, out State)
open = [Start];
closed = [];
State = failure;
while (open <> []) AND (State <> success)
begin
remove the leftmost state from open, call it X;
if X is the goal, then
State = success
else begin
generate children of X;
put X on closed
eliminate the children of X on open or closed
put remaining children on right end of open
end else
endwhile
return State;
enddef
How does Best FS work?
Min cost nodes are expanded 1st.
shortest path not guaranteed.
Try to minimize the cost of finding a solution.
Combination of DFS and BFS with heuristics
Whats the difference between Hill climbing and BFS?
BFS = global states, Hill climbing = local states
What does the HC alg generate?
Partial tree/graph
What is the problem with Greedy HC?
can get stuck in local optima
What are the 4 steps of local search?
Generate initial solution
Local search
Perturbation
Acceptance cirteria
What are the 2 ways to get an initial solution in ILS?
random solution or one returned by greedy construction heuristc
(LS is already available for most solutions)
Perturbation: random move in a neighborhood of higher irder than current can be very effective
ILS Alg:
ILS(){
generate initial solution
perform local search
while(stopping cond not met){
perturb;
local search
check acceptance cirterion
}
}
ILS Alg 2 (Chapter 2A)
generate init solution
apply LS Alg
Obtain local optimum (local search)
perturb local optimum to obtain new solution
apply LS Alg to new solution
If new solution is better than current solution update current
What happens to the temperature in SA?
Temp T starts high and is lowered with each iteration.
What happens with a new candidate solution at each iteration?
the new candidate solution’s distance from the ideal is proportional to the temperature
What does the temperature influence?
The acceptance of lower values.
SA Alg:
Best = Current = {}
Set initial T in the same magnitude as the typical differences between adjacent losses (costs)
t = 1;
while (stopping condition not met){
set NEXT to adjacent state referred to as Current;
cost = cost(NEXT) - cost(Current)
Set Current = NEXT with prob 1/exp(-cost/T)
if cost(Current) < cost(BEST) then Best = Current;
t = t+1
T = T0/log(t+1)
What methods are needed for SA?
1 Method to generate initial solution
2 Generation function to find neighbours in order to select a NEXT candidate
3 Cost function
4 Eval criterion
5 Stop criterion
SA steps:
1 Generate current solution
2 Eval solution
3 Generate 3 solutions from neighbourhoods
4 let next be best of neighbours
5 if(f(Vc) <f(Vn)) Vc = Vn
5.1 if If f(Vc) >f(Vn) we will evaluate the Metropolis function given by
= e((Vc-Vn)/Temperature)< random(0,1)
6 Update T
SA adv:
Can be applied to large number of problems.
Tuning parameters are easy
Can take time but solutions are usually good
Can find the best solution
Disadv of SA
Can take time. Can leave optimal solution and not find it. (Keep track of the best solution)
What principle does Evolutionary Algs follow?
survival of the fittest
Generic Evolutionary Alg:
Init population with random individuals
Eval each indiv
while(termination condition not met){
Select parents
Genetic manipulation
Evaluate new individuals
Select individuals for next generation}
What are the key stages in Generic EA?
Initial pop generation
Evaluation of every individual in the population
Selection of parents
Application of genetic operators
Evaluation of every individual in the population
Population update (generational/steady state)
Check for the stopping cirteria
What does a fitness function do?
Evaluates the suitability of an individual
What do Genetic Operators do?
Creates offspring of each gen
GA Alg:
Create initial pop
Calc fitness of all individuals
while (termination cond not met){
Select fitter individuals for reproduction
Recombine individuals
Mutate individuals
Eval fitness of all individuals
Generate a new population}
How does Tournament selection work?
Select random individuals according to the tournament size.
Select fittest to be parent 1 and the same procedure for parent 2
What happens if Tournament selection size is equal to the size of the population vs 1
1 = completely random
Size = Only the fittest indiv will become the parents
What are the different crossovers?
One-point, Two-point, Uniform
Whats the difference between the types of crossovers?
1 point: select 1 point to crossover at. 1st part upto that point is of 1 parent and after that point is of other parent.
2 point: Same but the section between the points are swapped between parents
Uniform: Each bit is considered individually, and a random process decides which parent will be chosen
How does one decide if a bit needs to be mutated?
Use a probability alg.
What are the parameters for a GA?
Population size
Selection type
Cross over type + rate
Mutation type + rate
Stopping criteria
What are the advantages of a GA?
Easy to understand
modular, separate from application
Support multi-objective optimization
Easy to exploit prev/alt solutions
Flexible building blocks for hybrid applications
Study the GA example in TSP- Genetic Algorithm file
Where does GP search for a solution?
In program space?
GP Alg:
Create initial population of programs
Execute each program and establish the fitness.
while(termination condition not met){
Select fitter programs to participate in reproduciton
Create new programs using genetic operators and update the population
Execute each new program and establish the fitness
}
How are genetic programs represented?
As Syntax trees
What are the tree generation methods in GPs?
Full, Grow and Ramped-half and half
What are the parameters for GP?
Initial tree depth
Max tree depth
Pop size
What are some rules for GP.
The function set is problem dependent(+-*/)
Terminal set is constants (a,b,c,d)
root and middle nodes obtain values from the function set.
Leaf nodes obtain values from terminal set
Fitness function is problem dependant
What are the Selection methods for GP?
Tournament selection
Fitness proportionate
What are the Genetic Operators for GP?
Subtree crossover
Grow mutation
Reproduction (move parents into next population)
What are the 2 types of population update in Gp?
Steady state: Population is updated in such a manner that one offspring replaces a member of the current population based on fitness
Generational:
What are the 2 termination conditions of GPs?
Objective met
Number of generations achieved
What are some applications of GPs?
Symbolic regression
Robotics
Cyber-security
Finance
Basic approach of GP:
Create init pop randomly
Each program is constructed from building blocks needed to solve the problem GP is being applied to.
Evaluate the fitness of each program
Select good programs to act as parents
generate new programs
GP algorithm:
Create initial pop
Establish fitness
while (termination condition not met){
select fitter programs to reproduce
Create new programs and update pop
establish fitness}
return best
By what is the number of programs specified in GP?
The user through a population size parameter
How does the full method work in GP?
it constructs trees in such a manner that all nodes up to a depth of (max depth -1) are functions and max depth = terminals
How does the grow method work in GP?
Create trees of variable length, Nodes between root and max depth -1 may be random between terminal/function. max depth = terminals
How does the ramped 1/2-1/2 method work in GP?
It combines the full and grow methods
GE alg:
Create initial population of variable length binary strings
Map via BNF grammar
eval fitness
while(termination cond not met){
Select fitter indiv for reproduction
Recombine selected individuals
mutate offspring
eval fitness
replace all individuals in the population with offspring}
How is the initial population generated in GE?
Randomly generate a population of variable length binary strings (individuals)
Length is determined randomly from a lower/upper bound
Population size and variable length limits are user specified
how does mapping work in GE?
Production rules needs to be specified
Must contain domain knowledge
Mapping involves converting binary string to decimal and using them to select production rules
Genotype to phenotype