Using gpCAM as Software

gpCAM can be used without the explicit use of the API. In that case the main task for the user is to adjust the configuration file to the needs of the experiment or simulation. A configuration file with explanations is shown on this page. The explanation will be highlighted like this.

To open the configuration file go to ./scripts/

and open with your favorite editor, we use vim in our example.


After adapting the configuration file, you can run


to start the code. The script will execute the in the same folder which calls the AutonomousExperimenter class

To run a visualization from a gpCAM dataset, use the AutonomousExperimenter class for initialization and the methods in gp_optimizer to get function values. These can be inserted in any visualization software (matplotlib, plotly, paraview, ...)

import numpy as np

import dask.distributed

The parameters define the parameter space that will be navigated during the experiment.

Each dimension needs a name and an interval.

parameters = np.array([[-5,5],[-10,10]])

Next, we can import several user-defined functions that will be used by gpCAM

The only non-optional one is the data_acquisition_function because it tells gpCAM where to send the suggestions

But not to worry, several default data acquisition functions are provided in ./scripts/data_acquisition_functions

All the function imported here are illustrated in ./scripts

from instrument_function import synthetic_function tells gpCAM where to send suggestions and where it gets the data

from acquisition_function import exploration, upper_confidence_bounds important for steering gpCAM to interesting regions

from mean_function import example_mean can inform the prior where it should be, a powerful way to communicate domain knowledge

from cost_function import l1_cost a cost function can be used when moving through the parameter space should be minimized

from cost_function import update_l1_cost_function the user can define how the cost function can be updated and learned

from kernel_function import kernel_l2_single_task the kernel is an important tool to make gpCAM domain aware

from run_every_iteration import write_vtk_file this a function that will be called every iteration of the autonomous loop, it can do virtually anything

Now, we will define the Gaussian processes as a dictionary. Here we are only using 1 GP, for several just repeat the entry with different settings.

For more details, see the documentation (link at the top)

gp ={

"kernel function": None,

#"kernel function": kernel_l2_multi_task, #another option

"hyperparameters": [1.0,1.0,1.0],

"hyperparameter bounds": [[1.0,100.0],[0.10,100.0],[0.10,100.0]],

"number of returns": 1,

"dimensionality of return": 1,

"acquisition function optimization tolerance": 0.001,

"adjust optimization threshold": [True,0.1],

"run function in every iteration": None,

"data acquisition function": synthetic_function,

"acquisition function": "shannon_ig",

"mean function": None,

"cost function": None,

"cost update function": None,

"cost function parameters": {"offset": 10,"slope":[2.0,2.0]},

"plot function": plot_function


The autonomous data acquisition will stop when the uncertainty (standard deviation) falls under the specified level.

append_data = True #will new data be appended and then sent to the instrument (False) or will only the new data be sent (True)

breaking_error = 1e-12

automatic_signal_variance_range_determination = True

Here we provide the algorithm with some simple parameters regarding the training and the suggestion process

acquisition_function_optimization_method = "global"

acquisition_function_optimization_population_size = 10

acquisition_function_optimization_max_iter = 20

number_of_suggested_measurements = 1

initial_likelihood_optimization_method = "global"

global_likelihood_optimization_at = [10,20,30,40]

local_likelihood_optimization_at = [15,35,1000]

hgdl_likelihood_optimization_at = [17,32]

likelihood_optimization_population_size = 20

likelihood_optimization_tolerance = 0.001

likelihood_optimization_max_iter = 120

Now some computing-related values

compute_device = "cpu"

sparse = False

training_dask_client = None #dask.distributed.Client() #None/False/client

prediction_dask_client = None #None/False/client

And how many points we want to place randomly as initialization and when to stop

initial_dataset_size = 20

max_number_of_measurements = 100