genetic algorithm - reg

1 Ansicht (letzte 30 Tage)
Kallam Haranadha Reddy
Kallam Haranadha Reddy am 11 Dez. 2018
Kommentiert: Walter Roberson am 11 Dez. 2018
I want to use genetic algorithm for inventory classification. Number of variables is 6. All the variables must lie between 0 and 1. If we add first 4 variables, the sum must be 1. Also 5 th variable must be greater than 6 th variable. My doubt is whether the Fitness function should return a single scalar value or the fitness function should return all the fitness values of the population. I think the GA can be solved using the toolbox of GA in MATLAB. I tried to run GA in optimtool toolbox. The population size is 50. The fitness function is InvGAClassifyFitnessFunc(Position, classGA1,ClassDM!) where Position is the chromosome with the above properties. I have written the inequalities as Aineq=[0,0,0,0,-1,1] Bineq=0;
Aeq as [1,1,1,1,0,0] and Beq as [1];
lb as [0,0,0,0,0,0] and ub as [1,1,1,1,1,1];
creation function as constraint-dependent. Population type is double.Scaling function as Rank. Selection function as 'Roulette'.Mutation function as 'Adaptive feasible'. Crossover function as 'Constraint dependent'. All other options as default.
When i ran this problem in MATLAB it is giving error " Not enough input arguments".
Please guide me.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Dez. 2018
Your fitness function will be passed a single population member in the form of a vector . It should return aa scalar . ga will call it as many times as needed to pass in all the population members .
Your fitness function appears to require 3 inputs needing classGA1 and ClassDM1 as the second and third parameters . ga only passes a single parameter to the fitness function . You probably need to paramaterize the fitness function
ff = @(Position) InvGAClassifyFitnessFunc(Position, classGA1, ClassDM1 )
and then pass ff as the fitness function .
  3 Kommentare
Walter Roberson
Walter Roberson am 11 Dez. 2018
Note: char(68,1) does not reserve a 68 x 1 array of characters. char(68,1) is the same as
[char(68); char(1)]
which takes the character that is assigned position 68, namely 'D', and put below it the character assigned position 1, namely https://www.fileformat.info/info/unicode/char/0001/index.htm SOH, Start Of Heading.
Walter Roberson
Walter Roberson am 11 Dez. 2018
It would be easier if we had your source code to work with.
for i=1:68
ClassDM1{i,1}=Data.ClassDM{i+3,1};
ClassDM1{i,1}=ClassDM1{i,1};
end
Okay so the first ClassDM1{i,1} assignment extracts some data from Data.ClassDM. But then the second one overwrites what was just assigned... overwrites it with itself ??
ClassDM1=@(i)ClassDM(i,1);
and that overwrites the cell array just built up, with a function handle to an anonymous function that extracts one cell (not the contents of the cell) from a variable that is still only initialized to cell(68,1) ?
And the function handle is being passed as a parameter to InvClassifyGAFitnessFunc ??

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by