Skip to content

Instantly share code, notes, and snippets.

@sile
Created Jan 27, 2020
Embed
What would you like to do?
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