Clear Filters
Clear Filters

Confusion about running times/cases when running genetic algorithm (GA)

2 views (last 30 days)
Dear ALL,
I have an optimization problem, including:
(1) An objective function;
(2) 14 variables to optimize, including 4 continuous variable and 10 discrete variables (including 4 integer variables);
But please note that sometimes I might optimize all the 14 variables, but sometimes I might ONLY optimize one variable, eg., 1 discrete variable.
Then how did I optimize ONLY one variable? I just gave both the upper and lower bounds of all other 13 variables to be 0.
Q1: Is it a correct way?
(3) Linear inequality constraints;
(4) Non-linear inequality constraints;
(5) I want to find the global optima.
Therefore, I have been using GA.
But I am confused about the total number of running cases of GA.
For example, I am optimizing ONLY 1 discrete variable and I am giving GA two options.
Then, I thought GA only needs run 2 cases since I only give it 2 options, and then compare the objective function values of these two cases and get the optimal solution.
However, it seems that GA runs a lot of cases...
I am confused...
Thanks in advance for your answers!
Best regards,
Min

Accepted Answer

Walter Roberson
Walter Roberson on 28 Jan 2019
To optimize only one variable, set the lower bounds of the other variables to be the same as the upper bounds, and each entry should be the value associated with the variable. This will seldom be 0.
Mathworks do not have any routines that are guaranteed to find the global optima in general. For some kinds of functions it can be shown that the global optimum can be found (at least with some settings), but not in general. Indeed, it can be shown that in general for some functions, the global optimum cannot possibly be found except by testing every possible combination of values.
  2 Comments
Walter Roberson
Walter Roberson on 28 Jan 2019
ga() has no protection at all against generating random combinations that have already been generated. If there are only 2 valid combinations of values, then it will happily randomly generate from the same 2, trying over and over again to find a better solution. ga() makes no attempt at all to be systematic about the random solutions it tries.
ga() has different ways of deciding where to "move to" next, including ways that depened upon centroids or best current member. Because of that, it is possible in theory that the exact same input vector in a different generation could lead to a different solution that might be better, so ga() should not prevent combinations that it has tried before.
What ga() does have is a "stall" limit, where it can figure out that nothing has improved for a number of generations, at which point it gives up. You can configure the stall limit in the options structure.
Min Zhang
Min Zhang on 28 Jan 2019
Thank you very much for your answers!
  1. I set the lower bounds of the other variables to be the same as the upper bounds, which are all zeros. Actually, the calculation of the objective function needs to call an external .exe, which needs an input file from Matlab. When I write this input file, and when I don't optimize this variable, I just don't modify this parameter in the input file. Essentially, this parameter will be always the parameter of a base case. So I think I should be fine to go.
  2. For my problem, I am wondering whether GA is the most appropriate method to use or not. Currently, the unsatisfactory issue of GA is the running time is so long even though I am running it in parallel. For example, in some cases, it might take 24 hours when running with 4 workers.
  3. Because of that, it is possible in theory that the exact same input vector in a different generation could lead to a different solution that might be better, so ga() should not prevent combinations that it has tried before. It is difficult for me to understand this but I will figure it out.
  4. I think you are talking about MaxStallGenerations. Do you think I can also make the PopulationSize smaller? For example, if I know that I have only two valid combinations of values, I set the PopulationSize to be 5? In addition, so you don't think I can do the configuration of these GA settings in a systematic way except for trial and error?
Thanks again!
Regards,
Min

Sign in to comment.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!