Number of variables (nvars) is dependent on the value of one variable when using genetic algorithm (GA)

4 ビュー (過去 30 日間)
I have two kinds of variables: x and y, and y includes y1, y2, y3, y4, ...
The total number of y's is dependent on the value of x.
For example, if x = 4, then my variables are vars=[x, y1, y2, y3, y4];
if x = 6, then my variables are vars=[x, y1, y2, y3, y4, y5, y6];
In addition, both x and y's are discrete integers, and I have both upper and lower bounds for them.
For example, the options for x is [4, 6, 8, 10];
the options for all the y's (are the same) is [4, 5, 6, 7, 8];
Could GA deal with this problem?
I was thinking to make nvars the potential maximum value.
That is to say, based on the above example, I could make nvars = 1(this is x)+10 (these are 10 y's)=11.
However, I still have issues.
For example, during the optimization process, the value of x could be 6, then there will be only 6 y's, which means the last four variables will be useless (by "useless" I mean there is no need to optimize), then I think I need to set the upper bounds to be same as the lower bounds for these four variables.
But how? Actually, I don't know the value of x when I set the lower and upper bounds, yes?
Thanks in advance!

採用された回答

Walter Roberson
Walter Roberson 2019 年 1 月 30 日
Run the system multiple times, one for each of the discrete values of x. Take the best of the solutions.
  5 件のコメント
Walter Roberson
Walter Roberson 2019 年 1 月 30 日
Yes and Yes.
ga() does not care how you compute the objective function. But it cannot detect that it is working on a case in which one of the variables is unused, and will waste time trying to find values of that variable that lead to a better result. This waste of time can easily lead to it not converging in the number of iterations you give it.
Min Zhang
Min Zhang 2019 年 1 月 30 日
Thank you so much for your answers!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by