# Genetic Algorithm - Vectorized Mode - Reg

2 visualizaciones (últimos 30 días)
Kallam Haranadha Reddy el 29 de Dic. de 2018
Editada: Stephen23 el 30 de Dic. de 2018
'Position' is a (68,6) array of doubles representing the population of Genetic algorithm. 'classGA1 ' is a (68,1) cell array of the type of population class ( inventory class A,B or C) . 'ClassDM1 ' is a (68,1) cell array of the inventory class(A,B, or C)given by the decision maker (materials manager).
[Fitness] = InvClassifyGAFitnessFunc(Position,classGA1,ClassDM1);
is the Fitness is a (68,1) double array determining the fitness of population.
I want to operate the GA in vectorized mode.
[Fitness] = @(Position)InvClassifyGAFitnessFunc(Position(':',1:6),classGA1{':',1},ClassDM1{':',1});
% vff = @(Position) InvClassifyGAFitnessFunc(Position(':',1:6), classGA1{':'},CDM1{':'});
A=[0,0,0,0,-1,1];
b=[0];
Aeq=[1,1,1,1,0,0];
beq=[1];
lb=[0,0,0,0,0,0];
ub=[1,1,1,1,1,1];
options= gaoptimset('PlotFcn',@gaplotbestf,'Vectorized','on');
[x,fval]=ga(Fitness,6,A,b,Aeq,beq,lb,ub,[],options);
The genetic algorithm is giving the error message
Error using InvClassifyGAFitnessFunc
Too many input arguments.
How to run my genetic algorithm in vectorized mode.
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

Walter Roberson el 30 de Dic. de 2018
'classGA1 ' is a (68,1) cell array of the type of population class
When that is the case, then
classGA1{':',1}
expands into 68 different arguments, equivalent to classGA1{:}
##### 4 comentariosMostrar 3 comentarios más antiguosOcultar 3 comentarios más antiguos
madhan ravi el 30 de Dic. de 2018
Thank you!

Iniciar sesión para comentar.

madhan ravi el 29 de Dic. de 2018
Your function requires only two inputs whereas you have stuffed in 3 .
##### 4 comentariosMostrar 3 comentarios más antiguosOcultar 3 comentarios más antiguos
Stephen23 el 30 de Dic. de 2018
Editada: Stephen23 el 30 de Dic. de 2018
"Your function requires only two inputs whereas you have stuffed in 3 ."
There are actually 137 inputs to InvClassifyGAFitnessFunc:
Three inputs is probably the correct number, judging by this earlier thread:

Iniciar sesión para comentar.

### Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

R2015b

### Community Treasure Hunt

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

Start Hunting!

Translated by