Restricting members to choose in population selection
이전 댓글 표시
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),:)
답변 (1개)
Alan Weiss
2013년 4월 8일
0 개 추천
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
David
2013년 4월 8일
Alan Weiss
2013년 4월 8일
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
카테고리
도움말 센터 및 File Exchange에서 Choose a Solver에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!