Obtain partial or intermediate (output) results from genetic algorithm

2 ビュー (過去 30 日間)
Tessa Kol
Tessa Kol 2021 年 4 月 29 日
コメント済み: Tessa Kol 2021 年 4 月 29 日
Dear all,
I defined a very long function to be optimized by the genetic algorithm. How do I obtain the output of
(predict(Model{1,3},x)-min(Y1))/(Y1_target-min(Y1)) and predict(Model{1,3},x)
when a optimal solution is found?
I gather that you have to access the intermediate results of the genetic algorithm in some way, but I am not sure if that is the right approach and how one should accomplish this when it is the right approach.
%% Loading the Data
load([pwd,'\taguchi_sample_irregular.mat'])
%% Parameters
% Predictors
X = taguchi_multi_variate_samples;
Y = [Payload(:) Work(:) Overflow(:)];
% Response 1 (i.e. payload objective)
Y1 = Payload;
% Response 2 (i.e. work objective)
Y2 = Work;
% Response 3 (i.e. spillage objective)
Y3 = Overflow;
%% Surogate modeling of the data set
% SVM regression model with polynominal kernel functions
Model{1,3} = fitrsvm(X,Y1,'KernelFunction','polynomial', 'KernelScale','auto');
Model{2,3} = fitrsvm(X,Y2,'KernelFunction','polynomial', 'KernelScale','auto');
Model{3,3} = fitrsvm(X,Y3,'KernelFunction','polynomial', 'KernelScale','auto');
%% Optimization
% Target values for each response/objective
Y1_target = max(Y1);
Y2_target = max(Y2);
Y3_target = max(Y3);
fun = @(x) [-((((0.*(predict(Model{1,3},x) < min(Y1))) + ...
((predict(Model{1,3},x)-min(Y1))/(Y1_target-min(Y1))).*(min(Y1) < predict(Model{1,3},x) & predict(Model{1,3},x) < Y1_target) + ...
(1.*(predict(Model{1,3},x) > Y1_target))) .* ...
((0.*(predict(Model{2,3},x) < min(Y2))) + ...
((predict(Model{2,3},x)-min(Y2))/(Y2_target-min(Y2))).*(min(Y2) < predict(Model{2,3},x) & predict(Model{2,3},x) < Y2_target) + ...
(1.*(predict(Model{2,3},x) > Y2_target))) .* ...
((0.*(predict(Model{3,3},x) < min(Y3))) + ...
((predict(Model{3,3},x)-min(Y3))/(Y3_target-min(Y3))).*(min(Y3) < predict(Model{3,3},x) & predict(Model{3,3},x) < Y3_target) + ...
(1.*(predict(Model{3,3},x) > Y3_target))))^(1/3))];
[x, fval, exitflag,output] = ga(fun,4,[],[],[],[],[0 0 0 0], [200 200 200 200]);
  2 件のコメント
Alan Weiss
Alan Weiss 2021 年 4 月 29 日
Sorry, I don't quite understand your question. After you get the result x what happens when you try to run
predict(Model{1,3},x)
This was one of your questions, and I am sure that you have tried this, but what happens?
Alan Weiss
MATLAB mathematical toolbox documentation
Tessa Kol
Tessa Kol 2021 年 4 月 29 日
Thank you for your reply. Lucky for me I already solved the problem. I indeed try to run:
predict(Model{1,3},x)
I get the predicted output of first objective corresponding to the optimal set. In total I combined three objectives into one function. "x" (small x) is the optimal set that is predicted by the genetic algorithm. If you are interested in more information about what I implemented in matlab, here is a useful link: https://www.itl.nist.gov/div898/handbook/pri/section5/pri5522.htm
It is called the desirability approach and the function I defined corresponds the formula for the overall desirability.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by