Number of variables (nvars) is dependent on the value of one variable when using genetic algorithm (GA)
10 次查看(过去 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!
0 个评论
采纳的回答
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!