<<

MAY 31, 2017 PROBLEM SET#4 DR. ALLAA HILAL

University of Waterloo Department of Electrical and Computer Engineering ECE 457A: Cooperative and Adaptive TA: Chris Choi Problem Set #4

Question #1 (Solution):

Give the name of the that results from each of the following cases: a) Local beam search with beam width = 1

Hill Climbing b) Local beam search with one initial state and no limit on the number of states retained

Breadth First Search c) Simulated annealing with T = 0 at all times (and omitting the termination test)

During every iteration in simulated annealing, a candidate solution has a

P(T, R, S) = exp(Quality(R) – Quality(S) / T) where: - T: temperature - R: tweaked candidate solution - S: current candidate solution

If T = 0, then the probability is undefined, making Simulated Annealing act like a algorithm. d) Simulated annealing with T=infinity at all times

If T = infinity, then the probability of replacing S with R is 1.0 then Simulated Annealing acts like Random Walk algorithm.

1

MAY 31, 2017 PROBLEM SET#4 DR. ALLAA HILAL

Question #2 (Solution): a) As with any optimization problem, there are generally four components needed for a precise formulation. 1. Initialization 2. Update function 3. Cost function 4. Termination criteria

1. Initialization: • Pick any piece

2. Update function: • Connect any male connections to remaining female pieces

3. Cost function The goal test will be that all of the pieces are used and created a connected track without any overlapping. The step cost will be the same as the number of pieces.

cost = num of pieces used if overlap(track) or open_ends(track): cost = infinity

4. Termination criteria - Use all pieces - Connect all pieces with no open ends or overlaps

b) We need a complete-state formulation, so let the states be any configuration of the 32 pieces. We need discrete operators, which remove any piece and reconnect it anywhere else; and continuous operators, which change the angle of any joint by some real-valued angle. Unfortunately, especially for closed loops, moving one joint necessarily moves some or all of the others, so we need to be careful how this is carried out. We need a function, which could penalize open pegs, amount of overlapping track, sum of joint distortion angles, number of disjoint connected components.

Question #3 (Solution):

1. Initialization:

[1, 2, 3, 4, 5, 6, 7 ] [Red, Blue, Green, Blue, Red, Black, Blue]

2. Update function: Replace any graph node with any color in this set {Red, Blue, Green, Black}

3. Cost function

cost = len(colours_used) if valid(graph) is False:

2

MAY 31, 2017 PROBLEM SET#4 DR. ALLAA HILAL

cost = infinity

4. Termination criteria Uses fewest possible number of colors (optimal = 3) Using Simulated Annealing to solve problem 3 by hand:

Let:

T: Temperature dT: Temperature change per iteration S: Current candidate solution R: Tweaked candidate solution while T > 0: # tweak current candidate solution R = tweak(S)

# evaluate R_score = cost(R) S_score = cost(S)

# replace current candidate solution? if R_score < S_score or random.random() < exp((S_score - R_score) / T): S = list(R)

# keep record of best candidate solution if S_score < best_score: best = list(S) best_score = S_score

# update T -= dT # decrease temperature

T = 10 dT = 0.1 S = [Red, Blue, Green, Blue, Red, Black, Blue]

Iteration 1:

R = Tweak(S) R = [Red, Black, Green, Blue, Red, Black, Blue]

4 = Cost(S) 4 = Cost(R)

R is not better than S

P(T, R, S) = exp((Cost(S) - Cost(R)) / T) = exp((4 – 4)) / 10) = exp(0) = 1.0

Accept any R:

S = R

3

MAY 31, 2017 PROBLEM SET#4 DR. ALLAA HILAL

S = [Red, Black, Green, Blue, Red, Black, Blue]

Update temperature T:

T = T – dt = 10 – 0.1 = 9.9 Iteration 2:

R = Tweak(S) R = [Red, Blue, Green, Blue, Red, Black, Blue]

4 = Cost(S) 4 = Cost®

R is not better than S

P(T, R, S) = exp((Cost(S) - Cost(R)) / T) = exp((4 – 4)) / 9.9) = exp(0) = 1.0

Accept any R: S = R S = [Red, Blue, Green, Blue, Red, Black, Blue]

Update temperature T: T = T – dt = 9.9 – 0.1 = 9.8

Iteration 3:

R = Tweak(S) R = [Red, Blue, Green, Blue, Red, Green, Blue]

4 = Cost(S) 3 = Cost(R)

P(T, R, S) = exp((Cost(S) - Cost(R)) / T) = exp((4 – 3)) / 9.8) = exp(0.1) = 1.1

Accept R with a probability of 110%:

S = R S = [Red, Blue, Green, Blue, Red, Green, Blue]

Update temperature T:

T = T – dt = 9.9 – 0.1 = 9.7

Optimal solution found [Red, Blue, Green, Blue, Red, Green, Blue]

4