4 import java.util.ArrayList;
8 * Implementation of Simple Mapping algorithm
9 * @author Sébastien Miquée
12 public class Simple extends Algo
14 private static final long serialVersionUID = 1L;
17 private ArrayList<GTask> atraiter ;
18 private ArrayList<GNode> archi ;
21 * Default constructor.
31 * @param _gr Application graph to be mapped on
32 * @param _gd Grid graph
34 public Simple( Graph _gr, Grid _gd )
43 private ArrayList<GNode> sortInitGNode()
45 ArrayList<GNode> grn = null ;
49 grn = new ArrayList<GNode>() ;
51 // Tri des clusters suivant leur taille
52 ArrayList<Cluster> cl = gl.getClusters() ;
53 ArrayList<Cluster> cl2 = new ArrayList<Cluster>() ;
59 while( cl2.size() != gl.getNbCluster() )
64 for( int i = 0 ; i < cl.size() ; i++ )
67 if( c.getNbGNode() > max )
70 max = c.getNbGNode() ;
78 for( int i = 0 ; i < cl2.size() ; i++ )
80 Cluster tmp = cl2.get( i ) ;
82 for( int j = 0 ; j < tmp.getNbGNode() ; j++ )
84 grn.add( tmp.getGNodes().get( j ) ) ;
96 /* If the mapping is possible ... */
97 if( gr.getNbGTask() <= gl.getNbGNode() )
99 archi = sortInitGNode() ;
100 atraiter = gr.getGraph() ;
102 System.out.println( "******************************************" ) ;
103 System.out.println( "* Launching the Simple Mapping algorithm *" ) ;
104 System.out.println( "******************************************\n\n" ) ;
106 /** Save the Mapping **/
107 for( int i = 0 ; i < atraiter.size() ; i++ )
109 mp.addMapping( new Association( archi.get( i ), atraiter.get( i ) ) ) ;
113 System.err.println( "\n\n!!! Unable to map application !\n\n" ) ;
116 /** Update in cluster the status of nodes **/
122 public GNode replaceNode(GNode _dead, ArrayList<GNode> _ag )
129 pos = mp.getIdOfAssociation( _dead ) ;
133 System.err.println( "GNode "+_dead+" does not exist in the mapping!" ) ;
143 System.err.println( "Not enought available nodes in gnodes to replace one !" ) ;
148 /** Update in cluster the status of nodes **/
156 public GNode getOtherGNode( ArrayList<GNode> _ag )
158 /** Returning the first node in the list **/
161 return _ag.get( 1 ) ;
170 /** La programmation est un art, respectons ceux qui la pratiquent !! **/