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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by