better end plot = fix fallback to RS
This commit is contained in:
parent
650d93585b
commit
0d40f5c246
5 changed files with 72 additions and 46 deletions
|
|
@ -12,7 +12,7 @@ def random(func, init, again):
|
|||
while again(i, val, sol):
|
||||
sol = init()
|
||||
val = func(sol)
|
||||
if val > best_val:
|
||||
if val >= best_val:
|
||||
best_val = val
|
||||
best_sol = sol
|
||||
i += 1
|
||||
|
|
@ -28,7 +28,8 @@ def greedy(func, init, neighb, again):
|
|||
while again(i, best_val, best_sol):
|
||||
sol = neighb(best_sol)
|
||||
val = func(sol)
|
||||
if val > best_val:
|
||||
# Use >= and not >, so as to fallback to random walk on plateus.
|
||||
if val >= best_val:
|
||||
best_val = val
|
||||
best_sol = sol
|
||||
i += 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue