Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kernel_tuner/strategies/dual_annealing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""The strategy that uses the dual annealing optimization method."""
import scipy.optimize
import numpy as np

from kernel_tuner.util import StopCriterionReached
from kernel_tuner.searchspace import Searchspace
Expand All @@ -16,7 +17,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
method, max_fevals = common.get_options(tuning_options.strategy_options, _options)

#scale variables in x to make 'eps' relevant for multiple variables
cost_func = CostFunc(searchspace, tuning_options, runner, scaling=True)
cost_func = CostFunc(searchspace, tuning_options, runner, scaling=True, invalid_value=np.inf)

bounds, x0, _ = cost_func.get_bounds_x0_eps()

Expand Down
4 changes: 2 additions & 2 deletions kernel_tuner/strategies/simulated_annealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def acceptance_prob(old_cost, new_cost, T):
# if start pos is not valid, always move
if isinstance(old_cost, ErrorConfig):
res = 1.0
# if we have found a valid ps before, never move to nonvalid pos
# if we have found a valid pos before, never move to nonvalid pos
elif isinstance(new_cost, ErrorConfig):
res = 0.0
# always move if new cost is better
Expand All @@ -108,7 +108,7 @@ def acceptance_prob(old_cost, new_cost, T):
abs_diff = old_cost - new_cost

# relative to abs(old_cost), as the cost might be negative
rel_diff = abs_diff / np.abs(old_cost)
rel_diff = abs_diff / (np.abs(old_cost) if old_cost != 0.0 else 1e-20)

# exponential decay
res = np.exp(rel_diff / T)
Expand Down