GithubHelp home page GithubHelp logo

pyevolve's People

Contributors

amitsaha avatar bje- avatar booherbg avatar fork-while-fork avatar gwainer avatar lorenzoriano avatar melevir avatar msabramo avatar perone avatar rkbk avatar ronnypfannschmidt avatar senyai avatar tomerf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyevolve's Issues

Thread error

Hi,

I have some trouble using pyevolve's multiprocessing. Specifically, I have issue with threads. This is the error that I get :

...
File "build/bdist.linux-x86_64/egg/pyevolve/GSimpleGA.py", line 824, in evolve
File "build/bdist.linux-x86_64/egg/pyevolve/GSimpleGA.py", line 668, in step
File "build/bdist.linux-x86_64/egg/pyevolve/GPopulation.py", line 365, in evaluate
File "/usr/lib64/python2.7/multiprocessing/init.py", line 232, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild)
File "/usr/lib64/python2.7/multiprocessing/pool.py", line 184, in init
self._result_handler.start()
File "/usr/lib64/python2.7/threading.py", line 746, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

I don't think that my code is involved in this error, but just in case :

eval func =>
def eval_gen(seq):

len_seq = len(seq)
j = 0
state = [0,0,0,0]
pmin = float("+inf")
while j < len_seq and not(is_terminal(state)) :
    a = 5 if seq[j] == 0 else -5 
    state = compute_next_state(a,state)
    cost = d(state)
    if cost <= pmin:
        pmin = cost
    j += 1
return pmin + j

GA =>

ga = GSimpleGA.GSimpleGA(genome,interactiveMode=False)
ga.setGenerations(50)
ga.setMinimax(Consts.minimaxType["minimize"])
ga.setCrossoverRate(0.5)
ga.setMutationRate(0.1)
ga.setPopulationSize(20)
ga.setMultiProcessing(True)
genome.evaluator.set(eval_gen)
ga.evolve()
seq = ga.bestIndividual()

Thanks for you help!

[Possible Bug] GTournamentSelector

Looking at the code of GTournamentSelector, it seems like it is not considering if maximizing or minimizing when selecting from the candidates.

if population.sortType == Consts.sortType["scaled"]:
choosen = max(tournament_pool, key=key_fitness_score)
else:
choosen = max(tournament_pool, key=key_raw_score)

Since in GASimpleGA.py to use elitism it considers the min/max param, it seems like this one should do it as well and use min instead if minimizing.

G1DListCrossoverOX fails with AssertionError

Here is sample code:

        mom = G1DList(3)
        mom.genomeList = [1, 2, 3]
        dad = G1DList(3)
        dad.genomeList = [4, 5, 6]
        Crossovers.G1DListCrossoverOX(None, mom=mom, dad=dad, count=1)

It fails with AssertionError in pyevolve/Crossovers.py, line 216, assert listSize == len(sister) (first is 3, second is 4).

Please tag releases

Hi,
it would help a lot to tell the user community about production quality releases if you would consider tagging released versions. In Debian we would observe what you consider release quality code.
Thanks a lot for considering, Andreas.

what's the scaling module?

I want to use the Pyevolve in python3, and the I download the package follow the Pull request instruction #79 then I find the bug, what can I do ?

Traceback (most recent call last):
File "setup.py", line 2, in
from pyevolve import version, author
File "/mnt/e/sub/Pyevolve-master/Pyevolve-master/pyevolve/init.py", line 22, in
import pyevolve.Consts
File "/mnt/e/sub/Pyevolve-master/Pyevolve-master/pyevolve/Consts.py", line 369, in
import Scaling
ModuleNotFoundError: No module named 'Scaling`

[Question] Elitism

How does the elitism work in this project ? The elite subject is copied to the next generation or is used as a parent? I'm asking because when I set the elitism in True, I expected to see always the same minium fitnes over the generations, but is not the case.

Use new style classes

Now all classes in the project are old-style classes:

class ClassName:
    pass

Better option is to use new-style classes:

class ClassName(object):
    pass

