Error in genetic algorithm in toolbox

1 回表示 (過去 30 日間)
b
b 2012 年 5 月 11 日
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...

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 5 月 11 日
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 件のコメント
b
b 2012 年 5 月 11 日
Can you help me with the question i wrote below?
Sean de Wolski
Sean de Wolski 2012 年 5 月 11 日
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.

サインインしてコメントする。

その他の回答 (1 件)

b
b 2012 年 5 月 11 日
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);

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by