private String findHighestUtilizationModuleThatCanScale(double limitWorkload, double[] mus, Solution sol,
         Topology topology, SuitableOptions cloudCharacteristics) {

      double[] workloadsModules = getWorkloadsArray(routes, limitWorkload);

      // calculate the workload received by each core of a module: consider both
      // number of cores
      // of a cloud offer and number of instances for such module
      double[] workloadsModulesByCoresAndNumInstances = weightModuleWorkloadByCoresAndNumInstances(workloadsModules,
            topology, sol, cloudCharacteristics);

      // find upper value
      double[] utilizations = utilizationOfEachModule(workloadsModulesByCoresAndNumInstances, mus);

      int maxUtilizationIndex = -1;
      for (int i = 0; i < utilizations.length; i++) {
         if (topology.getElementIndex(i).canScale()) {// It is a candidate
            if (maxUtilizationIndex == -1) {// choose it directly because it's
                                            // the first one that can scale
               maxUtilizationIndex = i;
            } else {
               if (utilizations[i] > utilizations[maxUtilizationIndex]) {
                  // It could be done as an OR in the previous condition, but
                  // this is
                  // a safe manner as the order in which Java evaluates
                  // disyuntive conditions
                  maxUtilizationIndex = i;
               }
            }
         }
      }

      if (maxUtilizationIndex > -1) {
         return topology.getElementIndex(maxUtilizationIndex).getName();
      } else {
         log.debug("None of the modules can scale. Thresholds cannot be calculated");
         return null;
      }
   }
private String findHighestUtilizationModuleThatCanScale ( double limitWorkload , double [ ] mus , Solution sol , Topology topology , SuitableOptions cloudCharacteristics ) { double [ ] workloadsModules = getWorkloadsArray ( routes , limitWorkload ) ; double [ ] workloadsModulesByCoresAndNumInstances = weightModuleWorkloadByCoresAndNumInstances ( workloadsModules , topology , sol , cloudCharacteristics ) ; double [ ] utilizations = utilizationOfEachModule ( workloadsModulesByCoresAndNumInstances , mus ) ; int maxUtilizationIndex = - 1 ; for ( int i = 0 ; i < utilizations . length ; i ++ ) { if ( topology . getElementIndex ( i ) . canScale ( ) ) { if ( maxUtilizationIndex == - 1 ) { maxUtilizationIndex = i ; } else { if ( utilizations [ i ] > utilizations [ maxUtilizationIndex ] ) { maxUtilizationIndex = i ; } } } } if ( maxUtilizationIndex > - 1 ) { return topology . getElementIndex ( maxUtilizationIndex ) . getName ( ) ; } else { log . debug ( "None of the modules can scale. Thresholds cannot be calculated" ) ; return null ; } }
@param limitWorkload
@param routes
@param mus
@param cloudCharacteristics
@param topology
@param modifSol
@return The name of the module with highest utilization. This method makes
a strong assumption that rows in routes matrix and elements in
topology are in the same order (which should happen if no bugs
were included programming)