GWO structure help, please rewrite the code help

NumAgents = 7;
maxiters = 2000;
lb = [0 2];
ub = [1 5];
dim = 2;
fobj = @my_function_that_expects_a_vector_of_2_values;
GWO(Numagents, maxiters, lb, ub, dim, fobj)
I am executing this code after installing the GWO toolbox in my matlab directory.
error appears as:
Not enough input arguments.
Error in GWO (line 116)
set(handles.itertext,'String', ['The current iteration is ', num2str(l)])
Error in gwostrcture (line 14)
GWO(Numagents, maxiters, lb, ub, dim, fobj)
i am unable to detect the error. can any one help me to rectify this issue.

Answers (1)

NumAgents = 7;
maxiters = 2000;
lb = [0 2];
ub = [1 5];
dim = 2;
fobj = @my_function_that_expects_a_vector_of_2_values;
[BestScore, BestPos, CG_Curve] = GWO(NumAgents, maxiters, lb, ub, dim, fobj)

8 Comments

i am getting same error
Please show your function - this example works properly:
NumAgents = 7;
maxiters = 2000;
lb = [0 2];
ub = [1 5];
dim = 2;
fobj = @(x) x(1).^2+x(2).^2;
[BestScore, BestPos, CG_Curve] = GWO(NumAgents, maxiters, lb, ub, dim, fobj)
this is my function
f=
(4804161458172084915439888952351367*x1^2)/633825300114114700748351602688000 + (11024762890340132617008770664173683865571*x2^2)/332306998946228968225951765070086144000
Stephan
Stephan on 14 Mar 2019
Edited: Stephan on 14 Mar 2019
This will work:
NumAgents = 7;
maxiters = 2000;
lb = [0 2];
ub = [1 5];
dim = 2;
fobj = @(x) (4804161458172084915439888952351367*x(1).^2)/633825300114114700748351602688000+...
(11024762890340132617008770664173683865571*x(2).^2)/332306998946228968225951765070086144000;
[BestScore, BestPos, CG_Curve] = GWO(NumAgents, maxiters, lb, ub, dim, fobj);
easier and numerically the same:
fobj = @(x) 7.579630313443054*x(1).^2+33.176439031680047*x(2).^2;
lb = [0 2];
ub = [1 5];
dim = 2;
fobj = @(x) (4804161458172084915439888952351367*x(1).^2)/633825300114114700748351602688000+...
(11024762890340132617008770664173683865571*x(2).^2)/332306998946228968225951765070086144000;
[BestScore, BestPos, CG_Curve] = GWO(NumAgents, maxiters, lb, ub, dim, fobj);
ITS showing
Not enough input arguments.
Error in GWO (line 116)
set(handles.itertext,'String', ['The current iteration is ', num2str(l)])
Stephan
Stephan on 14 Mar 2019
Edited: Stephan on 14 Mar 2019
where are NumAgents and maxiters gone?
its were there in code but the error was same
For me it worked properly. I loaded the GWO down from this source:
and the code works without any problems.

Sign in to comment.

Asked:

on 14 Mar 2019

Commented:

on 14 Mar 2019

Community Treasure Hunt

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

Start Hunting!