Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding some new functions.
[mapping.git] / src / and / Mapping / Mapping.java
index c6c4060..9429df4 100644 (file)
@@ -59,9 +59,17 @@ public class Mapping implements Serializable
                }
                
                /** For the usage of algorithms which map groups of tasks on cluster **/
+               GNode tmp = null ;
                for( int i = 0 ; i < at.size() ; i++ )
                {
-                       insertMapping( new Association( c.nextGNode(), at.get( i ) ) ) ;
+                       tmp = c.nextGNode() ;
+                       if( tmp != null )
+                       {
+                               insertMapping( new Association( tmp, at.get( i ) ) ) ;
+                       } else {
+                               System.err.println( "Error during reception of the next GNode !" ) ;
+                               break ;
+                       }
                }
        }
        
@@ -92,9 +100,10 @@ public class Mapping implements Serializable
        {
                if( _a != null && _a.getGNode() != null && _a.getGTask() != null )
                {
-                       int ind = _a.getGTask().getNum() ;
-                       
-                       mapping.add( ind - 1, _a ) ;
+//                     int ind = _a.getGTask().getNum() ;
+//                     
+//                     mapping.add( ind - 1, _a ) ;
+                       mapping.add( _a ) ;
                }
        }
        
@@ -180,7 +189,7 @@ public class Mapping implements Serializable
        public void print()
        {
                System.out.println();
-               System.out.println( "\t=> Mapping done :\n" ) ;
+               System.out.println( "\t=> Mapping done:\n" ) ;
                
                if( type == 0 )
                {
@@ -225,6 +234,29 @@ public class Mapping implements Serializable
        }
        
        
+       /**
+        * Return the position of the association containing 
+        * the GNode _g.
+        * @param _g The GNode to be search
+        * @return The position of the association
+        */
+       public int getIdOfAssociation( GNode _g )
+       {
+               int ret = -1 ;
+               
+               for( int i = 0 ; i < mapping.size() ; i++ )
+               {
+                       if( mapping.get( i ).getGNode().getId() == _g.getId() )
+                       {
+                               ret = i ;
+                               break ;
+                       }
+               }
+               
+               return ret ;
+       }
+       
+       
        /**
         * Return the amount of external tasks dependencies, in cluster point of view.
         * @return The amount of external dependencies