Ga Results Worse with Each Generation

2 views (last 30 days)
agion
agion on 27 Feb 2023
Commented: agion on 28 Feb 2023
I am trying to use the ga function to optimize a function, but am noticing a strange behavior. My function has 5 variables that are bound to between 0 and -10 and there is a equality constraint that in the form of c(x) -1 = 0. I am using the following options:
options = optimoptions('ga','UseVectorized',true,'PopulationSize',3000,'InitialPopulationMatrix',intpop2,'MaxGenerations',50,...
'FunctionTolerance',1e-4,'ConstraintTolerance',1e-4,'Display','iter');
where the initial poptulaiton is a matrix of all combinations of the five variable (equally spaced along a grid between 0 and -10). The problem I am having is that I frequently notice that after several generation the ga function returns worse results. When exaiminging the output of each iteration, an acceptable answer seems to be found after 5 or so iterations; however the function continues and the results become worse. I have tried to change the function tolerance and constraint tolerance but the results are largely the same or become inconsistent (outside of the normal variations when using optimaztion functions). Below is an example of the output I frequently get.
Generation Func-count Best f(x) Max Constraint Stall Generations
1 162500 0.00106595 0.01563 0
2 314182 0.000272166 0.01934 0
3 473557 0.00190035 0.01894 0
4 632932 0.000113225 0.01067 0
5 792307 4.30226e-05 0.005452 0
6 943989 0.000232475 0.001222 0
7 1103364 1.50892e-06 0.001525 0
8 1262739 1.50892e-06 0.001525 1
9 1422114 1.50892e-06 0.001525 2
10 1581489 1.50892e-06 0.001525 3
11 1740864 1.50892e-06 0.001525 4
12 1900239 6.42236e-05 0.002838 0
13 2059614 5.37465 385 0
14 2218989 3.37523 14.95 0
15 2378364 3.19792 1 0
16 2537739 3.25397 1 0
17 2697114 2.60784 1 0
18 2856489 3.26691 0.9944 0
19 3015864 3.31657 1 0
20 3175239 5.10486 0.5483 0
  3 Comments
Alan Weiss
Alan Weiss on 28 Feb 2023
I'm not sure that I understand your "equality constraint that in the form of"
c(x) - 1 = 0
Usually, I would call this a nonlinear equality constraint
ceq(x) = 1
I am not sure how you have implemented your nonlinear constraint function. Can you show us what inputs and outputs it gives?
Alan Weiss
MATLAB mathematical toolbox documentation
agion
agion on 28 Feb 2023
Yes, my mistake I have it set to a nonlinear equality constraint of
ceq(x) = 1
I can't really show all of the inputs and output as it is part of a much larger application with a gui and user inputs that I am writting, but effectvely the input to the nonlinear constraint function is 3 values (a1, a2, and a3) that are calculated by the objective function and within the nonlinar constraint function (a1*a2)/(a3*K) = 1, where K is constant. I should also not that if I remove this constraint the ga function performs as expected.

Sign in to comment.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!