Skip to content

Commit

Permalink
cloning initial best solucion to current solution to avoid aliasing
Browse files Browse the repository at this point in the history
between the best and the current solutions
  • Loading branch information
Laouen committed Sep 1, 2024
1 parent 2a85f7a commit 8ee531b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions thoi/heuristics/simulated_annealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ def simulated_annealing(X: np.ndarray,

# Best solution found
# |batch_size| x |order|
best_solution = current_solution
best_solution = current_solution.clone()
# |batch_size|
best_energy = current_energy
best_energy = current_energy.clone()

no_progress_count = 0
pbar = trange(max_iterations, leave=False)
for _ in pbar:

pbar.set_description(f'mean({metric.upper()}) = {(1 if largest else -1) * best_energy.mean()}')
pbar.set_description(f'mean({metric.upper()}) = {(1 if largest else -1) * best_energy.mean()} - ES: {no_progress_count}')

# Generate new solution by modifying the current solution
# |batch_size| x |order|
Expand Down
8 changes: 4 additions & 4 deletions thoi/heuristics/simulated_annealing_multi_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def simulated_annealing_multi_order(X: np.ndarray,

# Best solution found
# |batch_size| x |order|
best_solution = current_solution
best_solution = current_solution.clone()
# |batch_size|
best_energy = current_energy
best_energy = current_energy.clone()

no_progress_count = 0
pbar = trange(max_iterations, leave=False)
pbar = trange(max_iterations, leave=True)
for _ in pbar:

pbar.set_description(f'mean({metric.upper()}) = {(1 if largest else -1) * best_energy.mean()}')
pbar.set_description(f'mean({metric.upper()}) = {(1 if largest else -1) * best_energy.mean()} - ES: {no_progress_count}')


# |batch_size|
Expand Down

0 comments on commit 8ee531b

Please sign in to comment.