please do someone help me rectify this error…
i was using the genetic algorithm in matlab..
firstly i tried the followng code
rand('seed', 0); FitnessFunction = @simple_fitness; numberOfVariables = 50; [x,fval] = ga(FitnessFunction,numberOfVariables); function y = simple_fitness(x) y = 100 * (x(1)^2 - x(2)) ^2 + (1 - x(1))^2;
and it worked fine…
then i tried giving input as
rand('seed', 0); FitnessFunction = @simple_fitness; numberOfVariables = 50; A = rand(40,59); b = ones(40,1); [x,fval] = ga(FitnessFunction,numberOfVariables,A,b);
this worked for the first time, the second time i gave execute button it showed message as "didnt optimize…"
Third time also it got executed…
But then i changed the value of A and b to
A = rand(27,128);b = ones(27,1);
then it didnt execute for the changed value… now it is not working for any values of A and b. It is showing error as
??? Error using ==> preProcessLinearConstr at 49 The number of columns in A must be the same as the length of X0. Error in ==> gacommon at 79 [Iterate.x,Aineq,bineq,Aeq,beq,lb,ub,msg,exitFlag] = ... Error in ==> ga at 269 [x,fval,exitFlag,output,population,scores,FitnessFcn,nvars,Aineq,bineq,Aeq,beq,lb,ub, ... Error in ==> Untitled16 at 28 [x,fval] = ga(FitnessFunction,numberOfVariables,A,b);
i dont know why this error… it executed once, but now showing error… it gets executed for the case where A and b are not given… but in case we give values of A and b, the above error is obtained… Please do reply…
please can someone explain me what is the value of x in the first case…
Best Answer