AnthonyDickson / CartPole-NEAT

CartPole Reinforcement Learning with Neuroevolution of augmenting topologies
MIT License
2 stars 0 forks source link

Program Multithreading #1

Open AnthonyDickson opened 5 years ago

AnthonyDickson commented 5 years ago

For example, on a quad core system one could run four genetic algorithms in parallel and then choose the best of the four.

AnthonyDickson commented 5 years ago

Python's default threading may be sufficient. Tutorial on python threading here. A simple article on parallel and distributed genetic algorithms found here

The general idea of how the program would work:

  1. Driver program is opened with the user specifying how many workers (or threads) are required
  2. Driver forks n worker processes, each being individual genetic algorithm (GA) training loops.
  3. Each worker performs setup such as connecting to the database for recording run statistics and creating the initial population.
  4. Each worker will then perform training from end to end, with the results and fittest individuals ideally being returned on completion.
  5. The driver program then selects the fittest individual from the selection given by the workers.
  6. Driver reports results and then closes and deals with cleanup.
AnthonyDickson commented 5 years ago

Checked cpu core utilisation - it is indeed single-threaded. Could go for the 'island' approach, or go for an approach where the population is divided into chunks and the current episode is simulated (i.e. see how long each pop lasts with current topology/weights) for each chunk on separate threads. With the latter approach the main thread will have to wait for the worker threads to complete before going onto crossover and mutation.

AnthonyDickson commented 5 years ago

Expanding on the 'island' idea, could have creatures migrate between islands.