4 import java.util.ArrayList;
8 * Implementation of the Simple Mapping algorithm (no fault tolerance mechanism)
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.
32 * @param _gr Application graph to be mapped on
33 * @param _gd Grid graph
35 public Simple( Graph _gr, Grid _gd )
46 private ArrayList<GNode> sortInitGNode()
48 ArrayList<GNode> grn = null ;
52 grn = new ArrayList<GNode>() ;
54 // Sorting clusters according to their "size"
55 ArrayList<Cluster> cl = gl.getClusters() ;
56 ArrayList<Cluster> cl2 = new ArrayList<Cluster>() ;
62 while( cl2.size() != gl.getNbCluster() )
67 for( int i = 0 ; i < cl.size() ; i++ )
70 if( c.getNbGNode() > max )
73 max = c.getNbGNode() ;
81 for( int i = 0 ; i < cl2.size() ; i++ )
83 Cluster tmp = cl2.get( i ) ;
85 for( int j = 0 ; j < tmp.getNbGNode() ; j++ )
87 grn.add( tmp.getGNodes().get( j ) ) ;
99 /* If the mapping is possible ... */
100 if( gr.getNbGTask() <= gl.getNbGNode() )
102 archi = sortInitGNode() ;
103 atraiter = gr.getGraph() ;
105 System.out.println( "******************************************" ) ;
106 System.out.println( "* Launching the Simple Mapping algorithm *" ) ;
107 System.out.println( "******************************************\n\n" ) ;
109 /** Save the Mapping **/
110 for( int i = 0 ; i < atraiter.size() ; i++ )
112 mp.addMapping( new Association( archi.get( i ), atraiter.get( i ) ) ) ;
116 System.err.println( "\n\n!!! Unable to map application !\n\n" ) ;
123 public GNode replaceNode(GNode _dead, ArrayList<GNode> _ag )
130 pos = mp.getIdOfAssociation( _dead ) ;
134 System.err.println( "GNode "+_dead+" does not exist in the mapping!" ) ;
144 System.err.println( "Not enought available nodes in gnodes to replace one !" ) ;
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 !! **/