GA error due to boxdirections

2 次查看(过去 30 天)
Joe
Joe 2014-4-21
回答: Rakesh Kumar 2020-10-14
I know there was a similar post in the forum ( here ), but my problem is definitely not because of typos in the objective function, because it works perfectly under patternsearch and simulatedannealing. I constantly get the error shown below here and this problem is so annoying that I couldn't sleep well lately, so any advice is greatly appreciated. It seems weird to me because I couldn't find anywhere in GA algorithm to set MeshSize. Version is Matlab 2012b.
"
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)
"
My command for invoking GA is:
"
run ii_parameter_TBE.m; % to generate initial values, lb and ub of parameters
load parameter.mat;
load bound.mat;
options = gaoptimset('TolFun',1e-3,'PopulationSize',length(parameter)*2,'Display','diagnose');
rng('default')
[x,fval,exitFlag,output] = ga(@ii_objective,length(parameter),[],[],[],[],lb,ub,[],[],options);
"
Best regards,
Joe

回答(2 个)

yvette-hyq
yvette-hyq 2015-4-16
编辑:yvette-hyq 2015-4-17
Hi Joe,
Just wonder if you have found the cause of the problem. I have the exact problem as yours. The initialisation of this variable as I can trace back to is in line 28 to 44;
StepSize = 1;
in mutationadaptfeasible.m. But I don't see what the problem is when it comes to boxdirections.m.
I appreciate if you can share some suggestions. Thank you very much.
Yvette

Rakesh Kumar
Rakesh Kumar 2020-10-14
Before running your code, please issue this command (so MATLAB wil stop where an error is thrown)
dbstop if error
MATLAB will stop in boxdirections (line 23). Please check the value of MeshSize and report back.
Thanks,
Rakesh

类别

Help CenterFile Exchange 中查找有关 Direct Search 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by