Azzera filtri
Azzera filtri

How to give function tolerance value, crowding distance function, selection function in custom made function using gaoptimset?

3 visualizzazioni (ultimi 30 giorni)
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);

Risposte (1)

Ameer Hamza
Ameer Hamza il 3 Mag 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 Commenti
Aryan Agarwal
Aryan Agarwal il 4 Mag 2020
Thanks for the reply! I have one more question related to this, that i had asked separately on MATLAB answers. Can you please have a look at it as well and suggest any solution? Thanks a lot for your help! Link to the other question:
https://in.mathworks.com/matlabcentral/answers/522704-how-to-change-mutation-probability-in-this-custom-mutation-function-of-gamultiobj
Ameer Hamza
Ameer Hamza il 4 Mag 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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by