Noisy Inputs

In Olympus we allow to add noise to the measurements. However, also noise in the input parameters may be added by the user. Here we show how one can artificially inject noise into the input parameters proposed by the experiment planning algorihms.

[1]:
# import olympus
from olympus import Planner, Surface, Campaign
import numpy as np
[2]:
planner = Planner('Hyperopt')
surface = Surface(kind='Dejong', param_dim=2)
[3]:
max_iter = 5

# instantiate a Campaign object, which stores the results of the optimization
campaign = Campaign()

# tell the planner what is the optimization domain
planner.set_param_space(surface.param_space)

for i in range(max_iter):
    print(f"Iter {i+1}\n------")

    # ask the planner for a new set of parameters
    params = planner.recommend(observations=campaign.observations)
    print('Noiseless Parameters:', params.to_array())

    # -----------------------------------------
    # Here we add noise to the input parameters
    # -----------------------------------------
    noisy_params = params.to_array() + np.random.normal(loc=0, scale=0.2, size=2)
    print('Noisy Parameters:', noisy_params)

    # evaluate the merit of the new parameters
    values = surface.run(noisy_params, return_paramvector=True)
    print('Values:', values[0].to_array())

    # store parameter and measurement pair in campaign
    campaign.add_observation(params, values)

    print()
Iter 1
------
Noiseless Parameters: [0.91516692 0.20302945]
Noisy Parameters: [ 0.73368038 -0.15661178]
Values: [4.09110448]

Iter 2
------
Noiseless Parameters: [0.57761863 0.07672387]
Noisy Parameters: [0.61797856 0.10844515]
Values: [3.06495384]

Iter 3
------
Noiseless Parameters: [0.59093962 0.16875164]
Noisy Parameters: [0.3161343  0.13549561]
Values: [3.26517068]

Iter 4
------
Noiseless Parameters: [0.20300339 0.97610323]
Noisy Parameters: [0.44173351 1.19968439]
Values: [3.40847969]

Iter 5
------
Noiseless Parameters: [0.41894133 0.59690823]
Noisy Parameters: [0.2575433  0.40528083]
Values: [2.53033984]