Skip to content

Instantly share code, notes, and snippets.

@sile
Created January 27, 2020 15:29
Show Gist options
  • Save sile/a8c13f068273d616a6c45ed0bb93e299 to your computer and use it in GitHub Desktop.
Save sile/a8c13f068273d616a6c45ed0bb93e299 to your computer and use it in GitHub Desktop.
Kurobako blog: sa.py
# A solver implementation based on Simulated Annealing algorithm.
from kurobako import solver
from kurobako.solver.optuna import OptunaSolverFactory
import optuna
class SimulatedAnnealingSampler(optuna.BaseSampler):
# Please refer to
# https://github.com/optuna/optuna/blob/v1.0.0/examples/samplers/simulated_annealing_sampler.py
# for the implementation.
...
def create_study(seed):
sampler = SimulatedAnnealingSampler(seed=seed)
return optuna.create_study(sampler=sampler)
if __name__ == ‘__main__’:
factory = OptunaSolverFactory(create_study)
runner = solver.SolverRunner(factory)
runner.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment