필터 지우기
필터 지우기

Genetic Algorithm fitness function for failing parameters

조회 수: 2 (최근 30일)
Ben Holmes
Ben Holmes 2016년 1월 22일
댓글: jgg 2016년 1월 22일
I'm attempting to analyse a strongly nonlinear system using GA. The fitness function evaluates a time-domain comparison between the modelled (estimated) and measured data, and sums the squared error across the duration of the signal. The model that runs uses an optimised/robust variation of Newton's method to solve the nonlinear behaviour, but some of the parameter settings can cause non-convergence, resulting in an Inf value being returned by the fitness function.
Ideally I would like to be able to discard this set of parameters and generate a new set (possibly repeatedly) that yields a working model, but I don't know how to change the population from the fitness function. The parameter set is not necessarily a bad set, just the combination of parameters yields a non-functioning model, and when this happens the parameters are seen as unfit, which is not necessarily true. The parameters are all bound to realistic regions.

채택된 답변

jgg
jgg 2016년 1월 22일
I think you probably want an output function.
Basically, you can create a function which is called after every iteration of the solver, and can do things to the population. Create a function like:
function [state,options,optchanged] = ga_output_function(options,state,flag)
if strcmp(flag,'iter') %if ga is in iteration
p = state.Population;
s = state.Score;
%test and change things
else
%something else
end
end
The state object is explained in the link, but it's basically a structure with all the components of the GA optimizer at the current iteration. So, in your problem you could have it check if you've reached one of those bad parameter values then change the population so that it's excluded (however you choose to do this), passing back the new state with the new population.
Then, create an option structure like:
options = gaoptimset('OutputFcns',@ga_output_function);
and pass it to your GA solver.
You'll have to play around with this a little bit to get it to work in your situation, but I think this solves your basic problem ("I want to change the population of the GA solver when something happens").
  댓글 수: 2
Ben Holmes
Ben Holmes 2016년 1월 22일
I think you're right! Do you know the order in which this is all called? Hopefully something like:
Evaluate Current Generation -> Output Function -> Generate Next Generation
jgg
jgg 2016년 1월 22일
I'm pretty sure that's how it works. You can confirm this by doing some testing though (get it to save the population at each stage before changing it); I'm not 100% sure.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by