Clear Filters
Clear Filters

External Variables in bayesopt Objective Function

1 view (last 30 days)
Hello,
I am making use of bayesopt within Matlab. According to the documentation, the objective function must have the following signature:
result = objectiveFunction(X)
where X is a struct/table giving the values of the optimisation variables to be used to analyse the objective function at this particular iteration.
My issue is that the objective function I wish to use depends on some external variables as well as X. To be clear, these external variables will never change throughout a single Bayesian optimisation, and so they are not themselves optimisation variables. In theory they could be hard coded in to the objective function itself, but this would not be very efficient to run multiple experiments.
As an example: one external variable I need is 'model_file'. This is set before the bayesopt starts and defines a model which is loaded & used to perform some dynamic calculations within the objective function. Typically every time we run a new experiment either the model_file or other external variables are changed.
Currently I am considering solutions whereby the external variables are defined globally in the script which runs bayesopt, but I was wondering if there is a nicer solution to this? Ideally I would have something like:
result = objectiveFunction(X, external_variables)
But it seems like this is not possible?

Accepted Answer

Walter Roberson
Walter Roberson on 25 Jan 2019

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!