當前位置: 首頁>>代碼示例>>Java>>正文


Java Ranking類代碼示例

本文整理匯總了Java中jmetal.util.Ranking的典型用法代碼示例。如果您正苦於以下問題:Java Ranking類的具體用法?Java Ranking怎麽用?Java Ranking使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Ranking類屬於jmetal.util包,在下文中一共展示了Ranking類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import jmetal.util.Ranking; //導入依賴的package包/類
/**
* Performs the operation
* @param object Object representing a SolutionSet.
* @return an object representing a <code>SolutionSet<code> with the selected parents
 * @throws JMException 
*/
@Override
public Object execute (Object object) throws JMException {
  SolutionSet population = (SolutionSet)object;
  int populationSize     = (Integer)parameters_.get("populationSize");
  SolutionSet result     = new SolutionSet(populationSize);
  
  //->Ranking the union
  Ranking ranking = new Ranking(population);                        

  int remain = populationSize;
  int index  = 0;
  SolutionSet front = null;
  population.clear();

  //-> Obtain the next front
  front = ranking.getSubfront(index);

  while ((remain > 0) && (remain >= front.size())){                
    //Asign crowding distance to individuals
    distance_.crowdingDistanceAssignment(front,problem_.getNumberOfObjectives());                
    //Add the individuals of this front
    for (int k = 0; k < front.size(); k++ ) {
      result.add(front.get(k));
    } // for

    //Decrement remaint
    remain = remain - front.size();

    //Obtain the next front
    index++;
    if (remain > 0) {
      front = ranking.getSubfront(index);
    } // if        
  } // while

  //-> remain is less than front(index).size, insert only the best one
  if (remain > 0) {  // front containt individuals to insert                        
    distance_.crowdingDistanceAssignment(front,problem_.getNumberOfObjectives());
    front.sort(crowdingComparator_);
    for (int k = 0; k < remain; k++) {
      result.add(front.get(k));
    } // for

    remain = 0; 
  } // if

  return result;
}
 
開發者ID:organicsmarthome,項目名稱:OSHv2,代碼行數:55,代碼來源:RankingAndCrowdingSelection.java

示例2: execute

import jmetal.util.Ranking; //導入依賴的package包/類
/**
* Performs the operation
* @param object Object representing a SolutionSet.
* @return an object representing a <code>SolutionSet<code> with the selected parents
 * @throws JMException 
*/
public Object execute (Object object) throws JMException {
  SolutionSet population = (SolutionSet)object;
  int populationSize     = (Integer)parameters_.get("populationSize");
  SolutionSet result     = new SolutionSet(populationSize);
  
  //->Ranking the union
  Ranking ranking = new Ranking(population);                        

  int remain = populationSize;
  int index  = 0;
  SolutionSet front = null;
  population.clear();

  //-> Obtain the next front
  front = ranking.getSubfront(index);

  while ((remain > 0) && (remain >= front.size())){                
    //Asign crowding distance to individuals
    distance_.crowdingDistanceAssignment(front,problem_.getNumberOfObjectives());                
    //Add the individuals of this front
    for (int k = 0; k < front.size(); k++ ) {
      result.add(front.get(k));
    } // for

    //Decrement remaint
    remain = remain - front.size();

    //Obtain the next front
    index++;
    if (remain > 0) {
      front = ranking.getSubfront(index);
    } // if        
  } // while

  //-> remain is less than front(index).size, insert only the best one
  if (remain > 0) {  // front containt individuals to insert                        
    distance_.crowdingDistanceAssignment(front,problem_.getNumberOfObjectives());
    front.sort(crowdingComparator_);
    for (int k = 0; k < remain; k++) {
      result.add(front.get(k));
    } // for

    remain = 0; 
  } // if

  return result;
}
 
開發者ID:vpillac,項目名稱:vroom,代碼行數:54,代碼來源:RankingAndCrowdingSelection.java


注:本文中的jmetal.util.Ranking類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。