'too many input arguments' error in Genetic Algorithm optimization toolbox
Show older comments
I have a problem with my optimization code. I enter this code in matlab:
function Prob = objective_function()
rng default
% Indices
k = 15;
j = 2;
f = 10;
l = 5;
r0 = 6;
r = 6;
% Parameters
cr0 = randi([0 1],1,r0);
dr0f = randi([0 1],r0,f);
csl = randi([0 1],1,l);
cpjk = randi([0 1],j,k);
corj = randi([0 1],r,j);
pr0f = randi([0 1],r0,f);
cvjrk = randi([0 1],j,r,k);
% Objective Function
cb = zeros(r0,f);
cd = zeros(r,j);
cor = zeros(r0,f);
cr = zeros(j,k);
ctr = zeros(1,l);
cp2 = zeros(j,r,k);
for ii = 1:r0
for jj = 1:f
cb(ii,jj) = cr0(ii).*dr0f(ii,jj);
end
end
for ii = 1:r
for jj = 1:j
cd(ii,jj) = corj(ii,jj);
end
end
for ii = 1:r0
for jj = 1:f
cor(ii,jj) = pr0f(ii,jj);
end
end
for ii = 1:j
for jj = 1:k
cr(ii,jj) = cpjk(ii,jj);
end
end
for ii = 1:l
ctr(ii) = csl(ii);
end
for ii = 1:j
for jj = 1:r
for kk = 1:k
cp2(ii,jj,kk) = cvjrk(ii,jj,kk);
end
end
end
obj = sum([cb(:);cd(:);cor(:);cr(:);ctr(:);cp2(:)]);
Prob.obj = obj;
disp(obj);
Prob.k = k;
Prob.j = j;
Prob.f = f;
Prob.l = l;
Prob.r0 = r0;
Prob.r = r;
Prob.cr0 = cr0;
Prob.dr0f = dr0f;
Prob.csl = csl;
Prob.cpjk = cpjk;
Prob.corj = corj;
Prob.pr0f = pr0f;
Prob.cvjrk = cvjrk;
Prob.cb = cb;
Prob.cd = cd;
Prob.cor = cor;
Prob.cr = cr;
Prob.ctr = ctr;
Prob.cp2 = cp2;
Prob = obj;
end
I want to solve this problem with genetic algorithm but when I use optimization toolbox and select 'ga' for solving the model, then I encounter with ' Too many input arguments' error. Whereas when I solve this problem with 'Linprog', I haven't receive any error. How I can solve this problem with ga?
Accepted Answer
More Answers (0)
Categories
Find more on Multiobjective Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!