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


Java Constants.sPreferenceLevelRequired方法代碼示例

本文整理匯總了Java中org.cpsolver.coursett.Constants.sPreferenceLevelRequired方法的典型用法代碼示例。如果您正苦於以下問題:Java Constants.sPreferenceLevelRequired方法的具體用法?Java Constants.sPreferenceLevelRequired怎麽用?Java Constants.sPreferenceLevelRequired使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.cpsolver.coursett.Constants的用法示例。


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

示例1: getMinMaxRoomPreference

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
public int[] getMinMaxRoomPreference() {
    iLock.readLock().lock();
    try {
        if (iMinMaxRoomPreference != null) return iMinMaxRoomPreference;
    } finally {
        iLock.readLock().unlock();
    }
    iLock.writeLock().lock();
    try {
        if (iMinMaxRoomPreference != null) return iMinMaxRoomPreference;

        if (getNrRooms() <= 0 || roomLocations().isEmpty()) {
            iMinMaxRoomPreference = new int[] { 0, 0 };
        } else {
            Integer minRoomPref = null, maxRoomPref = null;
            for (RoomLocation r : roomLocations()) {
                int pref = r.getPreference();
                if (pref >= Constants.sPreferenceLevelRequired / 2 && pref <= Constants.sPreferenceLevelProhibited / 2) {
                    minRoomPref = (minRoomPref == null ? pref : Math.min(minRoomPref, pref));
                    maxRoomPref = (maxRoomPref == null ? pref : Math.max(maxRoomPref, pref));
                }
            }
            iMinMaxRoomPreference = new int[] { minRoomPref == null ? 0 : minRoomPref, maxRoomPref == null ? 0 : maxRoomPref };
        }

        return iMinMaxRoomPreference;
    } finally {
        iLock.writeLock().unlock();
    }
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:31,代碼來源:Lecture.java

示例2: getMinMaxTimePreference

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
public double[] getMinMaxTimePreference() {
    iLock.readLock().lock();
    try {
        if (iMinMaxTimePreference != null) return iMinMaxTimePreference;
    } finally {
        iLock.readLock().unlock();
    }
    iLock.writeLock().lock();
    try {
        if (iMinMaxTimePreference != null) return iMinMaxTimePreference;

        Double minTimePref = null, maxTimePref = null;
        for (TimeLocation t : timeLocations()) {
            double npref = t.getNormalizedPreference();
            int pref = t.getPreference();
            if (pref >= Constants.sPreferenceLevelRequired / 2 && pref <= Constants.sPreferenceLevelProhibited / 2) {
                minTimePref = (minTimePref == null ? npref : Math.min(minTimePref, npref));
                maxTimePref = (maxTimePref == null ? npref : Math.max(maxTimePref, npref));
            }
        }
        iMinMaxTimePreference = new double[] { minTimePref == null ? 0.0 : minTimePref, maxTimePref == null ? 0.0 : maxTimePref };
        
        return iMinMaxTimePreference;
    } finally {
        iLock.writeLock().unlock();
    }
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:28,代碼來源:Lecture.java

示例3: getTimePenalty

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
public double getTimePenalty() {
    if (iTimeLocation == null) return 0.0;
    if (iTimePenalty == null) {
        double[] bounds = variable().getMinMaxTimePreference();
        double npref = iTimeLocation.getNormalizedPreference();
        if (iTimeLocation.getPreference() < Constants.sPreferenceLevelRequired / 2) npref = bounds[0];
        else if (iTimeLocation.getPreference() > Constants.sPreferenceLevelProhibited / 2) npref = bounds[1];
        iTimePenalty = npref - bounds[0];
    }
    return iTimePenalty;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:12,代碼來源:Placement.java

示例4: getRoomPenalty

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
public int getRoomPenalty() {
    if (getNrRooms() == 0) return 0;
    if (iRoomPenalty == null) {
        int pref = getRoomPreference();
        int[] bounds = variable().getMinMaxRoomPreference();
        if (pref < Constants.sPreferenceLevelRequired / 2) pref = bounds[0];
        if (pref > Constants.sPreferenceLevelProhibited / 2) pref = bounds[1];
        iRoomPenalty = pref - bounds[0];
    }
    return iRoomPenalty;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:12,代碼來源:Placement.java

示例5: string2preference

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
/** Convert preference string to a preference value */
protected static int string2preference(String pref) {
    if (pref == null || pref.isEmpty()) return 0;
    if (Constants.sPreferenceRequired.equals(pref))
        return Constants.sPreferenceLevelRequired;
    if (Constants.sPreferenceProhibited.equals(pref))
        return Constants.sPreferenceLevelProhibited;
    return Integer.valueOf(pref);
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:10,代碼來源:InstructorSchedulingModel.java

示例6: isRequired

import org.cpsolver.coursett.Constants; //導入方法依賴的package包/類
/**
 * Is required?
 * @return true if the preference is required
 */
public boolean isRequired() { return iPreference < Constants.sPreferenceLevelRequired / 2; }
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:6,代碼來源:Preference.java


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