error surrogateopt: At least objective or constraints function must be non-empty
이전 댓글 표시
For my integer global optimization problem I'm using surrogateopt. The code was working before but something changed and it gives me an error now that I haven't been able to solve. I'm using matlab2023a. The errors are as follows:
Error using globaloptim.bmo.BlackboxModelOptimizer/optimize
At least objective or constraints function must be non-empty.
Error in surrogateopt (line 375)
controller = controller.optimize();
Error in Grid_calculation2_new (line 205)
optimdesign = surrogateopt(@(x) Surrogate_optimization_target(wl, ...
For my problem I have no constraints except the upper and lower bounds. The objective is specified in surrogateopt() as has also been done in this example: https://nl.mathworks.com/help/gads/surrogate-optimization-antenna-design.html
Here is part the part of the code that I expect to be relevant for this error. I hope someone can help me solve this error.
values_repeats_LB = zeros(1,size(structure_variaties,2));
values_repeats_UB = zeros(1,size(structure_variaties,2));
for i=1:size(structure_variaties,2)
values_repeats_LB(i) = structure_variaties{2,i}(1);
values_repeats_UB(i) = structure_variaties{2,i}(end);
end
%Lower and upper bounds values follow same order as variable materials
materials = [silica, TiO2, YAG]; %[silica, TiO2, YAG];
Lower_bounds = [60 40 100]; %Set the lower bounds here in nanometer
Upper_bounds = [120 120 300]; %Set the upper bounds here in nanometer
multiply_factor = 5; %E.g. vary the thickness per 5nm when choosing 5.
LB = [Lower_bounds/multiply_factor values_repeats_LB];
UB = [Upper_bounds/multiply_factor values_repeats_UB];
intcon = 1:size(LB,2);
plots_or_not = 0; %No plots
em_or_ex = 0; %Excitation (0) not emission (1)
%target_options = ["avg field ex" "avg abs ex" "avg field em" ...
% "tot em field" "plus PL" ...
% "plus transmission" "CRI" "factor"]; %options for for output_choice
target_choice = ["tot em field"]; %what you want as output.
surrogateoptions = optimoptions('surrogateopt', ...
'MaxFunctionEvaluations',500, ...
'UseParallel',false, ...
'PlotFcn','surrogateoptplot');
rng(4) % Fix randomness for reproducibility
optimdesign = surrogateopt(@(x) Surrogate_optimization_target(wl, ...
op_wl_ex, op_wl_em, theta, data_file, angle, z_step_size, ...
plots_or_not, em_or_ex, target_choice, ...
multiply_factor, basis_model, structure_variaties, materials, x), ...
LB, UB, intcon, surrogateoptions);
best_parameters = optimdesign;
best_parameters(1:3) = best_parameters(1:3)*multiply_factor;
댓글 수: 2
Matt J
2023년 6월 20일
Here is part the part of the code that I expect to be relevant for this error
No, I don't think so. We need to see the code for Surrogate_optimization_target and we need a .mat file (just one) containing all the variables in this line,
optimdesign = surrogateopt(@(x) Surrogate_optimization_target(wl, ...
op_wl_ex, op_wl_em, theta, data_file, angle, z_step_size, ...
plots_or_not, em_or_ex, target_choice, ...
multiply_factor, basis_model, structure_variaties, materials, x), ...
LB, UB, intcon, surrogateoptions);
René Bruikman
2023년 6월 21일
편집: René Bruikman
2023년 6월 21일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!