當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。