MATLAB: Genetic Algorithm – limiting significant digits of Optimization Variable

genetic algorithmoptimization

Hello All,
What is the correct options setting for limiting the sgnificant digits after the decimal point of the input variables to the fitness function.
Follwoing Example:
function [y] = fitnessfunction(XX)
%% ======================================================================== % Initialize for two objectives y = zeros(2,1);
% Compute first objective for i = 1:6 y(1) = y(1) – 10*exp(-0.2*sqrt(XX(i)^2 + XX(i+1)^2)); end
% Compute second objective for i = 1:6 y(2) = y(2) + abs(XX(i))^0.8 + 5*sin(XX(i)^3); end end
**************************************************** ****************************************************** options = gaoptimset( 'InitialPopulation', initpop, … 'PopInitRange' ,[lower_bounds; upper_bounds], … 'Vectorized', 'off', 'PlotFcns',@gaplotpareto,'StallGenLimit',150);
[X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = gamultiobj(fitnessFunction,nvars,Aineq,Bineq,Aeq,Beq,LB,UB,options);
How can I change the setting such that 'gamultiobj' changes parameters XX to limit pricision to 2 digits.
Thanks, Yash

Best Answer

This is a very difficult thing to do in general, because MATLAB computes to double precision by default. If you really want to compute to two decimal places, you need to make a custom population type and do your own arithmetic.
But perhaps you mean you want the optimization to stop after it seems it has two decimals correct. This again is problematic to achieve, because the optimization algorithm has a very hard time determining whether it has converged to any reasonable degree. The TolFun option can help influence the degree of accuracy of the final Pareto front, and you can try setting it to 1e-3 or 1e-2 or so, but I cannot promise you that you will see any particular change in the behavior of the solver.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation