es.udc.gii.common.eaf.algorithm.parallel.topology.migration
Class MigrationTopology

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
      extended by es.udc.gii.common.eaf.algorithm.parallel.topology.migration.MigrationTopology
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
FullConnectedMigrationTopology, GridMigrationTopology

public abstract class MigrationTopology
extends Topology

A migration topology is a topology that encapsulates the comunication between islands in an island model (parallel evolutionary algorithm).

A migration operator uses an instance of this class to perform the necessary communication among islands making use of the send(es.udc.gii.common.eaf.algorithm.parallel.topology.migration.MigrationObject) and receive() methods.

This is an abstract class, so it can not be directly used. Instead, some subclasses are provided and the user can code their own. Subclasses of this class are responsible for populating the protected atributes from Topology and may optionally override de protected methods doSend(es.udc.gii.common.eaf.algorithm.parallel.topology.migration.MigrationObject) and doReceive() in order to change the behaviour of the send(es.udc.gii.common.eaf.algorithm.parallel.topology.migration.MigrationObject) and receive() methods. However, a default implementation of the protected methods is given.

Since:
1.0
Author:
Grupo Integrado de IngenierĂ­a (www.gii.udc.es)

Field Summary
private  java.util.Map<mpi.Request,MigrationObject[]> pendingRecvRequest
           
private  java.util.Map<mpi.Request,MigrationObject[]> pendingSendRequest
           
private static int TAG
          Tag used for sending and receiving.
 
Fields inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
communicator, receivers, senders, topologyRank
 
Constructor Summary
MigrationTopology()
           
MigrationTopology(int races)
           
 
Method Summary
private  void addRecvRequest(mpi.Request request, MigrationObject[] migrant)
           
private  void addSendRequest(mpi.Request request, MigrationObject[] migrant)
           
protected  java.util.List<MigrationObject> doReceive()
          Each subclass can implement the receive method accordingly.
protected  void doSend(MigrationObject migrant)
          Each subclass can implement the send method accordingly.
 void finish()
          Cleans up this topology by finalizing all pending communications.
 java.util.List<MigrationObject> receive()
          Receives a list of MigrationObject from the senders.
 void send(MigrationObject migrant)
          Sends a MigrationObject to the receivers.
private  java.util.List<MigrationObject> testRecvRequests()
           
private  void testSendRequests()
           
 
Methods inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
configure, doConfigure, doConfigure, doInitialize, getCommunicator, getRaces, getReceivers, getSenders, getSize, getTopologyRank, initialize, isConnected, isInitialized, setInitialized, setRaces, synchronize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pendingSendRequest

private java.util.Map<mpi.Request,MigrationObject[]> pendingSendRequest

pendingRecvRequest

private java.util.Map<mpi.Request,MigrationObject[]> pendingRecvRequest

TAG

private static final int TAG
Tag used for sending and receiving.

See Also:
Constant Field Values
Constructor Detail

MigrationTopology

public MigrationTopology()

MigrationTopology

public MigrationTopology(int races)
Method Detail

testSendRequests

private void testSendRequests()

addSendRequest

private void addSendRequest(mpi.Request request,
                            MigrationObject[] migrant)

testRecvRequests

private java.util.List<MigrationObject> testRecvRequests()

addRecvRequest

private void addRecvRequest(mpi.Request request,
                            MigrationObject[] migrant)

doSend

protected void doSend(MigrationObject migrant)
Each subclass can implement the send method accordingly.


send

public void send(MigrationObject migrant)
Sends a MigrationObject to the receivers. It is a nonblocking send.


doReceive

protected java.util.List<MigrationObject> doReceive()
Each subclass can implement the receive method accordingly.


receive

public java.util.List<MigrationObject> receive()
Receives a list of MigrationObject from the senders. It is a nonblocking receive. If no message has arrived, an empty list is returned.


finish

public void finish()
Cleans up this topology by finalizing all pending communications. This method must be called when the topology is not need anymore.