Skip to content

whatisinternet/GeneticAlgorithms-py

Repository files navigation

GeneticAlgorithms-py

Usage

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)

Install Python

Instructions here

Install PIP (the python package manager):

Instructions here

Install dependencies

    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.

Running:

    echo False > debug
    python example.py

Redirecting output

    echo False > debug
    python example.py > test.txt

Testing:

Set debug to false by modifying the debug file in the root directory contain any string other than True

Install nose (requires PIP)

    [sudo] pip install nose

Running the tests:

    echo False > debug
    nosetests

with coverage information

    echo False > debug
    nosetests --with-coverage --cover-html

Automatic testing during development

Install Ruby 2.2.3, bundler, guard, and guard shell

    gem install bundler
  • To install guard and guard shell
    bundle install
  • Running guard
    echo False > debug
    guard

Charting / Debugging:

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

Style:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •