当前位置: 首页>>代码示例>>Java>>正文


Java RouletteWheelSelection类代码示例

本文整理汇总了Java中org.cpsolver.ifs.heuristics.RouletteWheelSelection的典型用法代码示例。如果您正苦于以下问题:Java RouletteWheelSelection类的具体用法?Java RouletteWheelSelection怎么用?Java RouletteWheelSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RouletteWheelSelection类属于org.cpsolver.ifs.heuristics包,在下文中一共展示了RouletteWheelSelection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRoulette

import org.cpsolver.ifs.heuristics.RouletteWheelSelection; //导入依赖的package包/类
/** Populate roulette wheel selection, if null or empty. 
 * @param solution current solution
 * @return selection
 **/
protected RouletteWheelSelection<Request> getRoulette(Solution<Request, Enrollment> solution) {
    if (iRoulette != null && iRoulette.hasMoreElements()) {
        if (iRoulette.getUsedPoints() < 0.1 * iRoulette.getTotalPoints())
            return iRoulette;
    }
    iRoulette = new RouletteWheelSelection<Request>();
    for (Request request : ((StudentSectioningModel) solution.getModel()).variables()) {
        double points = 0;
        if (solution.getAssignment().getValue(request) == null)
            points += 10;
        else {
            Enrollment enrollment = solution.getAssignment().getValue(request);
            if (enrollment.toDouble(solution.getAssignment()) > request.getBound())
                points += 1;
        }
        if (points > 0)
            iRoulette.add(request, points);
    }
    return iRoulette;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:25,代码来源:RouletteWheelRequestSelection.java

示例2: StudentPreferencePenalties

import org.cpsolver.ifs.heuristics.RouletteWheelSelection; //导入依赖的package包/类
public StudentPreferencePenalties(DistType disributionType) {
    RouletteWheelSelection<int[]> roulette = new RouletteWheelSelection<int[]>();
    for (int d = 0; d < sStudentRequestDistribution.length; d++)
        for (int t = 0; t < sStudentRequestDistribution[d].length; t++) {
        	switch (disributionType) {
        	case Uniform:
        		roulette.add(new int[] { d, t }, 1);
        		break;
        	case Preference:
                roulette.add(new int[] { d, t }, sStudentRequestDistribution[d][t]);
                break;
        	case PreferenceQuadratic:
                roulette.add(new int[] { d, t }, sStudentRequestDistribution[d][t] * sStudentRequestDistribution[d][t]);
                break;
        	case PreferenceReverse:
                roulette.add(new int[] { d, t }, 11 - sStudentRequestDistribution[d][t]);
                break;
            default:
                roulette.add(new int[] { d, t }, 1);
                break;
            }
        }
    int idx = 0;
    while (roulette.hasMoreElements()) {
        int[] dt = roulette.nextElement();
        iWeight.put(dt[0] + "." + dt[1], new Double(((double) idx) / (roulette.size() - 1)));
        idx++;
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:30,代码来源:OnlineSectioningTest.java

示例3: StudentPreferencePenalties

import org.cpsolver.ifs.heuristics.RouletteWheelSelection; //导入依赖的package包/类
/**
 * Constructor. All possible times are ordered based on the distribution
 * defined by {@link StudentPreferencePenalties#sStudentRequestDistribution}
 * . The first time gets zero penalty, the second 1/nrTimes, the third
 * 2/nrTimes etc. where nrTimes is the number of times in
 * {@link StudentPreferencePenalties#sStudentRequestDistribution}.
 * @param disributionType distribution type
 */
public StudentPreferencePenalties(int disributionType) {
    RouletteWheelSelection<int[]> roulette = new RouletteWheelSelection<int[]>();
    for (int d = 0; d < sStudentRequestDistribution.length; d++)
        for (int t = 0; t < sStudentRequestDistribution[d].length; t++) {
            if (disributionType == sDistTypeUniform) {
                roulette.add(new int[] { d, t }, 1);
            } else if (disributionType == sDistTypePreference) {
                roulette.add(new int[] { d, t }, sStudentRequestDistribution[d][t]);
            } else if (disributionType == sDistTypePreferenceQuadratic) {
                roulette.add(new int[] { d, t }, sStudentRequestDistribution[d][t]
                        * sStudentRequestDistribution[d][t]);
            } else if (disributionType == sDistTypePreferenceReverse) {
                roulette.add(new int[] { d, t }, 11 - sStudentRequestDistribution[d][t]);
            } else {
                roulette.add(new int[] { d, t }, 1);
            }
        }
    int idx = 0;
    while (roulette.hasMoreElements()) {
        int[] dt = roulette.nextElement();
        iWeight.put(dt[0] + "." + dt[1], new Double(((double) idx) / (roulette.size() - 1)));
        if (sDebug)
            sLog.debug("  -- " + (idx + 1) + ". preference is " + toString(dt[0], dt[1]) + " (P:"
                    + sDF.format(((double) idx) / (roulette.size() - 1)) + ")");
        idx++;
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:36,代码来源:StudentPreferencePenalties.java


注:本文中的org.cpsolver.ifs.heuristics.RouletteWheelSelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。