def gauss_wave(): """ Essentially, this is a high-frequency sinusoidal function plus a broad quadratic. One variable controls the position along the curve. The binary variable determines whether the sinusoidal is shifted by pi. So there are actually two maxima in this problem, it's just one is more probable. The tricky thing here is dealing with the fact that there are two variables and one is discrete. """ x = hp.uniform("x", -20, 20) t = hp.choice("curve", [x, x + np.pi]) f1 = scope.sin(t) f2 = 2 * scope.exp(-((old_div(t, 5.0)) ** 2)) return {"loss": -(f1 + f2), "status": base.STATUS_OK}
def gauss_wave(): """ Essentially, this is a high-frequency sinusoidal function plus a broad quadratic. One variable controls the position along the curve. The binary variable determines whether the sinusoidal is shifted by pi. So there are actually two maxima in this problem, it's just one is more probable. The tricky thing here is dealing with the fact that there are two variables and one is discrete. """ x = hp.uniform('x', -20, 20) t = hp.choice('curve', [x, x + np.pi]) f1 = scope.sin(t) f2 = 2 * scope.exp(-(old_div(t, 5.0)) ** 2) return {'loss': - (f1 + f2), 'status': base.STATUS_OK}
def gauss_wave2(): """ Variant of the GaussWave problem in which noise is added to the score function, and there is an option to either have no sinusoidal variation, or a negative cosine with variable amplitude. Immediate local max is to sample x from spec and turn off the neg cos. Better solution is to move x a bit to the side, turn on the neg cos and turn up the amp to 1. """ rng = np.random.RandomState(123) var = .1 x = hp.uniform('x', -20, 20) amp = hp.uniform('amp', 0, 1) t = (scope.normal(0, var, rng=rng) + 2 * scope.exp(-(old_div(x, 5.0)) ** 2)) return {'loss': - hp.choice('hf', [t, t + scope.sin(x) * amp]), 'loss_variance': var, 'status': base.STATUS_OK}
def gauss_wave2(): """ Variant of the GaussWave problem in which noise is added to the score function, and there is an option to either have no sinusoidal variation, or a negative cosine with variable amplitude. Immediate local max is to sample x from spec and turn off the neg cos. Better solution is to move x a bit to the side, turn on the neg cos and turn up the amp to 1. """ rng = np.random.default_rng(123) var = 0.1 x = hp.uniform("x", -20, 20) amp = hp.uniform("amp", 0, 1) t = scope.normal(0, var, rng=rng) + 2 * scope.exp(-((old_div(x, 5.0))**2)) return { "loss": -hp.choice("hf", [t, t + scope.sin(x) * amp]), "loss_variance": var, "status": base.STATUS_OK, }