Title: Problem Difficulties
1Problem Difficulties
- Search space
- (can the best answer be found in time?)
- 2. Complexity
- (simplification renders the solution useless)
- 3. Objective function
- (noise and time variance)
- 4. Constraints
- (difficult to find one feasible solution,
- harder to find optimum solution)
- People and Politics
2Algorithmic Approach to Problem Solving
- Three basic concepts are common to every
algorithmic approach to problem solving - Representation
- Objective
- Evaluation Function
- Representation encoding of problem solution.
- Objective what is the goal?
- Evaluation (Fitness) Function quality of
solution.
3Problem Types
It is important to recognise different problem
types as it may suggest appropriate methods to
find the solution.
- Linear,
- SAT Boolean Satisfiability Problem
- TSP Travelling Salesman Problem
- NLP Non-linear Programming
- Proofs
- Constraint Satisfaction Problems
- Other types and subdivisions exist
4Classical Algorithms
- Two main classes of classical algorithms
- Operate on complete solutions
- Interruptible to give potential solution
- Quality depends on the accuracy of
procedure-problem - Requires knowledge of problem
- Each algorithm can only tackle a class of
problems - Evaluate partially constructed or approximate
solutions
Enumeration fails on real-world problems when the
number of alternative solutions is prohibitively
large
5Contents
- Problems
- Basic Concepts Representation, objective,
evaluation problem definition, neighbourhoods
and optima - Basic Problems Linear, SAT, TSP, NLP
Constraint satisfaction problems - Basic Techniques Exhaustive, Local Search
Simplex method. - Methods 1 Greedy, Dynamic programming,A,
Branch Bound and Divide Conquer. - Methods 2 Simulated Annealing, TS
- Methods 3 Evolutionary Approaches
- Constraint Handling Techniques
- Hybridise and Tune Practical tips
- Test are you sure that you have the best
solution?
6Classical Algorithms
- Two main classes of classical algorithms
- Operate on complete solutions
- Evaluate partially constructed or approximate
solutions - Utilised when complete solution methods fail
- Decompose problem into simpler sub-problems and
then reassemble - Or solve complex problem in a series of simpler
stages
Methods include Greedy, Dynamic programming, A,
Branch Bound and Divide Conquer.
7Greedy Algorithms
- E.g. SAT solved by Greedy Algorithm
- For each variable from 1 to n, in any order,
assign the truth value that results in satisfying
the greatest number of currently unsatisfied
clauses. If theres a tie, then choose one of
the best options at random.
- Design a SAT problem to show that this method
sometimes fails! - Now suggest an amendment to the algorithm and
design another problem - There is no foolproof greedy algorithm for SAT!
8Greedy Algorithms
- E.g. TSP solved by Greedy Algorithm
- Proceed to the nearest unvisited city until tour
complete
Greedy methods are conceptually simple Pay for
this simplicity by failing to provide good
solutions to complex problems with interacting
parameters (e.g. real-world problems)
9Divide and Conquer
- Split complicated problems into smaller, simpler
problems. - Feasible if the time and effort required to
decompose, solve all sub-problems and then
reassemble solution is less than the original
problem
10Dynamic Programming
- The problem can be decomposed into sequence of
decisions made at various stages - Each stage has a number of possible states
- The decision takes you from a state at one stage
to some state at the next stage - The best sequence of decisions at any stage is
independent of the decisions made at prior stages - There is a well defined cost for traversing from
state to state across stages. Moreover, there is
a recursive relationship for choosing the best
decisions to make. - Termed Dynamic as time often plays a significant
role, also the order of operations may be crucial
11Dynamic Programming
- Stagecoach Problem (Harvey Wagner)
- Cross from state 1 to state 10
- 2 5
- 8
- 1 3 6 10
- 9
- 4 7
- At a cost of
- 2 3 4 5 6 7 8 9 10
- 1 2 5 8
- 3 6 9
- 4 7
12Dynamic Programming
- Complex heuristic algorithm, but often works
where greedy fails. - Define
- n stages, with decision x at any given state s
- Cost function f(s,xn) for the best sequence of
decisions (termed a policy) - Goal
- Minimise f , where xn(s) achieves this value
- Find last move first and work backwards!e.g.
- 1
-
- 2
13Branch and Bound
- S
- Include
- If edge 2-3 costly,
- then can ignore.
- Can estimate lower bound (sum of average of best
adjacent cities), then ignore branches greatly
exceeding the lower bound.
(1,2)
(1,2)
(1,2) (2,3)
(1,2) (2,3)
(1,2) (2,3)
(1,2) (2,3)
(1,2) (2,3) (3,4) (4,5)
(1,2) (2,3) (3,4) (4,5)
14Branch and Bound
- Procedure
- Begin
- Initialise Candidate Set
- Initialise current upper limit
- while (not terminated) do
- Remove best candidate
- Reduce or subdivide
- Update upper limit
- for all sets do
- If lower limit of set gt
- current upper limit
- then remove this set
- End
15Game Trees
- A game tree is a directed graph
- nodes are positions in a game
- edges are moves
- Minimax 2 players A B
- A scores positively, B negatively
- Alpha-beta pruning reduces the number of
evaluated nodes. - A ply is one turn
16Min-Max
A plays first (X) Wants to maximise their score B
plays next (O) Wants to minimise their
score Diagram Y Lin
17A Algorithm
- Greedy algorithm extended to best-first search by
introducing more information - (Increased feedback from the environment)
- Branch bound considers Depth First search
- Breadth First search is also possible,
- but need a heuristic to guide the search.
- Best-first
- Begin
- Visit the first node
- for each available sub-tree do
- Assign a value for the sub-tree
- Choose the best available node
- best-first with this node
- End
18A Algorithm
- The heuristic has two components
- Merit of past decisions
- Potential inherent in remaining decisions
- 1 is usually easy to calculate, but
- 2 requires a good estimate
- Best-first extended to A Algorithm by
considering admissibility - An algorithm is admissible if it always
terminates at the optimum solution - Try to underestimate the actual cost, so you will
always find the optimum!
19Dijkstra's algorithm
- Depth-first search, breadth-first and Dijkstra's
algorithm are all special cases of A algorithm - Given a graph, G, with edges E of the form (v1,
v2) and vertices v, and a source vertex, s - Set every distance to INFINITY as path unknown
- The distance from the source to the source is
defined to be zero - / This loop corresponds to sending out the
explorers walking the paths, where the step of
picking "the vertex, v, with the shortest path to
s" corresponds to an explorer arriving at an
unexplored vertex / - While (not all vertices searched)
- pick the vertex, v with the shortest path to s
- add v to searched vertices
- for each edge of v, (v1, v2)
- "relaxation reduce estimate of shortest
path. - if(distv1 length(v1, v2) lt distv2)
- distv2 distv1 length(v1, v2)
- prevv2 v1
- end if
- end for
http//www.student.cs.uwaterloo.ca/cs341/Old_cour
ses/W03/section1/Unit20.pdf
20 Summary of Traditional Methods
- Some problems can be solved by classical
algorithms - e.g. a quadratic evaluation function can be
solved by gradient minimisation methods. - Each algorithm is suited to a problem and may
falter or fail on other problems - Could use complete solutions
- (time-consuming and may get trapped in local
optima ) - or partial solutions,
- (may be complex to implement and may not improve
things) - Now Consider Modern Heuristics
21Bridge Question
- Four travellers have to cross an old bridge on a
dark night. They have one source of light, which
must be used when crossing the bridge. The old
bridge can only support two people at a time. - One traveller takes one minute to cross. The
next, two minutes, the third five minutes and
finally the one on crutches takes ten minutes. - Whenever a pair of travellers go together it is
the slowest person who determines the total
time.What is the shortest total time for all the
travellers to cross the bridge? - Define the problem, stating all sensible
assumptions. 5 - Specify an algorithmic approach to solving this
problem. 6 - Detail two methods (classical or heuristic) to
solve this problem. 6 - Solve this problem, including commenting on the
worth of at least one solution 3