-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinfill.py~
More file actions
52 lines (35 loc) · 1.2 KB
/
infill.py~
File metadata and controls
52 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import numpy as np
from .multi_objective import uhvi
class Infill:
def __init__(self,name):
self.name = name
class UHVI(Infill):
def __init__(self, beta = None, D = None, delta = None):
self.D = D
self.delta = delta
self.t = 1
super().__init__('uhvi')
#if beta is not specified use the beta schedule
if beta == None:
self.use_schedule = True
assert not self.D == None
assert not self.delta == None
else:
self.use_schedule = False
self.beta = beta
def __call__(self, X, GPRs, PF, A, B):
return uhvi.get_uhvi(X, GPRs, PF, A, B, self.get_beta())
def get_beta(self):
if self.use_schedule:
return 2 * np.log(self.D * self.t**2 * np.pi**2 / (6 * self.delta))
else:
return self.beta
class UCB(Infill):
def __init__(self, beta = 0.1):
self.beta = beta
self.t = 1
super().__init__('ucb')
def __call__(self, X, GPR):
print(X)
p = GPR.predict_y(X)
return p[0].numpy() + np.sqrt(self.beta * p[1].numpy())