GA error due to boxdirections

1 view (last 30 days)
Joe
Joe on 21 Apr 2014
Answered: Rakesh Kumar on 14 Oct 2020
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

Answers (2)

yvette-hyq
yvette-hyq on 16 Apr 2015
Edited: yvette-hyq on 17 Apr 2015
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 on 14 Oct 2020
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

Community Treasure Hunt

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

Start Hunting!