All example functions are implemented as lambda functions that are passed into the genetic algorithm function. To see an example see example.py
. To define your own:
def dejong(maximize):
print 'Blackbox: deJongSphere function'
black_box = (lambda x: (reduce(
(lambda r, q: q + x ** 2)), range(4), 0)))
params = {
'objective_function': black_box,
'iterations': 500,
'mutation_probability': 0.01,
"crossover_rate": 0.7,
"constraint_range": range(-5, 5),
"number_of_variables": 1,
"carry_over": 64,
"pool_size": 500,
"target": None,
"max": maximize,
"function_name": "deJong Sphere maximized: {a}".format(a=maximize)
}
genetic_algorithms_py.__init__(params)
pip install -r requirements.txt
Errors?
- If MatPlotLib fails on Linux install the following:
freetype-devel, libpng-devel
and run pip again. If you still have errors you can install from here.
echo False > debug
python example.py
echo False > debug
python example.py > test.txt
Set debug to false by modifying the debug file in the root directory contain any string other than True
[sudo] pip install nose
echo False > debug
nosetests
with coverage information
echo False > debug
nosetests --with-coverage --cover-html
Install Ruby 2.2.3, bundler, guard, and guard shell
-
To install bundler
gem install bundler
- To install guard and guard shell
bundle install
- Running guard
echo False > debug
guard
Set debug to True by modifying the debug file in the root directory contain the string True
Charts will be generated, and charts will be displayed. Pressing enter is required to continue each objective function.
echo True > debug
python example.py
echo False > debug
- See: PEP 0008
- See also: Thoughbot Guides