Old style classes has different MRO, different syntax and so on.
Actually, there is no reason to use old-style classes (http://stackoverflow.com/questions/54867/)

Multiprocessing spawning lots of processes

Report by Billy Earney:

I'm trying to execute my evaluation functions in parallel, but several when I do this, pyevolve creates many processes that are not terminated automatically. I have to kill them myself. A few test runs produced over 200 zombie processes..

Below is a URL to a script I downloaded, and when I execute it, I get the same result (many processes are created). I've also downloaded the the source from the git repository, just in case this was a bug that has been fixed recently.

http://pyevolve.sourceforge.net/wordpress/?tag=parallel

Here's the basic info about the version of python and pyevolve I'm using:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pyevolve
pyevolve.version
'0.6'

Refactor mutators

There is a lot of copy-paste since all mutators works pretty much the same way.
Since mutators are covered with tests, they can (and must) be refactored.

automated tests?

it would be nice to get automated tests

if there is no-one against it' i would like to start using pyt.est on my own changes

Implement a resume mechanism

Currently, Pyevolve doesn't have a resume mechanism where the user can stop the algorithm and re-start again later from the point it stopped.

Performance micro optimizations

The code can certain use some very small performance changes, which after summing up all changes it should improve performance slightly.
I'm talking about thinks like, use correct structures, more pytonic code, etc..

For example:

Using a list for just TWO elements: cuts = [rand_randint(1, len(gMom)-1), rand_randint(1, len(gMom)-1)]
Might be better just having two separate vars or a tuple.
This is in Crossovers

return True if rand_random() <= p else False in Util.py. Like really? Could be just return rand_random() <= p

Do not re calculate lengths every time, if you are planning on using len(something) many times, assign it to a variable first and then use it.

Define functions that are used in big loops, as a local variable, since doing var1.var2.somefunc on a loop is expensive due to look ups every time.

[Bug] GSimpleGA and Selectors.GTournamentSelector

Having the following:

ga = GSimpleGA.GSimpleGA(genome)
ga.selector.set(Selectors.GTournamentSelector)

There 'tournamentPool' is not working.

I have added it on both, the genome:
genome = G1DList.G1DList(N)
genome.setParams(rangemin=0,
rangemax=2,
tournamentPool = 5
)

And ga.setParams(tournamentPool = 5)

However when GTournamentSelector tries to get that param, it can't find anywhere. I have debugged the code and it is quite messy, the same get/set operations are in GenomeBase, GPopulation, and GSimpleGA, some params are fetched from one class, some from others, you don't really know where to set each one of them.

Specify node chilren in GTreeNode

GTreeNodeBase.__init__ method accepts childs argument, but it's inheritor GTreeNode overloads __init__ without this argument.
GTreeNode.__init__ method must be changed to allow this.

Refactor crossovers

Now they accept one argument mandatory argument - genome - and args, but genome is not used. It should explicitly take mom and dad arguments.

Elitism Implementation - criteria for carryover

The elitism implementation seems a little strange to me. It looks like it's comparing the best in the current generation with the best in the previous generation, the 2nd best in the current generation with the 2nd best in the previous generation, etc. one-by-one. Thus it seems possible that the top candidate from the previous generation is not carried over (not better than the best in the current generation) but the second best candidate from the previous is carried over (better than the 2nd best in the current generation). But, I might also be reading the code incorrectly.

Delete commented code

There are some commented code in the project and it shouldn't be there since we are using git. It should be deleted.

Using random.sample() in TournamentSelectorAlternative

You might consider providing an option for using random.sample() to choose candidates for tournament selection. In my experience it's much faster, plus it won't pick duplicate candidates.

The code would look like:
tournament_pool = random.sample(population, pool_size)

Add a list of papers to the documentation

Add a list of papers citing the main SIGEVOlution paper to the documentation. People can use it to know how PyEvolve is being used in research. Also links to code/research groups that uses PyEvolve will be useful, so people will know who's using PyEvolve and how.

Move documentation from code to documentation module

Sphinx docs are great, but there are to many of them. I mean, look: 10 lines of code and 20 lines of docs - ordinary case in the project.
This dramatically reduces maintainability - to many scrolling per action rate.
Good idea is to keep small doc strings where it's required and move other info to docs/ folder.
Doctests are not a problem also since we have unit tests now.

Need to join/close processing pool

The version of pyevolve available through pip doesn't join or close the processing pool in GPopulation.evaluate(). This results in an EXPLOSION of RAM usage, so much so that it becomes almost unusable when the multiprocessing flag is True.

The current code on the master branch appears to fix this issue, all that needs to be done is to update the code available in the repos. I think that this is a big enough issue that it merits a new patch.

-- Eric

PyEvolve crashing with "list index out of range" when using multiprocessing

I'm running PyEvolve on a computer with 72 CPU cores. I've got a relatively complex objective function, that runs without issue without multiprocessing. The objective function uses the Threading module to run an external Fortran program three times for each individual of the population (the individual is a set of options for the program, and I'm trying to find options that will yield a certain result). The score is then based on results from the Fortran program, which are parsed in the objective function from an output log file. The Pyevolve GA settings themselves are relatively standard.

Here's the problem: if I run the GA with a population that is either close to 72 or larger than 72, PyEvolve crashes when evaluating the first finished population, giving the following message:

  File "/home/PERSONAL/raskar/programs/pyevolve_git/pyevolve/GSimpleGA.py", line 777, in evolve
    self.internalPop.evaluate()
  File "/home/PERSONAL/raskar/programs/pyevolve_git/pyevolve/GPopulation.py", line 393, in evaluate
    results = proc_pool.map(multiprocessing_eval_full, self.internalPop)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 250, in map
    return self.map_async(func, iterable, chunksize).get()
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 554, in get
    raise self._value
IndexError: list index out of range

Unfortunately, I have a large space to search, so it is probably necessary to use a large population.

The error seems similar to the one reported previously here:
https://groups.google.com/forum/#!topic/pyevolve/lPWq_rHEe8M

A fix was suggested there, by Simon Liddington:

I have found that if I modify evaluate() in GPopulation.py to use a
chunksize that means each CPU is given one chunk then it works:
proc_pool.map(multiprocessing_eval, self.internalPop, 1 +
(len(self.internalPop) / CPU_COUNT))

However, making this change doesn't fix my problem.

I'm using the latest git version of pyevolve.

Does anyone have any idea about what might be causing this problem, and what can be done to fix it?

[Question] Mutation

The Mutators.G1DListMutatorIntegerRange only seems to accept one mutation probability, which seems like it is the one that decides if a value on the chromosome should be mutated or not.

However, shouldn't be there also another probability that defines if the mutation should be applied at all or not? I think that's how other libraries work but I have no idea if that's an improvement or not.

Refactor examples

We need to fix the examples in the trunk of the development version to reflect the new 0.6 version.
The TSP really needs an entire refactoring.

Scaling became scaling

import Scaling

ERROR: Command errored out with exit status 1:
 command: 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\acarlton\\AppData\\Local\\Temp\\pip-install-vow2i4bj\\pyevolve\\setup.py'"'"'; __file__='"'"'C:\\Users\\acarlton\\AppData\\Local\\Temp\\pip-install-vow2i4bj\\pyevolve\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\acarlton\AppData\Local\Temp\pip-install-vow2i4bj\pyevolve\pip-egg-info'
     cwd: C:\Users\acarlton\AppData\Local\Temp\pip-install-vow2i4bj\pyevolve\
Complete output (9 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\acarlton\AppData\Local\Temp\pip-install-vow2i4bj\pyevolve\setup.py", line 2, in <module>
    from pyevolve import __version__, __author__
  File "C:\Users\acarlton\AppData\Local\Temp\pip-install-vow2i4bj\pyevolve\pyevolve\__init__.py", line 22, in <module>
    import pyevolve.Consts
  File "C:\Users\acarlton\AppData\Local\Temp\pip-install-vow2i4bj\pyevolve\pyevolve\Consts.py", line 369, in <module>
    import Scaling
ModuleNotFoundError: No module named 'Scaling'
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Configure Travis CI and coveralls

Since we have tests now, it make sense for robots tot launch them, not humans.
Its free and highly recommended since everyone will see that the project is stable (or not).
Add coveralls (https://coveralls.io) to CI cycle is great idea to - we'll be able to monitor coverage of the project (and pull requests)!

[Question] Default setElitismReplacement value

Any thoughts on why the default number for number of individuals to be replaced is set so "low" at 1 individual (out of a default population of 80?). Wouldn't a higher default number lead to improved performance for most cases "out-of-the-box"?

Weights bug

Need to clear the weights list in clear() ~ line 116 in FunctionSlot.py, ex.

del self.funcWeights[:]

[Bug] Selectors.GTournamentSelectorAlternative causes a crash.

Selectors.GTournamentSelectorAlternative causes a crash.

"Gen. 0 (0.00%): Max/Min/Avg Fitness(Raw) [0.00(0.00)/0.00(0.00)/0.00(0.00)]
Traceback (most recent call last):
File "C:\Users\Cristiano\Desktop\ej1\ej1.py", line 143, in
ga.evolve(freq_stats=GENERATIONS / 10)
File "C:\Python27\lib\site-packages\pyevolve\GSimpleGA.py", line 824, in evolv
e
if self.step(): break #exit if the number of generations is equal to the max
. number of gens.
File "C:\Python27\lib\site-packages\pyevolve\GSimpleGA.py", line 630, in step
crossover_empty = self.select(popID=self.currentGeneration).crossover.isEmpt
y()
AttributeError: 'NoneType' object has no attribute 'crossover'
"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.