Restricting members to choose in population selection
Mostrar comentarios más antiguos
Hello all,
I'd like to be able to define the list of possibilities that my population can be selected from.
For example, if using the optimization tool, I can define my bounds to be [1,1] to [400,400] and in this case any value is chosen between this range on each iteration of the ga.
If I want to constraint this as follows so that I only use steps of 5 from the population. How can I do this. Here is what I mean by steps.
popsize = 20;
steps = [1;(5:5:400)';]
[X,Y] = ndgrid(steps,steps);
A = [X(:),Y(:)];
A(randperm(length(A),popsize),:)
Respuestas (1)
Alan Weiss
el 8 de Abr. de 2013
0 votos
It sounds to me as if you want to restrict your population to be multiples of 5, from 5 to 400. You can do this by restricting your population to be integers from 1 to 400/5=80, and scaling your results afterwards.
To restrict your population to integers from 1 to 80, see the documentation of mixed integer programming in ga.
Alan Weiss
MATLAB mathematical toolbox documentation
2 comentarios
David
el 8 de Abr. de 2013
Alan Weiss
el 8 de Abr. de 2013
I would not try to use a nonlinear constraint to enforce integrality. If it were that easy, we would not have made a special integer solver!
Please try the integer method before wasting time on a nonlinear constraint method.
Alan Weiss
MATLAB mathematical toolbox documentation
Categorías
Más información sobre Choose a Solver en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!