Use sfit object for multiobjective optimization
2 views (last 30 days)
Show older comments
Hello everybody,
I want to solve an optimization problem regarding 3 objectives and 2 variables. The data that needs to be optimized may differ dependant on the users input.
My approach was to first generate arrays or vectors that hold the in- and output data. I can now generate 3 surface fit (sfit) objects for every objective that needs to be optimized. The gamultibj algorithm now suggests that I use these functions to create a fitness function, which then will be optimized. However I dont understand how I can create a useable fitness function out of the previously generated sfit objects. To me it seems the gamultiobj algorithm only wirks with a "hard coded" fitness function.
Relevant Code:
% v_n_ges / v_n_P holds all variables
% v_EW / v_T_med and v_K_med holds all objectives
% generate functions to optimize
EW_fit = fit([v_n_ges, v_n_P], v_EW, 'poly22');
T_med_fit = fit([v_n_ges, v_n_P], v_T_med, 'poly22');
K_med_fit = fit([v_n_ges, v_n_P], v_K_med, 'poly22');
% Multiobjective Optimization via fitness function
fitnessfcn = @Fitnessfcn;
numberOfVariables = 3;
[x, fval] = gamultiobj(fitnessfcn, numberOfVariables);
%% Generate fitness function (in progress)
function f = Fitnessfcn (x) % The fitness function would need an input row vector size 2 containing n_ges and n_P
% but also the sfit objects
% Allocate output
f = zeros(1,3);
f(1) = @EW_fit;
f(2) = @T_med_fit;
f(3) = @K_med_fit;
end
Also I was wondering if there is any way to skip the "sfit-step" and just directly work with the vectors/arrays.
Thanks in advance for your support and with best regards
0 Comments
Answers (1)
Nipun
on 31 May 2024
Edited: Nipun
on 31 May 2024
Hi Fabian,
I understand that you want to optimize a multi-objective problem using the gamultiobj algorithm in MATLAB. I assume you want to create a fitness function using the previously generated sfit objects. Based on the given information, you are trying to pass the sfit objects directly to the fitness function, but require an alternate way.
Here is a suggestion for your fitness function:
function f = Fitnessfcn(x)
% Extract variables
n_ges = x(1);
n_P = x(2);
% Evaluate surface fits
EW_val = EW_fit(n_ges, n_P);
T_med_val = T_med_fit(n_ges, n_P);
K_med_val = K_med_fit(n_ges, n_P);
% Assign fitness values
f = [EW_val, T_med_val, K_med_val];
end
This function evaluates the surface fits at the given input values of n_ges and n_P and returns the objective function values.
Regarding your question about skipping the sfit step, yes, you can directly work with vectors/arrays if you have the data available. However, fitting functions like fit() can be useful for interpolating or approximating data if you do not have the exact functional form.
Hope this helps.
Regards,
Nipun
0 Comments
See Also
Categories
Find more on Multiobjective 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!