Skip to content

Modified version of a genetic algorithm developed for optimization problems with correlated variables.

License

Notifications You must be signed in to change notification settings

acanbay/modifiedGA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

modifiedGA (mGA)

DOI Binder

This Python module comprises a modified Genetic Algorithm where a new intermediate step, gene variation, is introduced, and a mutation defined by a Gaussian distribution with a standard deviation that adjusts based on the results of each generation. It is capable of optimizing multiple parameters (even in cases of correlation between them - in such instances, it is advisable to maintain a high number of generations).


Mathematical background and performance test: click here


Installation:

Download the latest release, extract it, enter the extracted file, and run the following command via the console.

python setup.py install

Setting the optimization object

mGA = modifiedGA.algorithm( popSize, nGen, nVar, mins, maxs, problem, optimType, info )

Required parameters:

  • popSize : Population size (must be at least 10)
  • nGen : Number of generations
  • nVar : Number of variables
  • mins : Minimum value in the parameter space of possible values for the variables
  • maxs : Maximum value in the parameter space of possible values for the variables
  • problem : The function to be used in optimization

Important

  • The values of mins and maxs should consist of as many as nVar value.
  • The problem should take list of variables as parameters and return the result of the function.

Non-required parameters:

  • seed (integer) : Sets the initial value of the random number generator as a function of the given number. Using the same seed will always yield the same result.
  • optimType : Optimization type - 'minimum' or 'maximum' (defaul value is 'minimum')
    • 'minimum', optimizes the problem to the minimum value.
    • 'maximum', optimizes the problem to the maximum value.
  • info (bool) : Enable or disable showing information during calculation (default value is True).

Optimizing and getting results

results, values = mGA.optimize()

It returns the most optimal result and the parameters associated with this results.


Saving the results

mGA.saveResults( name, graph, xlabel, ylabel, title )

Non-required parameters:

  • name : Name of the file/graph which the results will be written (default value is "results")
  • graph : Specifies whether to create a plot (default value is False)
  • xlabel : Label of the x-axis on the graph (default value is "Generations")
  • ylabel : Label of the y-axis on the graph (default value is "Fitness")
  • title : Title of the graph (default is empty)

Important

The matplotlib module must be installed to plot graphs



About

Modified version of a genetic algorithm developed for optimization problems with correlated variables.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published