library_for_python

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Kazun1998/library_for_python

:warning: Heuristic/Annealing.py

Code

from random import random
from math import exp

class Annealing:
    def __init__(self, temperature: float, alpha: float, phase: int = 1) -> "Annealing":
        self.temperature = temperature
        self.alpha = alpha
        self.phase = phase
        self.count = 0

    def judge(self, before, after) -> bool:
        self.count += 1
        if self.count == self.phase:
            self.temperature *= self.alpha
            self.count = 0

        if after == before:
            return False

        if after > before:
            return True
        else:
            return random() < exp((after - before) / self.temperature)
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page