"Unable to resolve the name"
7 views (last 30 days)
Show older comments
I am trying to code an optimization script to maximize the lift-drag ratio of a turbine blade, as functions of geometrical features on a Bezier curve. I have trained models using data generated from CFD on Regression Learner App, using Gaussian Process Regression, and I tried following this tutorial: https://www.mathworks.com/videos/part-4-problem-based-nonlinear-programming-1549458887351.html
I get the following error related to the models being called:
Unrecognized function or variable 'model_name'
For some reason, I can't get the script to run models (in the form of 1x1 structures) to recognize the models already loaded on the workspace. And this error... I actually don't understand:
Function evaluation failed while attempting to determine output size. The function might contain an error, or might not be well-defined at the automatically-chosen point. To specify output size without function evaluation, use 'OutputSize'.
Here's how my code looks:
Optimization problem:
LDRmax = optimproblem;
Variables
V_inf = optimvar('V_inf','LowerBound',10,'UpperBound',22);
Base_R = optimvar('Base_R ','LowerBound',3,'UpperBound',8);
LA_Ang = optimvar('LA_Ang ','LowerBound',1,'UpperBound',5);
UA_Ang = optimvar('UA_Ang ','LowerBound',1,'UpperBound',5);
UA_Height = optimvar('UA_Height ','LowerBound',0.001,'UpperBound',0.005);
LA_Height = optimvar('LA_Height ','LowerBound',0.001,'UpperBound',0.005);
X1 = optimvar('X1 ','LowerBound',0.09,'UpperBound',0.41);
X2 = optimvar('X2 ','LowerBound',0.09,'UpperBound',0.41);
UA_BA = optimvar('UA_BA ','LowerBound',45,'UpperBound',90);
LA_BA = optimvar('LA_BA ','LowerBound',45,'UpperBound',90);
AoA = optimvar('AoA ','LowerBound',-20,'UpperBound',20);
UA_BL = optimvar('UA_BL ','LowerBound',0.02,'UpperBound',0.1);
LA_BL = optimvar('LA_BL ','LowerBound',0.02,'UpperBound',0.1);
Multi-variate Optimization Expression:
edit ldrobj
% I transfer the objective function to an external function that should
% call and process the models laoded in the workspace. Matlab can't seem to do that
obj = fcn2optimexpr(@ldrobj,Base_R,LA_Ang,UA_Ang,UA_Height,LA_Height,X1,X2,UA_BA,LA_BA,LA_BL,UA_BL)
prob.Objective = obj
LDR = 1/DLR
CM
Supporting functions:
function f = ldrobj(Base_R,LA_Ang,UA_Ang,UA_Height,LA_Height,X1,X2,UA_BA,LA_BA,LA_BL,UA_BL)
x = [Base_R,LA_Ang,UA_Ang,UA_Height,LA_Height,X1,X2,UA_BA,LA_BA,LA_BL,UA_BL];
ALL = ALLGPO.predictFcn(x); % name.predictFcn are the trained models I used for this optimization problem,
AUL = AULGPO.predictFcn(x); % I am calling several of these. The script can't seem to see them
clear x;
x = [V_inf,Base_R,LA_Ang,UA_Ang,LA_Height,X1,X2,UA_BA,LA_BA,AoA,UA_BL,ALL,AUL];
Dyn_Vel = DynVelGPO(x);
clear x;
x = [V_inf,X2,LA_BA,AUL,Dyn_Vel];
y = [V_inf,LA_Ang,UA_Ang,UA_Height,LA_Height,X2,UA_BA,LA_BA,AoA,LA_BL,AUL,ALL,Dyn_Vel];
f = CdGPO(x)/ClGPO(y);
end
Please thank you!
5 Comments
Stephen23
on 28 Aug 2024
The recommended approach is to pass them as input arguments, e.g.:
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!