Genetic Algorithm constant input for different topologies
Mostra commenti meno recenti
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 Commento
Vaidyanathan Thiagarajan
il 29 Ago 2017
Modificato: Vaidyanathan Thiagarajan
il 29 Ago 2017
Hello Hamilt,
What is your objective function? Do you have any constraints?
Did you get a chance to look at this page?
Vaidyanathan
Risposte (2)
Walter Roberson
il 29 Ago 2017
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
il 29 Ago 2017
0 voti
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
Categorie
Scopri di più su Genetic Algorithm in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!