本文整理汇总了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;
}
示例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;
}