I am running into a puzzling error when when using the ga function in MATLAB’s global optimization toolbox, the error message is pasted below to see if anyone can decipher what this means.
I am trying to seed the ga with an initial population, a matrix of pop-by-nvar. However, this produces the error below. I can only get the ga to run if I pass in an initial population vector of (pop-1)-by-nvar. This is a little inconvenient since I want to specify the entire population. I hope someone who is familiar with the global optimization toolbox and the ga function can shed some light here!
??? Index exceeds matrix dimensions.
Error in ==> gacreationlinearfeasible>lhsLambda at 213
[lambda(i,:),f,e] = fmincon(fun,lambda(i,:),[],[],Aeq,beq,lb,ub,[],opts);
Error in ==> gacreationlinearfeasible>feasibleLHS at 180
initialPopulation(boundary_points+1:interior_points+boundary_points,:) = ...
Error in ==> gacreationlinearfeasible at 42
feasiblePop = feasibleLHS(individualsToCreate,GenomeLength,options);
Error in ==> makeState at 30
state.Population = feval(options.CreationFcn,GenomeLength,FitnessFcn,options,options.CreationFcnArgs{:});
Error in ==> galincon at 18
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ==> ga at 282
[x,fval,exitFlag,output,population,scores] = galincon(FitnessFcn,nvars, ...
Here is an example of using GA with specifying an initial population:
Here is the solution I get after 72 generations:
Note that the Rastrigin function has the global minimum at (0,0)