Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding new functionalities.
[mapping.git] / src / and / Mapping / Grid.java
index 57345cd..2451b95 100644 (file)
@@ -136,13 +136,13 @@ public class Grid implements Serializable
                
                if( cluster1.compareTo( cluster2 ) == 0 )
                {
-                       d = 1 ;
+                       d = 10 ;
                } else {
                        if( site1.compareTo( site2 ) == 0 )
                        {
-                               d = 2 ;
+                               d = 20 ;
                        } else {
-                               d = 3 ;
+                               d = 30 ;
                        }
                }
                
@@ -407,6 +407,7 @@ public class Grid implements Serializable
                return ret ;
        }
        
+       
        /**
         * Compute the heterogeneity degree of the grid.
         * This is based on the relative standard deviation.
@@ -426,24 +427,32 @@ public class Grid implements Serializable
                double average = 0 ;
                double std = 0 ;
                double temp = 0 ;
+               long nb_freenodes = 0 ;
                
                /** Computation of the average power of computing nodes **/
                for( int i = 0 ; i < gnodesList.size() ; i++ )
                {
-                       temp += gnodesList.get(i).getPower() ;
+                       if( ! gnodesList.get(i).getMapped() )
+                       {
+                               temp += gnodesList.get(i).getPower() ;
+                               nb_freenodes++ ;
+                       }
                }
                
-               average = temp / gnodesList.size() ;
+               average = temp / nb_freenodes ; //gnodesList.size() ;
                
                /** Computation of the variance **/
                temp = 0 ;
                for( int i = 0 ; i < gnodesList.size() ; i++ )
                {
-                       temp += Math.pow( ( gnodesList.get(i).getPower() - average ), 2 ) ;
+                       if( ! gnodesList.get(i).getMapped() )
+                       {
+                               temp += Math.pow( ( gnodesList.get(i).getPower() - average ), 2 ) ;
+                       }
                }
                
                /** Computation of the standard deviation **/
-               temp = temp / gnodesList.size() ;
+               temp = temp / nb_freenodes ; //gnodesList.size() ;
                std = Math.sqrt( temp ) ;
                
                /** Computation of the relative standard deviation **/
@@ -459,6 +468,28 @@ public class Grid implements Serializable
                return hd ;
        }
        
+       
+       /**
+        * Return the amount of nodes available in the cluster containing the
+        * maximum of available nodes.
+        * @return The maximum available nodes of the architecture
+        */
+       public int getMaxClusterNode()
+       {
+               int max = 0 ;
+               
+               for( int i = 0 ; i < clusters.size() ; i++ )
+               {
+                       if( max < clusters.get( i ).getNbFreeNodes() )
+                       {
+                               max = clusters.get( i ).getNbFreeNodes() ;
+                       }
+               }
+               
+               return max ;
+       }
+       
+       
        /**
         * Initialization of computing nodes in the grid. Set all
         * of these nodes to be not mapped on, and do the same thing in each