islands

79 views
Skip to first unread message

gutompf

unread,
Aug 17, 2010, 8:29:33 AM8/17/10
to Watchmaker Framework for Evolutionary Computation
Hi.
I succesfully implemented my problem with Generational GA with
Watchmaker. Then I tryied islands and it crash. I want just ask - when
I use islands there are by default using different threads for
islands? If so it means, that my fitness function can run more then
once in a moment? If so is there some way how to avoid this? I have
this reasons for this:
1.I am calling some windows dll during fitness evaluation, and it
cannot run it more than once in moment (I am using JNA library for
this).
2. Second reason - I am newcomer to Java (I am learning it about 1
month) and I do not know how to work with threads.

So is there some way how to supress threads, or how to force threads
to wait while all other threads finish?
Thanks,
Milan

Daniel Dyer

unread,
Aug 17, 2010, 8:53:30 AM8/17/10
to Watchmaker Framework for Evolutionary Computation
On Aug 17, 1:29 pm, gutompf <zmazma...@gmail.com> wrote:
> Hi.
> I succesfully implemented my problem with Generational GA with
> Watchmaker. Then I tryied islands and it crash.

What happens exactly? Do you have a stack-trace?

> I want just ask - when
> I use islands there are by default using different threads for
> islands? If so it means, that my fitness function can run more then
> once in a moment?

Yes. By default the same fitness evaluator object is shared between
all islands and each island has its own individual thread. For
evaluators that are not thread-safe there is a way to work around
this, you can use the other constructor for the IslandEvolution class
and create each island yourself, providing a different instance of the
fitness evaluator. However, in your case it won't solve the problem
if the native library is not thread safe.

> If so is there some way how to avoid this?

At the moment, I don't think there is a way to change this behaviour
without modifying the evolve method of the IslandEvolution class.
While it would be possible to evolve the islands in sequence, it kind
of goes against the parallel nature of island evolution.

Probably the best approach for your specific problem is to put some
kind of synchronisation/lock around the call into the native code so
that it can only be accessed by one thread at a time. This will
become a bottleneck for the application but it won't be any slower
than converting the whole thing to be single-threaded. In fact, it
may be a bit faster because at least the evolutionary operators can
work in parallel.

> I have
> this reasons for this:
> 1.I am calling some windows dll during fitness evaluation, and it
> cannot run it more than once in moment (I am using JNA library for
> this).
> 2. Second reason - I am newcomer to Java (I am learning it about 1
> month) and I do not know how to work with threads.
>
> So is there some way how to supress threads, or how to force threads
> to wait while all other threads finish?

Easiest way is to just do this:

synchronized (lock)
{
callToNativeCode();
}

where lock is some final class field

private final lock = new Object();

You could use the Java 5 lock classes, but it doesn't really add
anything in this case.

Dan.

Daniel Dyer

unread,
Aug 17, 2010, 8:58:13 AM8/17/10
to Watchmaker Framework for Evolutionary Computation
On Aug 17, 1:53 pm, Daniel Dyer <d...@uncommons.org> wrote:
> Easiest way is to just do this:
>
>    synchronized (lock)
>    {
>        callToNativeCode();
>    }
>
> where lock is some final class field
>
>    private final lock = new Object();
>

Or even more simply, you could just declare the whole getFitness
method to be synchronized. Usually I avoid synchronized methods, and
if you are doing anything else in there other than the native call it
will be less efficient, but it is the most straightforward change,
just add one keyword to your code.

