GA optimiser error in boxdirections
Ältere Kommentare anzeigen
I constantly get the error shown below here and I would very much appreciate if anyone could point to what I can do to avoid this. Version is Matlab 2013a. Thanks!
Error using / Matrix dimensions must agree.
Error in boxdirections (line 23) pollParam = 1/sqrt(MeshSize);
Error in mutationadaptfeasible (line 71) [Basis,TangentCone] = boxdirections(true,StepSize,x,linCon.lb,linCon.ub,tol);
Error in stepGA (line 36) mutateKids = feval(options.MutationFcn, parents((1 + 2 * nXoverKids):end), options,GenomeLength,FitnessFcn,state,thisScore,thisPopulation,options.MutationFcnArgs{:});
Error in galincon (line 63) [score,population,state] = stepGA(score,population,options,state,GenomeLength,FitnessFcn);
Error in ga (line 351) [x,fval,exitFlag,output,population,scores] = galincon(FitnessFcn,nvars, ...
Error in GAOptimDesign (line 8) [x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB)
The code I am running is as follows, i.e. the ga optimiser from the optimtool:
ObjectiveFunction = @design; nvars = 12; % Number of variables LB = [-3 -3 -3 -3 18 10 10 5 65 65 65 65]; % Lower bound UB = [5 5 5 5 30 25 25 20 75 75 75 75]; % Upper bound
options = gaoptimset('PopulationSize',3) [x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB
The design function is way to large to describe here.
Akzeptierte Antwort
Weitere Antworten (1)
Aliyu Bagudu
am 5 Apr. 2016
0 Stimmen
I had the same problem however, I was able figure out where the problem actually comes from. The problem comes from the formula GA uses to calculate the number children of the next generation and thus the number of selected parents. There are 3 types of children in GA: Elite children(specified by EliteCount), Crossover children(specified by crossoverFraction) and calculated as crossoverFraction*(populationSize - EliteCount), and mutation children (calculated using populationSize - EliteCount - crossover children). You don't specify number of mutation children, it is calculated.
So the problem comes from rounding when calculation crossover fraction. The rounding is done to the nearest integer. So for some combination of populationSize, crossoverFraction, and EiltCount, this can result in total number of children that is not equal to populationSize.
Number of parents is 2 times number of children for crossover children. For mutation number of parents is equal to number of children.
1 Kommentar
mohamed afifi
am 18 Mär. 2017
I have the same problem so please can you show me how to solve it?
Kategorien
Mehr zu Genetic Algorithm finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!