Not enough input arguments for multivariable function when using bayesopt.

I want bayesopt to minimize two variables in a particular function. This piece of code works with one function (just var,) but the second I try to add var1 and its corresponding y input into the function all I get is "not enough input arguments." The error sites the "fun = ..." line as the one with the error.
Here is my code and its corresponding error:
var = optimizableVariable('theta',[1,10],'Type','real');
var1 = optimizableVariable('alpha',[1,10],'Type','real');
fun = @(x,y)objfunxx(x.theta, y.alpha); %Create Function Handles
results = bayesopt(fun,[var,var1]);
Not enough input arguments.

Error in solution>@(x,y)objfunxx(x.theta,y.alpha) (line 4)
fun = @(x,y)objfunxx(x.theta, y.alpha); %Create Function Handles

Error in BayesianOptimization/callObjNormally (line 13)
Objective = this.ObjectiveFcn(conditionalizeX(this, X));

Error in BayesianOptimization/callObjFcn (line 25)
= callObjNormally(this, X);

Error in BayesianOptimization/runSerial (line 24)
ObjectiveFcnObjectiveEvaluationTime, ObjectiveNargout] = callObjFcn(this, this.XNext);

Error in BayesianOptimization/run (line 9)
this = runSerial(this);

Error in BayesianOptimization (line 184)
this = run(this);

Error in bayesopt (line 323)
Results = BayesianOptimization(Options);
function f = objfunxx(x,y)
f=y*sin(x);
end

Answers (1)

fun accepts x, a 1-by-D table of variable values, and returns objective, a real scalar representing the objective function value fun(x).
You on the other hand are expecting the function to be passed two objects

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Products

Release

R2023a

Asked:

on 13 Sep 2023

Answered:

on 13 Sep 2023

Community Treasure Hunt

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

Start Hunting!