Search code examples
matlabbayesianhyperparameters

Coupled variables in hyperparameter optimization in MATLAB


I would like to find optimal hyperparamters for a specific function, I am using bayesopt routine in MATLAB.

I can set the variables to optimize like the following:

a = optimizableVariable('a',[0,1],'Type','integer');

But I have coupled variables, i.e, variables whose value depend on the existence of other variables, e.g., a={0,1}, b={0,1} iff a=1. Meaning that b has an influence on the function if a==1.

I thought about creating a unique variables that encompasses all the possibilities, i.e., c=1 if a=0, c=2 if a=1,b=0, c=3 if a=1,b=0. The problem is that I am interested in optimizing continuous variables and the above approach does not hold anymore.

I tried something alone the line of

b = a * optimizableVariable('b',[0,1],'Type','integer');

But MATLAB threw an error.

Undefined operator '*' for input arguments of type 'optimizableVariable'.

Solution

  • After three months almost to the day, buried deep down in MATLAB documentation, the answer was to use constrained variables.

    https://www.mathworks.com/help/stats/constraints-in-bayesian-optimization.html#bvaw2ar