• No results found

21simulated annealing

N/A
N/A
Protected

Academic year: 2020

Share "21simulated annealing"

Copied!
32
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

2

Outline

Hill climbing

Best-first search

(3)

Local and Global max and min

• A real-valued function f defined on a domain X has

global (or absolutemaximum

point at x∗ if f (x ∗) ≥ f(x) for all x in X.

Similarly, the function has

global (or absoluteminimum

point at x∗ if f(x∗) ≤ f(x) for all x in X. The value

of the function at a maximum point is called the maximum value of the function and the value of the function at a minimum point is called the minimum value of the function.

(4)

4

Hill Climbing

(5)
(6)

Hill Climbing - Algorithm

1. Pick a random point in the search space 2. Consider all the neighbors of the

current state

3. Choose the neighbor with the best quality and move to that state

4. Repeat 2 thru 4 until all the neighboring states are of lower quality

(7)

Hill Climbing - Algorithm

Function HILL-CLIMBING(Problem) returns a solution state

Inputs:Problem, problem

Local variables:Current, a node

Next, a node

Current = MAKE-NODE(INITIAL-STATE[Problem]) Loop do

Next = a highest-valued successor of Current

If VALUE[Next] < VALUE[Current] then return

Current

Current = Next

(8)
(9)
(10)

10

Hill Climbing

Generate-and-test + direction to move.

(11)

11

Simple Hill Climbing

Algorithm

1. Evaluate the initial state.

2. Loop until a solution is found or there are no new operators left to be applied:

 Select and apply a new operator

 Evaluate the new state: goal  quit

(12)

12

Simple Hill Climbing

(13)

13

Steepest-Ascent Hill Climbing

(Gradient Search)

(14)

14

Steepest-Ascent Hill Climbing

(Gradient Search)

Algorithm

1. Evaluate the initial state.

2. Loop until a solution is found or a complete iteration produces no change to current state:

 SUCC = a state such that any possible successor of the current state will be better than SUCC (the worst state).

 For each operator that applies to the current state, evaluate the new state:

goal  quit

better than SUCC  set SUCC to this state

(15)

15

Hill Climbing: Disadvantages

Local maximum

A state that is better than all of its neighbours, but not

(16)

16

Hill Climbing: Disadvantages

Plateau

A flat area of the search space in which all neighbouring

(17)

17

Hill Climbing: Disadvantages

Ridge

The orientation of the high region, compared to the set

of available moves, makes it impossible to climb up.

However, two moves executed serially may increase

(18)

18

Hill Climbing: Disadvantages

Ways Out

Backtrack to some earlier node and try going in a different direction.

(19)

19

Hill Climbing: Disadvantages

Hill climbing is a local method:

Decides what to do next by looking only at the “immediate” consequences of its choices.

(20)

20

Hill Climbing: Conclusion

Can be very inefficient in a large, rough problem space.

Global heuristic may have to pay for

computational complexity.

Often useful when combined with other

(21)

Simulated Annealing Search

• Idea: escape local maxima by allowing some "bad" moves but gradually decrease their frequency

• One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1

(22)

What is Annealing

• Annealing is a thermal process for obtaining

low energy states of a solid in a heat bath.

• The process contains two steps:

– Increase the temperature of the heat bath to a maximum value at which the solid melts.

– Decrease carefully the temperature of the heat bath until the particles arrange themselves in the ground state of the solid. Ground state is a minimum energy state of the solid.

(23)

Simulated Annealing

• To apply simulated annealing with

optimization purposes we require the

following:

– A successor function that returns a “close” neighboring solution given the actual one. This will work as the “disturbance” for the particles of the system.

– A target function to optimize that depends on the current state of the system. This

(24)

Simulated Annealing

• The search starts with a randomized

state.

• In a polling loop we move to

neighboring states

• We always accept the moves that

decrease the energy

(25)

Simulated Annealing

• Decrease the temperature slowly, accepting

less bad moves at each temperature level until at very low temperatures the algorithm

(26)
(27)

27

Simulated Annealing

A variation of hill climbing in which, at the beginning of the process, some downhill moves may be made.

To do enough exploration of the whole space

early on, so that the final solution is relatively insensitive to the starting state.

(28)

28

Simulated Annealing

Physical Annealing

Physical substances are melted and then gradually cooled until some solid state is reached.

The goal is to produce a minimal-energy state.

Annealing schedule: if the temperature is lowered sufficiently slowly, then the goal will be attained.

(29)

29

Simulated Annealing

Algorithm

1. Evaluate the initial state.

2. Loop until a solution is found or there are no new operators left to be applied:

 Set T according to an annealing schedule

 Selects and applies a new operator

 Evaluate the new state: goal  quit

E = Val(current state)  Val(new state)

E < 0  new current state

(30)

30

Best-First Search

Depth-first search: not all competing branches having to be expanded.

Breadth-first search: not getting trapped on dead-end paths.

(31)

Simply Logical – Chapter 6

© Peter Flach, 2000

Hill-climbing

search_hc(Goal,Goal ):-goal(Goal).

search_hc(Current

,Goal):-children(Current,Children), select_best(Children,Best), search_hc(Best,Goal).

p.128

% hill_climbing as a variant of best-first search

% hill_climbing as a variant of best-first search

search_hc([

search_hc([GoalGoal|_],Goal|_],Goal):- ):-goal(

goal(GoalGoal).). search_hc([

search_hc([CurrentCurrent|_],Goal):- |_],Goal):-children(

children(CurrentCurrent,,ChildrenChildren),), add_bstf(

add_bstf(ChildrenChildren,[],NewAgenda,[],NewAgenda),), search_hc(

(32)

Code of c++

• #include <cmath> • #include <random> • #include <utility> • #include <algorithm>

• // To find a status with lower energy according to the given condition template<typename status, typename count, typename energy_function, typename temperature_function, typename next_function, typename generator> status simulated_annealing(status i_old, count c, const

energy_function& ef, const temperature_function& tf, const next_function& nf, generator& g)

• { auto e_old = ef(i_old); status i_best = i_old; auto e_best = e_old; std::uniform_real_distribution<decltype(e_old)> rf(0, 1);

• for(; c > 0; --c)

• { status i_new = nf(i_old, g);

• auto e_new = ef(i_new); if(e_new < e_best){ i_best = i_new ; e_best = e_new ; } if( e_new < e_old || std::exp( (e_old - e_new) / tf(c) ) > rf(g) ){ i_old =

std::move(i_new); e_old = std::move(e_new); } } return(i_best); }

References

Related documents

Abstract— WPAN is restricted area network defined with energy limits and sensing limits. This network form is defined under controller devices. As the nodes moves outside the

Occurrence and genetic diversity of lemon sharks (Negaprion Occurrence and genetic diversity of lemon sharks (Negaprion brevirostris) at a nursery ground at the Chandeleur Islands,

The questionnaire was in its original English ver- sion created from items which were saturating 3 factors: overall acceptance of wom- en at managerial level (10 items),

The objective of this case report series was to describe the outcomes of three patients with poor quality mammary soft-tissue support who underwent primary cosmetic breast

Activity determination of the arginine degrading enzymes The obtained pure colonies were subjected to further activity analysis of arginine degrading enzymes using

Das [6] has studied the effect of first order chemical reaction in thermal radiation hydro magnetic free convective heat &amp; mass transfer flow of a

Indefinite orders of protection provide increased security for survivors of domestic violenceI. 1 Short-term protective orders,

Well diffusion assay was performed to check antibacterial activity of Lactobacilli strains against ESBL isolated from cardiac patients.. Results were observed