Interface Optimization
Here we show using how the interfaces to other navigators can be used in a similar manner to the included BOTorch navigators.
Specifically, we illustrate using the BayBE interface
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 torch
import matplotlib.pyplot as plt
from warnings import catch_warnings
from warnings import simplefilter
from odyssey.mission import Mission # Mission
from odyssey.objective import Objective # Objective
from odyssey.navigators.baybe_navigator import BaybeNavigator
def real_func(x: torch.Tensor, noise_level = 0):
noise = (-1 + torch.rand(x.size()) * 2) * noise_level
return -(torch.sin(x) + torch.sin((10.0 / 3.0) * x)) + noise
noise_level = 0.0
objective = Objective(real_func, noise_level = noise_level)
param_space = [(0.0, 10.0)]
goals = ['ascend']
mission = Mission(
name = 'siso_test',
funcs = [objective],
maneuvers = goals,
envelope = param_space
)
num_init_design = 0
param_types = ["numerical"]
navigator = BaybeNavigator(mission=mission, param_types=param_types)
num_iter = 15
while len(mission.display_X) - num_init_design < num_iter:
with catch_warnings() as w:
simplefilter('ignore')
trajectory = navigator.trajectory()
observation = navigator.probe(trajectory, init = False)
print(len(mission.display_X) - num_init_design, trajectory, observation)
navigator.relay(trajectory, observation)
navigator.upgrade()
best_idx = mission.display_Y.argmax().item()
best_input = mission.display_X[best_idx].item()
best_output = mission.display_Y[best_idx].item()
print(f'Best Input: {best_input}')
print(f'Best Output: {best_output}')
|