Using genetic algorithm to minimize standard deviation

조회 수: 4 (최근 30일)
Stephan Freitag
Stephan Freitag 2021년 3월 12일
댓글: Stephan Freitag 2021년 3월 12일
Hello,
I am trying to optimize a function and its standard deviation, when the input variables are changing a little bit (Monte Carlo).
function out = fitnessfcn(Y)
disp('MonteCarlo')
X_MCS = MonteCarlo(Y);
t = @(x) x(1)^X(2)-sin(x(2)); %just an example function
temp = zeros(length(X_MCS),1);
for i=1:length(X_MCS)
temp(i,1) = t(X_MCS(i,:));
end
out = [std(temp), t(Y)];
end
[solution,Fval] = gamultiobj(@fitnessfcn,n,A,b,[],[],lb,ub,@(X)nonlin(X),optsmulti);
So I thought now in every generation the whole population runs through my Monte Carlo simulation. PopulationSize is 50, so I should see 50 times my disp 'Monte Carlo' in the command window before a new generations starts, but it looks like this:
(5x) MonteCarlo
Generation Func-count Pareto distance Pareto spread
1 51 1 1
(2x) MonteCarlo
2 101 0 1
(13x) MonteCarlo
3 151 0 1
How can I achieve that the whole population runs through my fitnessfcn, not just some random parts?

채택된 답변

Matt J
Matt J 2021년 3월 12일
The fitnesfcn will be called only on those population members that satisfy your constraints. That is undoubtedly why you are seeing only a subset of your population processed. But isn't that what you want?
  댓글 수: 1
Stephan Freitag
Stephan Freitag 2021년 3월 12일
I didn't think about this, you are so right, thank you!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multiobjective Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by