当前位置: 首页>>代码示例>>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;未经允许,请勿转载。