Display/Plot Functions for Genetic Algorithm seemingly not working when I include nonlinear constraint

조회 수: 13 (최근 30일)
I can't seem to get the iterative display or plot functions to work correctly for the genetic algorithm when I include a nonlinear constraint. Basically, a subset of my variables are the off-diagonals of a matrix that must be postive definite, so it is advantageous if I can force GA to search over the subset of the parameter space that guarantees this. Code is as follows:
options = optimoptions(@ga,'UseParallel',true,...
'PopulationSize',R,'MaxStallGenerations',30,'FitnessLimit',0,...
'PlotFcn',{@gaplotbestf},'display','iter',...
'MutationFcn',{@mutationadaptfeasible,1.5,0.5},'CrossoverFraction',...
0.5,'CrossoverFcn',{@crossoverintermediate,(1/8)*ones(1,14)},...
'InitialPopulationMatrix',X0);
con = @(theta)nlincon(theta); % nonlinear constraint function
calibrating= @(theta)model(moments,mom_var,theta,store,sigma,eta,r,A); % objective function
[theta,fval] = ga(calibrating,14,[],[],[],[],lb,ub,con,options);
when I use the above code, I get neither the iterative GA display output to show up, nor do I get the plot function to, well, plot. However, if I simply set the nonlinear constraint option to "[]", both the iterative display and plot functions work correctly. Can someone give me a clue here as to what I'm doing wrong?

답변 (1개)

Alan Weiss
Alan Weiss 2019년 10월 6일
When you use a nonlinear constraint function, ga uses a different algorithm that takes many, many more iterations internally than usual before it outputs a single plot or iterative display result. For an example, see Nonlinear Constraints Using ga. Notice how many internal function evaluations happen before a single iterative display result or a plot appears. For details of the algorithm, see Nonlinear Constraint Solver Algorithms.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Peiman Khandar
Peiman Khandar 2020년 5월 26일
I have a question about internal function evaluations. how can we collect them in a single matrix to see the proceeds. since we could not write for loop for it? does it have specific method ?
thanks

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

카테고리

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