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


Java Constants.SLOTS_PER_DAY屬性代碼示例

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


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

示例1: setNotAvailable

@SuppressWarnings("unchecked")
public void setNotAvailable(Placement placement) {
    if (iAvailable == null) {
        iAvailable = new List[Constants.SLOTS_PER_DAY * Constants.NR_DAYS];
        for (int i = 0; i < iAvailable.length; i++)
            iAvailable[i] = null;
    }
    for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements();) {
        int slot = e.nextElement();
        if (iAvailable[slot] == null)
            iAvailable[slot] = new ArrayList<Placement>(1);
        iAvailable[slot].add(placement);
    }
    for (Lecture lecture: variables())
        lecture.clearValueCache();
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:16,代碼來源:RoomConstraint.java

示例2: getMaxPenalty

public int getMaxPenalty(Assignment<Lecture, Placement> assignment, Placement placement) {
    SpreadConstraintContext context = getContext(assignment);
    int penalty = 0;
    for (Enumeration<Integer> e = placement.getTimeLocation().getSlots(); e.hasMoreElements();) {
        int slot = e.nextElement();
        int day = slot / Constants.SLOTS_PER_DAY;
        int time = slot % Constants.SLOTS_PER_DAY;
        if (time < iFirstDaySlot || time > iLastDaySlot)
            continue;
        if (iLastWorkDay < 7) {
            if (day < iFirstWorkDay || day > iLastWorkDay)
                continue;
        } else {
            if (day < iFirstWorkDay && day > iLastWorkDay - 7)
                continue;
            if (day < iFirstWorkDay) day += 7;
        }
        int dif = 1 + context.getNrCourses(time, day, placement) - context.getMaxCourses(time, day);
        if (dif > penalty)
            penalty = dif;
    }
    return penalty;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:23,代碼來源:SpreadConstraint.java

示例3: countUselessSlotsHalfHours

/** Number of useless half hours for this room 
 * @param rc room constraint assignment context
 * @param placement placement that is being considered
 * @return number of useless slots caused by the given placement
 **/
protected static int countUselessSlotsHalfHours(RoomConstraintContext rc, Placement placement) {
    int ret = 0;
    TimeLocation time = placement.getTimeLocation();
    int slot = time.getStartSlot() % Constants.SLOTS_PER_DAY;
    int days = time.getDayCode();
    for (int d = 0; d < Constants.NR_DAYS; d++) {
        if ((Constants.DAY_CODES[d] & days) == 0)
            continue;
        if (isUselessBefore(rc, d * Constants.SLOTS_PER_DAY + slot - 6, placement))
            ret ++;
        if (isUselessAfter(rc, d * Constants.SLOTS_PER_DAY + slot + time.getNrSlotsPerMeeting(), placement))
            ret ++;
        if (time.getNrSlotsPerMeeting() == 6 && isUseless(rc, d * Constants.SLOTS_PER_DAY + slot, placement))
            ret --;
    }
    return ret;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:22,代碼來源:UselessHalfHours.java

示例4: time

public static int time(int slot) {
    int s = slot % Constants.SLOTS_PER_DAY;
    int min = (s * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN);
    if (min < 450) return 0; // morning
    int idx = 1 + (min - 450) / 60;
    return (idx > 11 ? 11 : idx); // 11+ is evening
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:7,代碼來源:OnlineSectioningTest.java

示例5: isBackToBackTooFar

public boolean isBackToBackTooFar(Placement p1, Placement p2) {
    if (!p1.getTimeLocation().shareDays(p2.getTimeLocation()))
        return false;
    if (!p1.getTimeLocation().shareWeeks(p2.getTimeLocation()))
        return false;
    int s1 = p1.getTimeLocation().getStartSlot() % Constants.SLOTS_PER_DAY;
    int s2 = p2.getTimeLocation().getStartSlot() % Constants.SLOTS_PER_DAY;
    if (s1 + p1.getTimeLocation().getLength() != s2 && s2 + p2.getTimeLocation().getLength() != s1)
        return false;
    double distance = Placement.getDistanceInMeters(iDistanceMetric, p1, p2);
    return (distance > iDistanceMetric.getInstructorProhibitedLimit());
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:12,代碼來源:FixCourseTimetablingInconsistencies.java

示例6: sameHours

private static boolean sameHours(int start1, int len1, int start2, int len2) {
    if (len1 > len2)
        return sameHours(start2, len2, start1, len1);
    start1 %= Constants.SLOTS_PER_DAY;
    start2 %= Constants.SLOTS_PER_DAY;
    return (start1 >= start2 && start1 + len1 <= start2 + len2);
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:7,代碼來源:GroupConstraint.java

示例7: time

/**
 * Return time index in
 * {@link StudentPreferencePenalties#sStudentRequestDistribution} for the
 * given slot.
 * @param slot time slot
 * @return time index
 */
public static int time(int slot) {
    int s = slot % Constants.SLOTS_PER_DAY;
    int min = (s * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN);
    if (min < 450)
        return 0; // morning
    int idx = 1 + (min - 450) / 60;
    return (idx > 11 ? 11 : idx); // 11+ is evening
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:15,代碼來源:StudentPreferencePenalties.java

示例8: isUselessAfter

private static boolean isUselessAfter(RoomConstraintContext rc, int slot, Placement placement) {
    int s = slot % Constants.SLOTS_PER_DAY;
    if (s - 1 < 0 || s + 6 >= Constants.SLOTS_PER_DAY)
        return false;
    return (isEmpty(rc, slot - 1, placement) &&
            isEmpty(rc, slot + 0, placement) &&
            isEmpty(rc, slot + 1, placement) &&
            isEmpty(rc, slot + 2, placement) &&
            isEmpty(rc, slot + 3, placement) &&
            isEmpty(rc, slot + 4, placement) &&
            isEmpty(rc, slot + 5, placement) &&
            !isEmpty(rc, slot + 6, placement));
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:13,代碼來源:UselessHalfHours.java

示例9: isUseless

private static boolean isUseless(RoomConstraintContext rc, int slot) {
    int s = slot % Constants.SLOTS_PER_DAY;
    if (s - 1 < 0 || s + 6 >= Constants.SLOTS_PER_DAY)
        return false;
    return (!rc.getPlacements(slot - 1).isEmpty() &&
            rc.getPlacements(slot + 0).isEmpty() &&
            rc.getPlacements(slot + 1).isEmpty() &&
            rc.getPlacements(slot + 2).isEmpty() &&
            rc.getPlacements(slot + 3).isEmpty() &&
            rc.getPlacements(slot + 4).isEmpty() &&
            rc.getPlacements(slot + 5).isEmpty() &&
            !rc.getPlacements(slot + 6).isEmpty());
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:13,代碼來源:UselessHalfHours.java

示例10: getValue

@Override
public double getValue(Assignment<Lecture, Placement> assignment, Placement value, Set<Placement> conflicts) {
    double ret = 0.0;
    if (value.getTimeLocation().getStartSlot() <= iLunchEnd && value.getTimeLocation().getStartSlot() + value.getTimeLocation().getLength() > iLunchStart) {
        InstructorLunchBreakContext context = (InstructorLunchBreakContext)getContext(assignment);
        for (InstructorConstraint constraint: value.variable().getInstructorConstraints()) {
            InstructorConstraintContext icx = constraint.getContext(assignment);
            CompactInfo compactInfo = context.getCompactInfo(constraint);
            for (int i = 0; i < Constants.NR_DAYS; i++) {
                // checks only days affected by the placement
                if ((value.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0) {
                    int currentLunchStartSlot = Constants.SLOTS_PER_DAY * i + iLunchStart;
                    int currentLunchEndSlot = Constants.SLOTS_PER_DAY * i + iLunchEnd;
                    int semesterViolations = 0;
                    for (BitSet week : getWeeks()) {
                        int maxBreak = 0;
                        int currentBreak = 0;
                        for (int slot = currentLunchStartSlot; slot < currentLunchEndSlot; slot++) {
                            if (isEmpty(icx, slot, week, value)) {
                                currentBreak++;
                                if (maxBreak < currentBreak) {
                                    maxBreak = currentBreak;
                                }
                            } else {
                                currentBreak = 0;
                            }
                        }
                        if (maxBreak < iLunchLength) {
                            semesterViolations++;
                        }
                    }
                    // add the difference to the result
                    ret += semesterViolations - compactInfo.getLunchDayViolations()[i];
                }
            }
        }
    }
    return ret;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:39,代碼來源:InstructorLunchBreak.java

示例11: updateLunchPenalty

/**
 * Method updates number of violations in days (Mo, Tue, Wed,..) considering
 * each week in the semester separately. The current number of violations
 * for a day is stored in the CompactInfo.lunchDayViolations of the
 * constraint, which must be set properly before the calling of the method.
 * 
 * @param assignment current assignment 
 * @param constraint
 *            the Instructor constraint of an instructor checked for a lunch
 *            break
 * @param p
 *            placement of a lecture currently (un)assigned
 */
public void updateLunchPenalty(Assignment<Lecture, Placement> assignment, InstructorConstraint constraint, Placement p) {
    // checks only placements in the lunch time
    if (p.getTimeLocation().getStartSlot() <= iLunchEnd && p.getTimeLocation().getStartSlot() + p.getTimeLocation().getLength() > iLunchStart) {
        CompactInfo compactInfo = getCompactInfo(constraint);
        for (int i = 0; i < Constants.NR_DAYS; i++) {
            // checks only days affected by the placement
            if ((p.getTimeLocation().getDayCode() & Constants.DAY_CODES[i]) != 0) {
                int currentLunchStartSlot = Constants.SLOTS_PER_DAY * i + iLunchStart;
                int currentLunchEndSlot = Constants.SLOTS_PER_DAY * i + iLunchEnd;
                int semesterViolations = 0;
                for (BitSet week : getWeeks()) {
                    int maxBreak = 0;
                    int currentBreak = 0;
                    for (int slot = currentLunchStartSlot; slot < currentLunchEndSlot; slot++) {
                        if (constraint.getContext(assignment).getPlacements(slot, week).isEmpty()) {
                            currentBreak++;
                            if (maxBreak < currentBreak) {
                                maxBreak = currentBreak;
                            }
                        } else {
                            currentBreak = 0;
                        }
                    }
                    if (maxBreak < iLunchLength) {
                        semesterViolations++;
                    }
                }
                // saving the result in the CompactInfo of the
                // InstructorConstraint
                compactInfo.getLunchDayViolations()[i] = semesterViolations;
            }
        }
    }
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:47,代碼來源:InstructorLunchBreak.java

示例12: computeLunchPenalty

/**
 * Method computes number of violations in days (Mo, Tue, Wed,..) considering
 * each week in the semester separately. Updates the compact infos accordingly.
 * @param assignment current assignment 
 * @param constraint instructor constraint
 * @return current penalty for the given instructor
 */
public double computeLunchPenalty(Assignment<Lecture, Placement> assignment, InstructorConstraint constraint) {
    double violations = 0d;
    CompactInfo compactInfo = getCompactInfo(constraint);
    for (int i = 0; i < Constants.NR_DAYS; i++) {
        int currentLunchStartSlot = Constants.SLOTS_PER_DAY * i + iLunchStart;
        int currentLunchEndSlot = Constants.SLOTS_PER_DAY * i + iLunchEnd;
        int semesterViolations = 0;
        for (BitSet week : getWeeks()) {
            int maxBreak = 0;
            int currentBreak = 0;
            for (int slot = currentLunchStartSlot; slot < currentLunchEndSlot; slot++) {
                if (constraint.getContext(assignment).getPlacements(slot, week).isEmpty()) {
                    currentBreak++;
                    if (maxBreak < currentBreak) {
                        maxBreak = currentBreak;
                    }
                } else {
                    currentBreak = 0;
                }
            }
            if (maxBreak < iLunchLength) {
                semesterViolations++;
            }
        }
        // saving the result in the CompactInfo of the
        // InstructorConstraint
        compactInfo.getLunchDayViolations()[i] = semesterViolations;
        violations += semesterViolations;
    }
    return Math.pow(violations, iMultiplier);
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:38,代碼來源:InstructorLunchBreak.java

示例13: countUselessSlotsBrokenTimePatterns

/** Number of useless slots for this room 
 * @param rc room constraint
 * @return current penalty for the given room
 **/
public static int countUselessSlotsBrokenTimePatterns(RoomConstraintContext rc) {
    int ret = 0;
    for (int d = 0; d < Constants.NR_DAYS; d++) {
        for (int s = 0; s < Constants.SLOTS_PER_DAY; s++) {
            int slot = d * Constants.SLOTS_PER_DAY + s;
            if (rc.getPlacements(slot).isEmpty()) {
                switch (d) {
                    case 0:
                        if (!rc.getPlacements(2 * Constants.SLOTS_PER_DAY + s).isEmpty() && !rc.getPlacements(4 * Constants.SLOTS_PER_DAY + s).isEmpty())
                            ret++;
                        break;
                    case 1:
                        if (!rc.getPlacements(3 * Constants.SLOTS_PER_DAY + s).isEmpty())
                            ret++;
                        break;
                    case 2:
                        if (!rc.getPlacements(0 * Constants.SLOTS_PER_DAY + s).isEmpty() && !rc.getPlacements(4 * Constants.SLOTS_PER_DAY + s).isEmpty())
                            ret++;
                        break;
                    case 3:
                        if (!rc.getPlacements(1 * Constants.SLOTS_PER_DAY + s).isEmpty())
                            ret++;
                        break;
                    case 4:
                        if (!rc.getPlacements(0 * Constants.SLOTS_PER_DAY + s).isEmpty() && !rc.getPlacements(2 * Constants.SLOTS_PER_DAY + s).isEmpty())
                            ret++;
                        break;
                }
            }
        }
    }
    return ret;
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:37,代碼來源:BrokenTimePatterns.java

示例14: getDepartmentId

public Long getDepartmentId(int slot) {
    int day = slot / Constants.SLOTS_PER_DAY;
    int time = (slot % Constants.SLOTS_PER_DAY) / getStep();
    return getDepartmentId(day, time);
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:5,代碼來源:RoomSharingModel.java

示例15: getNrTimes

public int getNrTimes() {
    return Constants.SLOTS_PER_DAY / getStep();
}
 
開發者ID:UniTime,項目名稱:cpsolver,代碼行數:3,代碼來源:RoomSharingModel.java


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