public synchronized double getFitness(....

Dan.

Milan Cisty

unread,
Aug 17, 2010, 9:30:16 AM8/17/10
to watch...@googlegroups.com
Thanks. I did something in code for fitness evaluation and it seems work now.
But I do not know how exactly implement Evolution Observer when I have islands
- is it in some example? Sory maybe this is trivial question, but if possible
for you to let me know I appreciate it - I am really Java begginer.
Milan

Daniel Dyer

unread,
Aug 17, 2010, 9:48:14 AM8/17/10
to Watchmaker Framework for Evolutionary Computation
On Aug 17, 2:30 pm, "Milan Cisty" <milan.ci...@stuba.sk> wrote:
> Thanks. I did something in code for fitness evaluation and it seems work now.
> But I do not know how exactly implement Evolution Observer when I have islands

For islands you should implement the IslandEvolutionObserver
interface, rather than the simple EvolutionObserver interface that you
would have used previously. This island-specific interface has two
methods that you have to implement. One is called at the end of a
generation on each island, and the other is called at the end of an
epoch (i.e. after each migration). You might not be interested in
both types of notification, in which case you can leave one of the
methods empty.

Dan.

Leandro Hattori

unread,
Jun 20, 2013, 2:13:56 PM6/20/13
to watch...@googlegroups.com
Hi, I'm using the framework watchmaker. What is the topology that uses the island model?

Daniel Dyer

unread,
Jun 20, 2013, 4:29:32 PM6/20/13
to watch...@googlegroups.com
On Thu, 20 Jun 2013 19:13:56 +0100, Leandro Hattori
<leandrotak...@gmail.com> wrote:

> Hi, I'm using the framework watchmaker. What is the topology that uses
> the
> island model?

I'm not sure what you are asking. What "topology" are you referring to?

Dan.

--
Daniel Dyer

Leandro Hattori

unread,
Jun 21, 2013, 11:36:08 AM6/21/13
to watch...@googlegroups.com
I wonder what is the deployment topology Islands Model watchmaker. Because there are some types that I could search, eg, web, ring and star.

2013/6/20 Daniel Dyer <d...@dandyer.co.uk>
On Thu, 20 Jun 2013 19:13:56 +0100, Leandro Hattori <leandrotakeshihattori@gmail.com> wrote:

Hi, I'm using the framework watchmaker. What is the topology that uses the
island model?

I'm not sure what you are asking.  What "topology" are you referring to?

Dan.

--
Daniel Dyer


--
You received this message because you are subscribed to a topic in the Google Groups "Watchmaker Framework for Evolutionary Computation" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/watchmaker/3DRWgyJI06c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to watchmaker+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.





--


klaas hoelscher

unread,
Jun 21, 2013, 11:44:46 AM6/21/13
to watch...@googlegroups.com

Hey,
Topolgy as the way how the Islands are aligned and exchange oft individuals is possible?  E.g. ring arrangement, each Island may exchange with 2 neighboring Islands (if bidirectional exchange is possible)

Regards,
Klaas

You received this message because you are subscribed to the Google Groups "Watchmaker Framework for Evolutionary Computation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watchmaker+...@googlegroups.com.

Bruno Nunes

unread,
Mar 17, 2015, 8:32:22 AM3/17/15
to watch...@googlegroups.com
I have the same question, what type of topology is used in the islands Model in the watchmaker? It´s unidirectional ring topology or bidirectional topology ring ?  


Em sexta-feira, 21 de junho de 2013 12:44:46 UTC-3, Klaas Hölscher escreveu:

Hey,
Topolgy as the way how the Islands are aligned and exchange oft individuals is possible?  E.g. ring arrangement, each Island may exchange with 2 neighboring Islands (if bidirectional exchange is possible)

Regards,
Klaas

Am 21.06.2013 17:36 schrieb "Leandro Hattori" <leandrotak...@gmail.com>:
I wonder what is the deployment topology Islands Model watchmaker. Because there are some types that I could search, eg, web, ring and star.

2013/6/20 Daniel Dyer <d...@dandyer.co.uk>
On Thu, 20 Jun 2013 19:13:56 +0100, Leandro Hattori <leandrotak...@gmail.com> wrote:

Hi, I'm using the framework watchmaker. What is the topology that uses the
island model?

I'm not sure what you are asking.  What "topology" are you referring to?

Dan.

--
Daniel Dyer


--
You received this message because you are subscribed to a topic in the Google Groups "Watchmaker Framework for Evolutionary Computation" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/watchmaker/3DRWgyJI06c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to watchmaker+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


Klaas Hölscher

unread,
Mar 20, 2015, 9:47:47 AM3/20/15
to watch...@googlegroups.com
Hey Bruno,

i actually looked this up in the source code. The constructor IslandEvolution takes a parameter for Migration, availaby is either:
RandomMigration
* Migrates a fixed number of candidates away from each island. Which individuals are migrated is determined * randomly and which islands they move to is also random. If the migration count is greater than one, it is * possible (probable) that migrants from the same island will be moved to different islands. It is also possible
  * that when a migrant's destination is randomly chosen, it gets sent back to the island that it came from.

RingMigration
     * Migrates a fixed number of individuals from each island to the adjacent island.
* Operates as if the islands are arranged in a ring with migration occurring in a
* clockwise direction. The individuals to be migrated are chosen completely at random.


regards, Klaas

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages