File size: 954 Bytes
165ee00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import torch
import numpy as np

#
#
#   GKXWC2: 2D objective, 1 constraints
#
#   Reference:
#       Gardner JR, Kusner MJ, Xu ZE, et al (2014)
#       Bayesian optimization with inequality con-
#       straints. In: ICML, pp 937–945
#
#

def GKXWC2(individuals): 

    assert torch.is_tensor(individuals) and individuals.size(1) == 2, "Input must be an n-by-2 PyTorch tensor."
    
    fx = []
    gx = []
    
    for x in individuals:
        
        g = np.sin(x[0])*np.sin(x[1]) + 0.95
        fx.append( - np.sin(x[0]) - x[1]  ) # maximize -(x1^2 +x 2^2)
        gx.append( g )
        
    fx = torch.tensor(fx)
    fx = torch.reshape(fx, (len(fx),1))
    gx = torch.tensor(gx)
    gx = torch.reshape(gx, (len(gx),1))
    
    return gx, fx


def GKXWC2_Scaling(X):

    assert torch.is_tensor(X) and X.size(1) == 2, "Input must be an n-by-2 PyTorch tensor."
    
    X_scaled = X*6;
    return X_scaled