GA Ignores Initial Population and Initial Scores

2 views (last 30 days)
I am trying to optimize a function which accepts over 1300 parameters, (all integers between 1 and 13). The output is a score which varies between 0 and 100 (floating number), lets call this function as follow:
Score=F([x1,x2,...,x1303]);
I want to maximize this function so I defined a function like this:
OptFun=@(x) (100-F(x));
Now I use GA to minimize this function:
[x,fval,exitflag,output,population,scores] = ga(OptFun,nParam,[],[],[],[],ones(nParam,1),13*ones(nParam,1),[],1:nParam,GAOptions);
nParam=1303 and GAOptions is set like this:
GAOptions = gaoptimset(@ga);
GAOptions.Generations=500;
GAOptions.PopulationSize=24;
GAOptions.UseParallel=true;
GAOptions.Display='iter';
Well, let's not talk about if the Population size is small or number of generations are too low.
The question is that I am expecting that each set of parameters to be evaluated once. But I noticed that each function is revaluated couple of times. For example if x1=x2=...=x1303=13 is re-evaluted couple of times. How do I know this? I added few lines of code to F() which at the end it prints to a text file, what score was evaluted and what was the input parameters. So each time that GA gives a call to OptFun() which subsequently gives a call to F() I would know exactly what is evaluated and what was the score.
I have to mention that each evaluatin of F() could vary between 10min to 1.5hr, (depending on the machine, there is system call to a another application that I only have the binary of it).
I appreciate it if anyone can shed some light on this
  2 Comments
Geoff Hayes
Geoff Hayes on 14 Mar 2015
Mohammad - perhaps I've misunderstood your question, but why can't a member (of the population) with the same set of parameters be evaluated more than once? Why wouldn't the algorithm re-evaluate each member of the population on subsequent generations/iterations to determine their score which may have changed due to the effects of crossover or mutation from the previous generation?
Otherwise the algo would need to flag - at the end of each iteration - those members of the population that are either "new" because of crossover and/or mutation. Thus those that have been flagged in this manner would be evaluated (for their score) on the next iteration, whereas those that aren't flagged would be ignored.
The "flagging" would be nice especially in those cases (like yours) where the evaluation of the objective/fitness function varies from 10 to 90 minutes.
Mohammad Abouali
Mohammad Abouali on 16 Mar 2015
The only reason that I am concerned about re-evaluating the function is exactly the cost of the function call. If a member has been already evaluated, I thought the algorithm would know that and avoids re-evaluating it. This could be also a sign of looping. Although the consequences would not be as serious as in other methods, (since there is a randomness involved). In my case as you mentioned, the function re-evaluation could cost me quite some time.
By the way, I noticed that the InitialScores is ignored when the GA involves integer parameters. (this is mentioned in the documentation though)

Sign in to comment.

Accepted Answer

Alan Weiss
Alan Weiss on 16 Mar 2015
There is not much reason to think that ga can help with this function. Generally, integer ga handles up to about 100 variables. And you already know that your population is absurdly low for this problem. So I am not sure why you are doing this
But to answer your question, you probably should write your objective function to maintain a list of points already visited, and the first thing it does is see if the current point is in that list, and if so return the previously-computed objective function value. If not, then after evaluating the objective function, add the point and value to the list. Maybe use a persistent variable to store the list.
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!