schrum2 / MM-NEAT

Modular Multiobjective (Hyper) Neuro-Evolution of Augmenting Topologies + MAP-Elites: Java code for evolving intelligent agents in Ms. Pac-Man, Tetris, and more, as well as code for Procedural Content Generation in Mario, Zelda, Minecraft, and more!
http://people.southwestern.edu/~schrum2/re/mm-neat.php
Other
50 stars 20 forks source link

MOME Synchronization issue between logging and adding #934

Open JoannaBlatt opened 1 year ago

JoannaBlatt commented 1 year ago

When adding a new candidate if the bin does not exist it will be added as empty. If another thread is in logging (archive synchronized) it might pull the empty bin in methods that cannot deal with that and this can stall the program. This only happens when a new bin is made. If the whole add method is archive synchronized it seems to fix the issue. If you add the new bin right before replacing the bin within a synchronized(archive) it seems to fix the issue (ran 10 times without issue). If you do that with synchronized(this) it does not fix the issue.

Attempting to fix by having conditional statements related to subpopInBin assignment, adding the new bin right before replacement, and using synchronized(archive).

JoannaBlatt commented 1 year ago

Does the new bin even need to go through all the pareto front related code? Could simply have a synchronized section and add it right away.

schrum2 commented 1 year ago

I like how adding to a newly created bin/front is handled differently now. That definitely makes sense, and is simpler.

I am still quite skeptical about the decision to use synchronized (archive) instead of synchronized(this) in MOMEArchive, but I suppose we can just monitor the situation for now.

You indicated you did some tests with both options, but that synchronized (archive) seemingly led to deadlock. Is there anything to elaborate there? Just want to make sure we're tracking the details.

Will leave this issue open a bit longer, but if things seem fine, we'll close it.

JoannaBlatt commented 1 year ago

When using synchronize(this) outside the synchronized subpop it seems to work correctly. When using synchronize(subpopInBin) and then using synchronize(this) inside it does not work. Using synchronize(archive) inside synchronize(subpopInBin) seems to work.