Lecture 3 - Search Flashcards
General pattern for solving Sudoku?
1) select a square (→ Heuristics)
2) check all possibilities (→ Constraint Satisfaction)
3) propagate the information to other squares (write all possible numbers in all squares) (→ Constraint Propagation)
4) repeat these steps until the solution is complete (→ Search)
Steps in a search process?
1) Heuristics
2) Constraint Satisfaction
3) Constraint Propagation
4) Search
What do you need for defining a search problem?
1) A state description
(an abstract representation of the current state of a puzzle)
2) A goal function
(checks whether a state description satisfies the goal)
What is a “state description”?
- An abstract representation of the current state of a puzzle
What is the set of all “state descriptions” called?
State Space
What is a “goal function”?
- checks whether a state description satisfies the goal
Explain the two steps in Simple Exhaustive Search?
1) Generate all possible states
2) Test the goal function for each state
Explain the approach when performing Local Search (it is similar to solving a puzzle by hand)
- keep a single “current state”
- try to improve it by maximizing a heuristic evaluation
- using only “local” improvements aka “actions”
Explain the advantages and disadvantages with “local search”?
Advantages
- memory efficient
- fast in infinite state spaces
Disadvantages
- solution not always found aka no guarantees for
- does not ensure optimality (that the best/shortest solution is found)
State Representation
The image is an example of a state representation from mutilated chess board problem. Choosing a good state representation may be crucial for finding a good solution. How could a better state representation look?
-
What is this problem called and what is the challenge?
Mutilated Chess Board problem: Can you cover a mutilated chess board with dominoes
What constitutes the states in a 8-puzzle?
- The location of the tiles
8-puzzle actions
What computational actions in a 8-puzzle could not be done in the physical world?
- move blank tile (left, right, up, down)
Why is it better to simulate that the blank field moved when trying to solve a 8-puzzle?
Easier than having separate moves for each tile.
Ignore actions like unjamming slides if they get stuck
Why is the complete-state formulation in the 8-queens problem inefficient?
- There are to many states (any configuration of 8 queens on the board)
States in the 8-queens problem?
any configuration of 8 queens on the board
Actions in the 8-queens problem?
- Move one of the queens to another square
Explain the 8-queens problem
The eight queens puzzle isthe problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other; thus, a solution requires that no two queens share the same row, column, or diagonal. There are 92 solutions.
What is meant by heuristics in search algorithms?
- function that estimates the quality of a given state
Example of heuristics in way finding?
straight-line distances may be a good approximation for the true distances on a map
Basic idea of Heuristics in the n-queens problem
Move a queen so that it reduces the number of conflicts → heuristic h is # of queen pairs that attack each other.
Almost always solves n-queens problems almost instantaneously for very large n (e.g. n = 1 000 000)
How do simple search algorithms like hill-climbing search aka greedy local search work?
algorithm:
The hill climbing search algorithm does the following:
- expand the current state (generate all neighbors)
- move to the one with the highest evaluation
- until the evaluation goes down
What is the main problem with hill-climbing search?
Main Problem: Local Optima
- the algorithm will stop as soon as it is at the top of a hill
but it is actually looking for a mountain peak (global uptimum vs many local optima)
Other problems
- ridges
- plateaux
- shoulders
Explain the state space landscape and the related assumptions
state-space landscape
- location: states
- elevation: heuristic value (objective function)
Assumption:
- states have some sort of (linear) order continuity regarding small state changes
Explain a multidimensional state landscape
States may be refined in multiple ways
→ similarity along various dimensions
Using gradient decent what kind of optimum will you find (global or local)?
Most likely you will find a local optimum.
Explain Random Restart Hill-Climbing
Different initial positions result in different local optima → make several iterations with different starting positions
Explain stochastic Hill-Climbing
- select the successor node randomly
- better nodes have a higher probability of being selected
Explain Beam Search
- Keep track of k states rather than just one
k is called the beam size - Algorithm
Start with k randomly generated states
At each iteration, all the successors of all k states are generated
select the k best successors from the complete list and repeat
Explain simulated annealing search
Simulated annealing is an optimization technique inspired by the cooling process of metals. It searches for an optimal solution by exploring both good and bad moves, gradually reducing the likelihood of accepting worse solutions as it “cools.” This approach helps avoid local optima by balancing exploration (higher chance of worse moves initially) and exploitation (focusing on better solutions as the temperature lowers).
Explain Genetic Algorithms
Genetic algorithms are optimization methods inspired by natural selection.
They evolve solutions over generations by combining, mutating, and selecting the fittest individuals from a “population” of solutions. Through crossover and mutation, they explore new solutions, while selection retains the best ones, gradually improving toward an optimal solution.
Explain “Mutation” in relation to the “Genetic Algorithm”
Modelled after mutation of DNA. Take one parent string. Modify a random value.
Explain cross-over in relation to the Genetic Algorithm
Modelled after cross-over of DNA. Take two parent strings, cut them a cross-over point, recombine the pieces. It is helpful if the substrings are meaningful subconcepts.
List the steps in a Genetic “algorithm”?
Basic Algorithm:
1) Start with k randomly generated states (population)
2) A state is represented as a string over a finite alphabet -often a string of 0s and 1s
3) Evaluation function (fitness function)
4) Produce the next generation by selection, cross-over, and mutation
What is genetic programming?
Genetic programming is an optimization technique where computer programs are evolved to solve a problem. It uses principles of natural selection to create, mutate, and recombine programs, selecting the best ones each generation. Over time, this process produces programs that are increasingly effective at the given task.
What is this?
Example of genetic programming operators
Explain the Towers of Hanoi
Rules of the game:
- you are only allowed to move one disk
- you can only place a disk on top of a bigger disk (or the table)
Goal
- move the stack of disks from the first to the third peg
What does Divide-and-Conquer refer to?
General problem solving strategy with many applications also called recursive programming.
How to define the states in a “Constraint Satisfaction Problem” using symbols?
– state is defined by variables Xi with d values from domain Di
In a Constraint Satisfaction Problem (CSP):
• Variables X_i : Each variable represents an element of the problem that needs an assigned value. For example, in a scheduling problem, variables could represent time slots. • Domains D_i : Each variable X_i has a domain D_i , which is a set of possible values it can take. For instance, the domain for a time slot might be specific times of the day.
A state in the CSP is then defined by assigning specific values from each D_i to each X_i , such that these assignments respect the constraints of the problem. Constraints limit which combinations of values are valid across variables.
For example, in a map-coloring problem, variables are regions, domains are colors, and constraints prevent adjacent regions from having the same color. A state here is a specific assignment of colors to all regions.
List example of “Constraint Satisfaction Problems” (CSPs)?
- Sudoku
- Cryptarithmetic puzzle
- Graph/ Map-Colering
- n-queens
List Real-World CSPs
- Assignment problems (e.g., who teaches what class)
- Timetabling problems (e.g., which class is offered when and where?)
- Hardware configuration
- Spreadsheets
- Scheduling (Job scheduling)
- Floorplanning
Draw a constraint graph for the australian states
(Two neighboring nodes must not have the same color)
Explain the constrain graph?
- nodes are variables
- edges indicate constraints between them
In this case
B, D, X has a common constraint because B + D = D + X and A + X = A
Where X is 10 x X
Draw the constraint graph for this cryptarithmetic puzzle
Connected nodes in a constrain graph indicate that there are constraints between nodes. These constraints can also be written as equations. Write the constraint equations for this particular constraint graph?
List the types of constraints in a constraint graph
- Unary constraints
(involve a single variable, – e.g., South Australia ≠ green) - Binary constraints
(involve pairs of variables, – e.g., South Australia ≠ Western Australia) - Higher-order constraints
(involve 3 or more variables, – e.g., 2⋅ W + X1=10⋅X2 + U) - Preferences (soft constraints)
(– e.g., red is better than green
– are not binding, but task is to respect as many as possible)
Explain the two principal approaches for solving CSP problems?
Search:
– successively assign values to variable
– check all constraints
– if a constraint is violated → backtrack until all variables have assigned values
Constraint Propagation:
– maintain a set of possible values Di for each variable Xi
– try to reduce the size of Di by identifying values that violate
some constraints
What is Backtracking search?
- Systematic Exploration
- Depth-First Approach
- Constraint Satisfaction
Backtracking search is a method for solving problems by trying one choice at a time. If a choice leads to a conflict or dead-end, it “backtracks” to the previous step and tries a different option. This process repeats until it finds a solution that satisfies all conditions or concludes that no solution is possible.
How can a search problem be defined?
For defining a search problem we need a:
- state description and a
- goal function
What does Heuristics may help to do?
Guide the search into more promising regions of the search space
What can you do to prevent that a local optima is found instead of the global optima we are looking for.
- Random Restart Hill Climbing
- Stochastic Hill Climbing
What may Constraints help to avoid?
unnecessary search
What general-purpose heuristics are there for selecting constrained variables and their values?
- Minimum Remaining Value (MRV) Heuristic: Choose the variable with the fewest possible values left. It prioritizes the most “constrained” variable, aiming to detect failure early.
- Degree Heuristic: If multiple variables have the same MRV, select the one involved in the most constraints with other unassigned variables. This helps reduce options for future choices, simplifying the problem.
- Least Constraining Value Heuristic: Once a variable is chosen, pick the value that leaves the most options open for remaining variables. It reduces the risk of conflicts later on.
These heuristics help solve problems more efficiently by guiding the search to avoid dead-ends.
How does constraint propagation work?
– maintain a set of possible values Di for each variable Xi
– try to reduce the size of Di by identifying values that violate some constraints
Explanation
Constraint propagation works by reducing the possible values of variables based on constraints in the problem. When a variable is assigned a value, constraint propagation updates related variables to eliminate any values that would cause conflicts. This simplifies the problem by narrowing down choices early on, making it easier to find a solution or detect conflicts.
Complex problems may be solved by reducing them to less
complex problems.
What is the key idea of divide-and-conquer?
1) Decompose the problem into simpler partial problems (DIVIDE)
2) Solve each of these simpler problems (CONQUER)
3) Combine the partial solutions to a complete solution
How to define the states in a “Constraint Satisfaction Problem”?
In a Constraint Satisfaction Problem (CSP), states are defined by assignments of values to variables. Each state represents a partial or complete assignment where variables have been given values that must satisfy the problem’s constraints. A complete state is one where all variables are assigned, and a solution is found if it satisfies all constraints.