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
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
Walter Roberson 2017 年 8 月 29 日

0 投票

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 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

カテゴリ

タグ

質問済み:

2017 年 8 月 25 日

編集済み:

2017 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by