Genetic Algorithm - limiting significant digits of Optimization Variable

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

 채택된 답변

Alan Weiss
Alan Weiss 2013년 8월 12일

0 개 추천

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

댓글 수: 4

Thanks Alan, I want to achive what you describe in the 1st paragraph. The alogrithm should generate input population which have upto two digits after the decimal. This should happen for every iteration/elvolution (not sure what the correct term should be) of the GA.
Eg: XX = [14.25 12.1 -0.12]
This is the first time I am working with GA. Above was just an example, I am running the main physics based CFD simulation using external commercial software, for which the input parameter precision is only upto 2 decimal digits.
I can directly truncate the inputs generated by MATLAB to 2 decimal digits but not sure how that will influnce the evolution of GA. Will be helpful you had similar experince in the past, any pointers from you or anyone else will be helpful.
Thanks, Yash
Would it help if you worked in integers only? See this section of the documentation. You can divide the answers by 100 when you are done. Make sure to specify a diverse enough population, by giving appropriate bounds (a factor of 100 bigger than they are before you scale them up for this integer formulation).
Alan Weiss
MATLAB mathematical toolbox documentation
Thanks Alan, this should work. The input values can be divided by 100 that is not a problem.
Oh, crud, I don't know what I was thinking. gamultiobj does not take integer variable restrictions. Sorry, that only works for ga, not gamultiobj.
Alan Weiss
MATLAB mathematical toolbox documentation

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

질문:

2013년 8월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by