error surrogateopt: At least objective or constraints function must be non-empty
1 view (last 30 days)
Show older comments
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 Comments
Matt J
on 20 Jun 2023
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);
Answers (0)
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!