当前位置: 首页>>代码示例>>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;未经允许,请勿转载。