Assume that we have a canonical island genetic algorithm with the ring topology. I use C++,PPL and MS Visual Studio 2010.

It is convenient to work with parallel_for from PPL library. What program primitives should I use if the island must get the best current individual from its neighbour when the stagnation flag is on? I don't want to check the array of stagnation flags after parallel_for cycle finalization, I want to feed the "hungry" islands on-the-fly. Does PPL have means for this purpose? Each island has a pointer to its neihbour. I need some sort of critical section within Evolve() method for blocking GetBestIndividual() method. Evolve() is called in parallel (parallel_for cycle for islands).

有帮助吗?

解决方案

You can use critical_section object. It's a part of PPL library.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top