How to give function tolerance value, crowding distance function, selection function in custom made function using gaoptimset?
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Ameer Hamza
2020년 5월 3일
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
Ameer Hamza
2020년 5월 4일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!