GA Toolbox maximization fucntion

2 views (last 30 days)
Hamza
Hamza on 29 Dec 2014
Commented: Hamza on 3 Jan 2015
there is a Genetic algorithm toolbox. in which the ranking function is only aiming for the minimization of the fitness function i need to find a ranking function which aim for the maximization of the fitness function ....

Accepted Answer

Sean de Wolski
Sean de Wolski on 29 Dec 2014
maxfcn = @(x)-minfcn;
Just negate the min function!
  3 Comments
Sean de Wolski
Sean de Wolski on 30 Dec 2014
The minima of the negation will be the maxima. What you have above looks right to me.
Hamza
Hamza on 3 Jan 2015
Thank you very much sir for your help i have one another problem. i want to make random complex numbers like real part between (-0.5 to 0.5) and imaginary also -0.5i to 0.5i .
in the gatbx the range of the variable is found using rep function in matlab like FieldD = [rep([PRECI],[1, NVAR]); rep([-0.5-0.5;+0.5i+0.5i],[1, NVAR]);... rep([1; 0; 1 ;1], [1, NVAR])]; Chrom = crtbp(NIND, NVAR*PRECI); Phen = bs2rv(Chrom,FieldD);
i wrote -0.5-0.5;+0.5i+0.5i. but this is not giving me what i want. in my phenotype this is giving me (random)real-random(imag) and random(real)+random(imag). but it is skipping the numbers like -(random)real+random(imag) or random(real)-random(imag). e.t.c
can you help me with this one ..

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!