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 comentario

Vaidyanathan Thiagarajan
Vaidyanathan Thiagarajan el 29 de Ag. de 2017
Editada: Vaidyanathan Thiagarajan el 29 de Ag. de 2017
Hello Hamilt,
What is your objective function? Do you have any constraints?
Did you get a chance to look at this page?
Vaidyanathan

Iniciar sesión para comentar.

Respuestas (2)

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
Alan Weiss el 29 de Ag. de 2017
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

Etiquetas

Preguntada:

el 25 de Ag. de 2017

Editada:

el 29 de Ag. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by