Confused about current_island_counter
In process_parallel.py, start from line 545:
# Island management
if (
completed_iteration > start_iteration
and current_island_counter >= programs_per_island
):
self.database.next_island()
current_island_counter = 0
logger.debug(f"Switched to island {self.database.current_island}")
current_island_counter += 1
self.database.increment_island_generation()
# Check migration
if self.database.should_migrate():
logger.info(f"Performing migration at iteration {completed_iteration}")
self.database.migrate_programs()
self.database.log_island_status()
I suppose self.database.increment_island_generation() is used to compute how many programs are in a specific island. But ProgramDatabase.current island does not equal to the island that receives a new program. And current_island_counter is also confusing because it does not count anything about 'current island', I even did not see how it trace the current island. If my understanding was not too wrong, the following code should be proper:
# get current program island id
island_id = child_program.metadata.get(
"island", self.database.current_island
)
use this to increment island generation
self.database.increment_island_generation(island_idx=island_id)
The current_island_counter counts how many child programs were successfully generated in the island database.current_island. The self.database.increment_island_generation() simply increments the respective counter in the database.island_generations attribute. In this case, I believe it also equals the number of programs of that island, but these need not be the same in general for genetic algorithms (usually multiple new solutions are created at each new generation). The id of the current island is by default started at 0 in the init of the database class (or according to a given checkpoint). When the self.database.next_island() method is called, this increments the database.current_island (modulo NUM_ISLANDS). I don't think I understood what is the problem you've identified here. If the above clarifications were not enough let me know, but I don't think there's a bug in the logic of the above code (although I agree that some of these methods may obfuscate what the current state is).
@HenriqueAssumpcao Thanks for the reply.
You said 'The current_island_counter counts how many child programs were successfully generated in the island database.current_island.'
But I think the child_program you got here may have parent from any island, thus inherit its island id. So it's not necessarily generated in database.current_island.
Oh I see, I think you are actually correct then. The parent program comes from the first completed future found, and this doesn't need to come from the current island. I think your proposed solution also fixes this. This whole island management logic might be an artifact from the previous sequential version of OpenEvolve.
@HenriqueAssumpcao @lyx1237 thanks for checking I think your fix would help, if you can send a PR I can merge it.