Skip to content

Commit c84227d

Browse files
committed
Remove check for objective_higher_is_better==True in simulated annealing, as it is already done by CostFunc
1 parent 3ff0beb commit c84227d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

kernel_tuner/strategies/simulated_annealing.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
5454
print(e)
5555
return cost_func.results
5656

57-
ap = acceptance_prob(old_cost, new_cost, T, tuning_options)
57+
ap = acceptance_prob(old_cost, new_cost, T)
5858
r = random.random()
5959

6060
if ap > r:
@@ -85,9 +85,9 @@ def tune(searchspace: Searchspace, runner, tuning_options):
8585

8686
tune.__doc__ = common.get_strategy_docstring("Simulated Annealing", _options)
8787

88-
def acceptance_prob(old_cost, new_cost, T, tuning_options):
88+
def acceptance_prob(old_cost, new_cost, T):
8989
"""Annealing equation, with modifications to work towards a lower value."""
90-
error_val = sys.float_info.max if not tuning_options.objective_higher_is_better else -sys.float_info.max
90+
error_val = sys.float_info.max
9191
# if start pos is not valid, always move
9292
if old_cost == error_val:
9393
return 1.0
@@ -98,8 +98,6 @@ def acceptance_prob(old_cost, new_cost, T, tuning_options):
9898
if new_cost < old_cost:
9999
return 1.0
100100
# maybe move if old cost is better than new cost depending on T and random value
101-
if tuning_options.objective_higher_is_better:
102-
return np.exp(((new_cost-old_cost)/new_cost)/T)
103101
return np.exp(((old_cost-new_cost)/old_cost)/T)
104102

105103

0 commit comments

Comments
 (0)