Sording acceding order for maximization of function x^2+2*X+1

8 views (last 30 days)
PROGRAME
clear %Setup the GA ff = @testfun; x0=[1 5]; npar=1; %stopping crieteria maxit=100; mincost=-9999999; %GA parameters pop_size=4; mutrate=0.15; selection=0.5; nbits=8; Nt=nbits*npar; keep=floor(selection*pop_size); %Create the initial population iga=0; pop=round(rand(pop_size,Nt)); de=bi2de(pop); disp('Decimal Binary'); disp([de,pop]); xlow=1; xhigh=5; x=xlow+((xhigh-xlow)/(2^nbits-1))*de; for i=1 : pop_size f(i)=x(i).^2+2*x(i)+1 end
%%%%OUTPUT Output: Decimal Binary 239 1 1 1 1 0 1 1 1 85 1 0 1 0 1 0 1 0 248 0 0 0 1 1 1 1 1 55 1 1 1 0 1 1 0 0
f =
33.0512
f =
33.0512 11.1111
f =
33.0512 11.1111 34.6944
f =
*33.0512 11.1111 34.6944 8.1953*
from above output of function i want to sort it in acceding order then convert it to binary and then do process of crossover so pls help me to do it.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!