Closed yasser9372 closed 6 years ago
You can use GAFT to solve your problem I think. You can refer to the example with 3 variables and define you own fitness function (or the loss function). Usually the gaft initialize the initial population randomly, but you can define individuals explicitly too.
The matlab code may use different implementations of genetic operators in GAFT. So GAFT may not provide the equivalent interfaces. But the GAFT support custom operation defintion, you can write python code to do it in GAFT framework. Enjoy it.
Thank you. How can i generate first population explicitly?? Is it contain elite ????
You can use the BinaryIndividual
to create your individuals, the implementation see:https://github.com/PytLab/gaft/blob/master/gaft/components/binary_individual.py
By the way, I don't get what the elite mean, can you explain it in more details?
Thank you so much for your answering. I mean Elite algorithm for save the best chromosome in every population.
Edit:
Sorry for my a lot of Questions.
I am a little confused how i can define my fitness function.
when i use
@engine.fitness_register
i get error that engine not imported. when i import engine as
from gaft import engine
fitness_register not founded in engine. and if i use
@GAEngine.fitness_register
i get this error "missing 1 required positional argument: 'fn'"
Engine
firstly, see the example please https://github.com/PytLab/gaft/tree/master/examples
Hi.
I have a database with 200 sample with 4 feature for example "a, b, c, d". i want to put it into a polynomial like "ax + by + cz + dw" that have a different answer for each data. i want to use Genetic to find best Coefficients for this problem. can i use this framework for my problem?? can you help me how i can generate my population and fitness function ???
Edit: in https://github.com/PytLab/gaft/issues/13 you create 3 variable. the ranges that you set like (-10,10) is for first generate or it kept in all the algorithm???? what if i want to define an elite chromosome for beginning???
Edit 2: i have this operators in my Genetic in matlab. what is the Equivalent of this options??
options=gaoptimset('InitialPopulation',population,'SelectionFcn',@selectiontournament,'CrossoverFcn',@crossoversinglepoint, 'CrossoverFraction',0.8,'MutationFcn',{@mutationgaussian,0.4},'MigrationFraction',0.5,'EliteCount',5,'StallGenLimit',50,'TolFun',0,'PlotFcns',{ @gaplotbestf,@gaplotscores},'populationsize',200,'Generations',200,'TimeLimit',400,'Display','iter')
sorry for my English.
best regard.