def __init__(self, func, constraint_weights, constraint_rhs, constraint_check=None, return_nan=True, verify=True):
assert isinstance(func, TestFunction)
assert len(constraint_weights) == len(constraint_rhs)
super(Constrainer, self).__init__(func.dim, verify)
self.bounds, self.min_loc, self.fmax, self.fmin = func.bounds, func.min_loc, func.fmax, func.fmin
self.func = func
self.constraint_weights = constraint_weights
self.constraint_rhs = constraint_rhs
self.return_nan = return_nan
self.classifiers = list(set(self.classifiers) | set(['constraint']))
if constraint_check is not None:
self.constraint_check = constraint_check
else:
self.constraint_check = Constrainer.default_constraint_check
python类fmin()的实例源码
def __init__(self, func, noise_type, level, verify=True):
assert isinstance(func, TestFunction)
if level <= 0:
raise ValueError('Noise level must be positive, level={0}'.format(level))
super(Noisifier, self).__init__(func.dim, verify)
self.bounds, self.min_loc, self.fmax, self.fmin = func.bounds, func.min_loc, func.fmax, func.fmin
self.type = noise_type
self.level = level
self.func = func
self.classifiers = list(set(self.classifiers) | set(['noisy']))
def __init__(self, dim=2):
assert dim == 2
super(Adjiman, self).__init__(dim)
self.bounds = ([-1, 2], [-1, 1])
self.min_loc = [2, 0.10578]
self.fmin = -2.02180678
self.fmax = 1.07715029333
self.classifiers = ['unimodal', 'bound_min']
def __init__(self, dim=2):
super(Alpine01, self).__init__(dim)
self.bounds = lzip([-6] * self.dim, [10] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 0
self.fmax = 8.71520568065 * self.dim
self.classifiers = ['nonsmooth']
def __init__(self, dim=2):
assert dim == 2
super(Alpine02, self).__init__(dim)
self.bounds = lzip([0] * self.dim, [10] * self.dim)
self.min_loc = [7.91705268, 4.81584232]
self.fmin = -6.12950389113
self.fmax = 7.88560072413
self.classifiers = ['oscillatory', 'multi_min']
def __init__(self, dim=2):
super(ArithmeticGeometricMean, self).__init__(dim)
self.bounds = lzip([0] * self.dim, [10] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 0
self.fmax = (10 * (self.dim - 1.0) / self.dim) ** 2
self.classifiers = ['bound_min', 'boring', 'multi_min']
def __init__(self, dim=2):
assert dim == 2
super(BartelsConn, self).__init__(dim)
self.bounds = lzip([-2] * self.dim, [5] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 1
self.fmax = 76.2425864601
self.classifiers = ['nonsmooth', 'unimodal']
def __init__(self, dim=2):
assert dim == 2
super(Bird, self).__init__(dim)
self.bounds = lzip([-2 * pi] * self.dim, [2 * pi] * self.dim)
self.min_loc = [4.701055751981055, 3.152946019601391]
self.fmin = -64.60664462282
self.fmax = 160.63195224589
self.classifiers = ['multi_min']
def __init__(self, dim=2):
assert dim == 2
super(Bohachevsky, self).__init__(dim)
self.bounds = lzip([-15] * self.dim, [8] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 0
self.fmax = 675.6
self.classifiers = ['oscillatory']
def __init__(self, dim=3):
assert dim == 3
super(BoxBetts, self).__init__(dim)
self.bounds = ([0.9, 1.2], [9, 11.2], [0.9, 1.2])
self.min_loc = [1, 10, 1]
self.fmin = 0
self.fmax = 0.28964792415
self.classifiers = ['boring']
def __init__(self, dim=2):
assert dim == 2
super(Branin01, self).__init__(dim)
self.bounds = [[-5, 10], [0, 15]]
self.min_loc = [-pi, 12.275]
self.fmin = 0.39788735772973816
self.fmax = 308.129096012
self.classifiers = ['multi_min']
def __init__(self, dim=2):
assert dim == 2
super(Branin02, self).__init__(dim)
self.bounds = [(-5, 15), (-5, 15)]
self.min_loc = [-3.2, 12.53]
self.fmin = 5.559037
self.fmax = 506.983390872
def __init__(self, dim=2):
assert dim > 1
super(Brown, self).__init__(dim)
self.bounds = lzip([-1] * self.dim, [2] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 0
self.fmax = self.do_evaluate(numpy.array([2] * self.dim))
self.classifiers = ['unimodal', 'unscaled']
def __init__(self, dim=2):
assert dim == 2
super(Bukin06, self).__init__(dim)
self.bounds = [(-15, -5), (-3, 3)]
self.min_loc = [-10, 1]
self.fmin = 0
self.fmax = 229.178784748
self.classifiers = ['nonsmooth']
def __init__(self, dim=2):
assert dim == 2
super(CarromTable, self).__init__(dim)
self.bounds = lzip([-10] * self.dim, [10] * self.dim)
self.min_loc = [9.646157266348881, 9.646134286497169]
self.fmin = -24.15681551650653
self.fmax = 0
self.classifiers = ['boring', 'multi_min', 'nonsmooth', 'complicated']
def __init__(self, dim=2):
assert dim == 2
super(Chichinadze, self).__init__(dim)
self.bounds = lzip([-30] * self.dim, [30] * self.dim)
self.min_loc = [6.189866586965680, 0.5]
self.fmin = -42.94438701899098
self.fmax = 1261
self.classifiers = ['oscillatory']
def __init__(self, dim=2):
assert dim > 1
super(Cigar, self).__init__(dim)
self.bounds = lzip([-1] * self.dim, [1] * self.dim)
self.min_loc = [0] * self.dim
self.fmin = 0
self.fmax = 1 + 1e6 * self.dim
self.classifiers = ['unimodal', 'unscaled']
def __init__(self, dim=4):
assert dim == 4
super(Corana, self).__init__(dim)
self.bounds = lzip([-5] * self.dim, [5] * self.dim)
self.min_loc = [0] * self.dim
self.fglob = 0
self.fmin = 0
self.fmax = 24999.3261012
self.classifiers = ['boring', 'unscaled', 'nonsmooth']
def __init__(self, dim=2):
super(CosineMixture, self).__init__(dim)
self.bounds = lzip([-1] * self.dim, [1] * self.dim)
self.min_loc = [0.184872823182918] * self.dim
self.fmin = -0.063012202176250 * self.dim
self.fmax = 0.9 * self.dim
self.classifiers = ['oscillatory', 'multi_min']
def __init__(self, dim=2):
assert dim == 2
super(CrossInTray, self).__init__(dim)
self.bounds = lzip([-10] * self.dim, [10] * self.dim)
self.min_loc = [1.349406685353340, 1.349406608602084]
self.fmin = -2.062611870822739
self.fmax = -0.25801263059
self.classifiers = ['oscillatory', 'multi_min', 'nonsmooth', 'complicated']