Something strange with the next population generation in GA.

1 Ansicht (letzte 30 Tage)
Matthieu
Matthieu am 8 Okt. 2014
Bearbeitet: Matthieu am 8 Okt. 2014
Hi everyone,
I'm trying to solve an optimization problem using the genetic algorithm ga.
Long story short:
  • my optimization is constrained with linear unequalities,
  • the elements of the solution vector must be binary,
  • I need to design my own creation, crossover and mutation functions.
According to the documentation, I can't set IntConSet in GA input arguments (otherwise, custom functions aren't allowed) So I designed my own custom creation, mutation and crossover functions and made sure that they behave correctly.
For simplicity and in the following, I'll denote (A): "the individual verifies the linear constraints and has binary elements.
I manually checked that the individuals in the initial population returned by my custom creation function verify (A). They do. I manually checked that when both my custom mutation and crossover functions receive parents verifying (A), they return children verifying (A) as well. They do.
So basically, on paper, the second (and all the following) generation(s) of individuals generated by the GA, should verify (A), if the previous generation verified (A). The initial population does, so everything should iterate correctly.
But it's not happening.
The thing is, starting at generation 2, one individual, always the same, the first one in the list (namely thisPopulation(1,:)), behaves weirdly. This individual does not verify the linear constraints and its elements are not binary anymore, instead, they have non-integer values between 0 and 1. Please note that all the other individuals (thisPopulation(2:end,:)) still do verify (A). Only this first individual is messed up, for some reason.
I think I'm missing something here on how the next population generation function works. But I can't figure out what.
Any ideas ?
Thank you for your time and have a nice day,
Matt
PS : I can't provide any piece of code, as my company has strong intellectual properties rules. That's why I tried to be as specific as possible on the problem I'm facing.
  1 Kommentar
Matthieu
Matthieu am 8 Okt. 2014
Bearbeitet: Matthieu am 8 Okt. 2014
I can provide the options used for GA, if it helps.
options = gaoptimset('PopulationType', 'doubleVector',...
'PopInitRange',[0;1],...
'PopulationSize', 20,...
'EliteCount', 2,...
'CrossoverFraction', 0.8,...
'ParetoFraction', [],...
'MigrationDirection', [],...
'MigrationInterval', [],...
'MigrationFraction', [],...
'Generations', 100,...
'TimeLimit', Inf,...
'FitnessLimit', -Inf,...
'StallGenLimit', 10,...
'StallTimeLimit', Inf,...
'TolFun', 1.0000e-06,...
'TolCon', 1.0000e-06,...
'InitialPopulation', [],...
'InitialScores', [],...
'InitialPenalty', 10,...
'PenaltyFactor', 100,...
'PlotInterval', 1,...
'FitnessScalingFcn', @fitscalingrank,...
'DistanceMeasureFcn', [],...
'HybridFcn', [],...
'Display', 'diagnose',...
'PlotFcns', [],...
'OutputFcns', [],...
'Vectorized', 'off',...
'UseParallel', 'never',...
'CreationFcn', @GA.pop_creation_best_rnd,...
'SelectionFcn', @selectionstochunif,...
'CrossoverFcn', @GA.pop_crossover_fcn,...
'MutationFcn', @GA.pop_mutation_fcn);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Alan Weiss
Alan Weiss am 8 Okt. 2014
Since you cannot provide code, there is no way for us to check what might be happening. All I can suggest is that you put break points in the code and check for yourself. For example, if you execute
edit ga
and scroll to the bottom, you will see the main subroutines. Select the one your problem will run, such as gaunc and press control-D. This opens the gaunc function, and you can put in break points to see what is happening as ga runs.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  1 Kommentar
Matthieu
Matthieu am 8 Okt. 2014
Bearbeitet: Matthieu am 8 Okt. 2014
Nevermind, I made a mistake. Everything's working fine now. Thank you for your time.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by