Genetic Algorithm constant input for different topologies
이전 댓글 표시
Hello,
I have been using ga in my project. In the project, I have 10 possible locations. I would like to choose 2 of 10 possible locations depending on the fitness value. However, as you see, there are 10 possible locations and 2 of them should be chosen.
2 is just the sum of bitstrings. It can be => [0 0 0 0 0 0 0 0 1 1] or [1 0 1 0 0 0 0 0 0 0].
How can I do it with ga in Matlab.
Thanks in advance.
I
댓글 수: 1
Vaidyanathan Thiagarajan
2017년 8월 29일
편집: Vaidyanathan Thiagarajan
2017년 8월 29일
Hello Hamilt,
What is your objective function? Do you have any constraints?
Did you get a chance to look at this page?
Vaidyanathan
답변 (2개)
Walter Roberson
2017년 8월 29일
You can use
N = 10;
A = [ones(1,N); -ones(1,N)]
b = [2; -2];
Aeq = []; beq = [];
lb = zeros(1,N);
ub = ones(1,N);
nonlcon = [];
intcon = 1:N;
ga(YourObjectiveFunction, N, A, b, Aeq, beq, lb, ub, nonlcon, intcon)
This says that the positive of the sum of the variables must be <= 2, and that the negative of the sum of the variables must be <= -2 . The only way that combination can happen together is if the sum is exactly 2.
Alan Weiss
2017년 8월 29일
0 개 추천
If I understand you correctly, you have 10 choose 2 = 45 possibilities. Why not do an exhaustive search? Even if you program integer ga to look around, it can miss the optimum, whereas exhaustive search cannot. To generate all 45 possibilities programmatically, see the nchoosek reference page.
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!