How to give function tolerance value, crowding distance function, selection function in custom made function using gaoptimset?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have prepared custom made creation, mution and crossover function. And this code calls them for gamultiobj solver, with options set using gaoptimset as shown in code. I wish to confirm that this is the right way to initialize the tournament selection type, genotype distance crowding, and tolerance value as 0.003 as shown in code, and that the code is actually using these values and not bypassing or ignoring it with any default values. I am new to this, hence asking here.
Also how to initialize intial population solutions, if i have a matrix? Can anyone please tell how to do that in code?
fitnessFunction = @new; % Function handle to the fitness function
numberOfVariables = 80; % Number of decision variables
populationSize = 200; stallGenLimit =550; generations = 20000;
% Bound Constraints
lb = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11]; % Lower bound
ub = [13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13]; % Upper bound
Bound = [lb; ub];
options = gaoptimset('PopulationSize',populationSize,...
'CreationFcn', @int_pop,...
'MutationFcn', @int_mutation,...
'CrossoverFcn',@int_crossoverarithmetic,...
'StallGenLimit', stallGenLimit, 'SelectionFcn',@selectiontournament ...
,'Generations', generations,...
'PopulationSize',populationSize,...
'PopInitRange', Bound, 'PlotFcn',{@gaplotpareto,@gaplotdistance});
options.DistanceMeasureFcn = {@distancecrowding,'phenotype'};
options = gaoptimset(options,'ParetoFraction',0.3);
%options.InitialPopulationMatrix={J};
options.FunctionTolerance= {0.003}; %is this correct way to change function tolerance value?
%options.nonlcon={@mycon}; %Non linear constraint file
[x1, f1, exitflag1, output1, population1, score1] = gamultiobj(fitnessFunction,...
numberOfVariables, [],[], [], [], lb, ub,@consnew,options);
0 comentarios
Respuestas (1)
Ameer Hamza
el 3 de Mayo de 2020
Everything looks fine. However, note that the FunctionTolerance is the difference between the value of two consecutive iterations, not the absolute value of the function. So consider this factor when deciding its value.
To generate the matrix for the initial population, It should have these dimensions PopulationSize*numberOfVariables. So you can create it according to your choice while keeping the same dimensions. For example, a uniformly distributed random matrix
options.InitialPopulationMatrix = rand(populationSize, numberOfVariables)
2 comentarios
Ameer Hamza
el 4 de Mayo de 2020
That problem is related to the implementation of the genetic algorithm. I never had a chance to study it in detail, so I don't have much idea about implementing mutation and crossover functions.
Ver también
Categorías
Más información sobre Genetic Algorithm en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!