Effacer les filtres
Effacer les filtres

Error in genetic algorithm in toolbox

2 vues (au cours des 30 derniers jours)
b
b le 11 Mai 2012
I am trying again and again on genetic algorithm toolbox(GUI). When i run my algorithm, the error occurs as;
Optimization running.Error running optimization. Too many input arguments.
Why this occurs?
Thanks...

Réponse acceptée

Sean de Wolski
Sean de Wolski le 11 Mai 2012
What functions are you using? What code are you calling them with?
If you run:
dbstop if error
to stop with the debugger when an error is encountered, and then run the code as you are doing. It will stop with the debugge ron that line and you will see that you are feeding more inputs to whatever you are calling than it can receive.
  2 commentaires
b
b le 11 Mai 2012
Can you help me with the question i wrote below?
Sean de Wolski
Sean de Wolski le 11 Mai 2012
Nope. I don't know what your inputs are and I haven't seen that you'veollowed the debugging steps I've mentioned above. Following these steps will probably make this trivial to solve.

Connectez-vous pour commenter.

Plus de réponses (1)

b
b le 11 Mai 2012
I am using(GUI) Rastrigin function as objective function with four variables and real values.
I think(now i realize) in the mutation part of the GA, i have some error. my mutation function is: unction NewChrom = mutbga(initial1, FieldDR, MutOpt);
if nargin < 2, error('Not enough input parameters'); end
[Nind,Nvar] = size(initial1);
[mF, nF] = size(FieldDR);
if mF ~= 2, error('FieldDR must be a matrix with 2 rows'); end
if Nvar ~= nF, error('FieldDR and OldChrom disagree'); end
if nargin < 3, MutR = 1/Nvar; MutShrink = 1;
elseif isempty(MutOpt), MutR = 1/Nvar; MutShrink = 1;
elseif isnan(MutOpt), MutR = 1/Nvar; MutShrink = 1;
else
if length(MutOpt) == 1, MutR = MutOpt; MutShrink = 1;
elseif length(MutOpt) == 2, MutR = MutOpt(1); MutShrink = MutOpt(2);
else, error(' Too many parameters in MutOpt'); end
end
if isempty(MutR), MutR = 1/Nvar;
elseif isnan(MutR), MutR = 1/Nvar;
elseif length(MutR) ~= 1, error('Parameter for mutation rate must be a scalar');
elseif (MutR < 0 || MutR > 1), error('Parameter for mutation rate must be a scalar in [0, 1]'); end
if isempty(MutShrink), MutShrink = 1;
elseif isnan(MutShrink), MutShrink = 1;
elseif length(MutShrink) ~= 1, error('Parameter for shrinking mutation range must be a scalar');
elseif (MutShrink < 0 || MutShrink > 1),
error('Parameter for shrinking mutation range must be a scalar in [0, 1]');
end
FieldDR=[0 0 0 0;20 25 5 5];
Range = rep(0.5 * MutShrink *(FieldDR(2,:)-FieldDR(1,:)),[Nind 1]);
% zeros and ones for mutate or not this variable, together with Range
Range = Range .* (rand(Nind,Nvar) < MutR);
Range = Range .* (1 - 2 * (rand(Nind,Nvar) < 0.5));
ACCUR = 20;
Vect = 2 .^ (-(0:(ACCUR-1))');
Delta = (rand(Nind,ACCUR) < 1/ACCUR) * Vect;
Delta = rep(Delta, [1 Nvar]);
NewChrom = initial1 + Range .* Delta;
NewChrom = max(rep(FieldDR(1,:),[Nind 1]), NewChrom);
NewChrom = min(rep(FieldDR(2,:),[Nind 1]), NewChrom);

Community Treasure Hunt

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

Start Hunting!

Translated by