Interpolate Matlab inbuilt function with Julia

4 次查看(过去 30 天)
Hi, I have a problem when I try to interpolate Matlab inbuilt function bayesopt with Julia function, in my program, I try to use julia to evaluate my objective function, since it's fast, but I also want to use matlab bayesopt to optimize it, since julia's package is not that complete, it's almost work, but has a problem with variable type, here is an simple example, and the error as follows,
using MATLAB
function f(x, y)
return -x - y
end
function mdlfun(tbl)
x = tbl.v1
y = tbl.v2
return f(x, y)
end
mat"""
xrange = optimizableVariable('v1',[-2,2],'Type','real');
yrange = optimizableVariable('v2',[-5,5],'Type','real');
var=[xrange yrange];
bayesObject =bayesopt(@(tbl)$mdlfun(tbl),var,...
'MaxObjectiveEvaluations',50)
"""
Unable to use a value of type table as an index.
Error in @(tbl)matlab_jl_2(tbl)
Error in BayesianOptimization/callObjNormally (line 2576)
Objective = this.ObjectiveFcn(conditionalizeX(this, X));
Error in BayesianOptimization/callObjFcn (line 481)
= callObjNormally(this, X);
Error in BayesianOptimization/runSerial (line 1996)
ObjectiveFcnObjectiveEvaluationTime, ObjectiveNargout] = callObjFcn(this, this.XNext);
Error in BayesianOptimization/run (line 1948)
this = runSerial(this);
Error in BayesianOptimization (line 457)
this = run(this);
Error in bayesopt (line 323)
Results = BayesianOptimization(Options);
  2 个评论
xu supeng
xu supeng 2022-2-21
Maybe I am wrong, since evry code within
mat"""..."""
will be run in Matlab that's not what I hope, but any suggestions are welcome
xu supeng
xu supeng 2022-2-21
To be clear, I write this within julia and call bayesopt from julia, that's why I define functions in different ways

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Model Building and Assessment 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by