def __init__(self, fun, x0, bounds, seed=None, minimizer_kwargs=None,
temperature_start=5230, qv=2.62, qa=-5.0,
maxfun=1e7, maxsteps=500, pure_sa=False):
if x0 is not None and not len(x0) == len(bounds):
raise ValueError('Bounds size does not match x0')
lu = list(zip(*bounds))
lower = np.array(lu[0])
upper = np.array(lu[1])
# Checking that bounds are consistent
if not np.all(lower < upper):
raise ValueError('Bounds are note consistent min < max')
# Wrapper for the objective function and minimizer
if minimizer_kwargs is None:
minimizer_kwargs = dict()
self.owf = ObjectiveFunWrapper(bounds, fun, **minimizer_kwargs)
# Initialization of RandomState for reproducible runs if seed provided
self.rs = check_random_state(seed)
# Initialization of the energy state
self.es = EnergyState(lower, upper)
self.es.reset(self.owf, self.rs, x0)
# Maximum number of function call that can be used a stopping criterion
self.maxfun = maxfun
# Maximum number of step (main iteration) that can be used as
# stopping criterion
self.maxsteps = maxsteps
# Minimum value of annealing temperature reached to perform
# re-annealing
self.temperature_start = temperature_start
self.temperature_restart = 0.1
# VisitingDistribution instance
vd = VisitingDistribution(lower, upper, qv, self.rs)
# Markov chain instance
self.mc = MarkovChain(qa, vd, self.owf, self.rs, self.es)
self.qv = qv
self.pure_sa = pure_sa
评论列表
文章目录