本文整理汇总了Java中org.cpsolver.coursett.Constants.SLOT_LENGTH_MIN属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.SLOT_LENGTH_MIN属性的具体用法?Java Constants.SLOT_LENGTH_MIN怎么用?Java Constants.SLOT_LENGTH_MIN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.cpsolver.coursett.Constants
的用法示例。
在下文中一共展示了Constants.SLOT_LENGTH_MIN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: distance
public int distance(DistanceMetric m, Section s1, Section s2) {
if (s1.getPlacement()==null || s2.getPlacement()==null) return 0;
TimeLocation t1 = s1.getTime();
TimeLocation t2 = s2.getTime();
if (!t1.shareDays(t2) || !t1.shareWeeks(t2)) return 0;
int a1 = t1.getStartSlot(), a2 = t2.getStartSlot();
if (m.doComputeDistanceConflictsBetweenNonBTBClasses()) {
if (a1 + t1.getNrSlotsPerMeeting() <= a2) {
int dist = Placement.getDistanceInMinutes(m, s1.getPlacement(), s2.getPlacement());
if (dist > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (a2 - a1 - t1.getLength()))
return dist;
}
} else {
if (a1+t1.getNrSlotsPerMeeting()==a2)
return Placement.getDistanceInMinutes(m, s1.getPlacement(), s2.getPlacement());
}
return 0;
}
示例2: getDistanceInMinutes
public int getDistanceInMinutes(XSection other, DistanceMetric m) {
if (getNrRooms() == 0 || other.getNrRooms() == 0) return 0;
XTime t1 = getTime();
XTime t2 = other.getTime();
if (t1 == null || t2 == null || !t1.shareDays(t2) || !t1.shareWeeks(t2)) return 0;
int a1 = t1.getSlot(), a2 = t2.getSlot();
if (m.doComputeDistanceConflictsBetweenNonBTBClasses()) {
if (a1 + t1.getLength() <= a2) {
int dist = getDistanceInMinutes(m, other.getRooms());
if (dist > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (a2 - a1 - t1.getLength()))
return dist;
}
} else {
if (a1 + t1.getLength() == a2)
return getDistanceInMinutes(m, other.getRooms());
}
return 0;
}
示例3: BreakFlexibleConstraint
/**
*
* @param id constraint unique id
* @param owner identifier of distribution preference the constraint was created for
* @param preference time preference ("R" for required, "P" for prohibited, "-2",
* "-1", "1", "2" for soft preference)
* @param reference parameters of the constraint in String form
*/
public BreakFlexibleConstraint(Long id, String owner, String preference, String reference) {
super(id, owner, preference, reference);
Pattern pattern = null;
Matcher matcher = null;
// recognize Break constraint
String patternString = "_(Break):([0-9]+):([0-9]+):([0-9]+)_";
pattern = Pattern.compile(patternString);
matcher = pattern.matcher(reference);
if (matcher.find()) {
iBreakStart = Integer.parseInt(matcher.group(2));
iBreakEnd = Integer.parseInt(matcher.group(3));
iBreakLength = Integer.parseInt(matcher.group(4))/Constants.SLOT_LENGTH_MIN;
iConstraintType = FlexibleConstraintType.BREAK;
}
}
示例4: MaxBlockFlexibleConstraint
/**
*
* @param id constraint unique id
* @param owner identifier of distribution preference the constraint was created for
* @param preference time preference ("R" for required, "P" for prohibited, "-2",
* "-1", "1", "2" for soft preference)
* @param reference parameters of the constraint in String form
*/
public MaxBlockFlexibleConstraint(Long id, String owner, String preference, String reference) {
super(id, owner, preference, reference);
Pattern pattern = null;
Matcher matcher = null;
// recognize Break constraint
String patternString = "_(MaxBlock):([0-9]+):([0-9]+)_";
pattern = Pattern.compile(patternString);
matcher = pattern.matcher(reference);
if (matcher.find()) {
iMaxBlockSlotsBTB = Integer.parseInt(matcher.group(2))/Constants.SLOT_LENGTH_MIN;
iMaxBreakBetweenBTB = Integer.parseInt(matcher.group(3))/Constants.SLOT_LENGTH_MIN;
iConstraintType = FlexibleConstraint.FlexibleConstraintType.MAXBLOCK_BACKTOBACK;
}
}
示例5: isAvailable
public boolean isAvailable(Lecture lecture, Placement placement) {
if (iUnavailabilities == null) return true;
TimeLocation t1 = placement.getTimeLocation();
for (Placement c: iUnavailabilities) {
if (c.getTimeLocation().hasIntersection(placement.getTimeLocation()) && (!lecture.canShareRoom(c.variable()) || !placement.sameRooms(c)))
return false;
if (!iIgnoreDistances) {
TimeLocation t2 = c.getTimeLocation();
if (t1.shareDays(t2) && t1.shareWeeks(t2)) {
if (t1.getStartSlot() + t1.getLength() == t2.getStartSlot() || t2.getStartSlot() + t2.getLength() == t1.getStartSlot()) {
if (Placement.getDistanceInMeters(getDistanceMetric(), placement, c) > getDistanceMetric().getInstructorProhibitedLimit())
return false;
} else if (getDistanceMetric().doComputeDistanceConflictsBetweenNonBTBClasses()) {
if (t1.getStartSlot() + t1.getLength() < t2.getStartSlot()) {
if (Placement.getDistanceInMinutes(getDistanceMetric(), placement, c) > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (t2.getStartSlot() - t1.getStartSlot() - t1.getLength()))
return false;
} else if (t2.getStartSlot() + t2.getLength() < t1.getStartSlot()) {
if (Placement.getDistanceInMinutes(getDistanceMetric(), placement, c) > t2.getBreakTime() + Constants.SLOT_LENGTH_MIN * (t1.getStartSlot() - t2.getStartSlot() - t2.getLength()))
return false;
}
}
}
}
}
return true;
}
示例6: distance
public static boolean distance(DistanceMetric m, Placement p1, Placement p2) {
if (m == null && p1 != null) m = ((TimetableModel)p1.variable().getModel()).getDistanceMetric();
if (m == null && p2 != null) m = ((TimetableModel)p2.variable().getModel()).getDistanceMetric();
if (p1 == null || p2 == null || m == null) return false;
if (p1.variable().isCommitted() && p2.variable().isCommitted()) return false;
TimeLocation t1 = p1.getTimeLocation(), t2 = p2.getTimeLocation();
if (!t1.shareDays(t2) || !t1.shareWeeks(t2)) return false;
if (m.doComputeDistanceConflictsBetweenNonBTBClasses()) {
if (t1.getStartSlot() + t1.getLength() <= t2.getStartSlot()) {
return Placement.getDistanceInMinutes(m, p1, p2) > t1.getBreakTime() + Constants.SLOT_LENGTH_MIN * (t2.getStartSlot() - t1.getStartSlot() - t1.getLength());
} else if (t2.getStartSlot() + t2.getLength() <= t1.getStartSlot()) {
return Placement.getDistanceInMinutes(m, p1, p2) > t2.getBreakTime() + Constants.SLOT_LENGTH_MIN * (t1.getStartSlot() - t2.getStartSlot() - t2.getLength());
}
} else {
if (t1.getStartSlot() + t1.getLength() == t2.getStartSlot()) {
return Placement.getDistanceInMinutes(m, p1, p2) > t1.getBreakTime();
} else if (t2.getStartSlot() + t2.getLength() == t1.getStartSlot()) {
return Placement.getDistanceInMinutes(m, p1, p2) > t2.getBreakTime();
}
}
return false;
}
示例7: getTimeString
public static String getTimeString(int slot, int breakTime) {
int min = slot * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN - breakTime;
int h = min / 60;
int m = min % 60;
if (CFG.useAmPm())
return (h > 12 ? h - 12 : h) + ":" + (m < 10 ? "0" : "") + m + (h >= 12 ? "p" : "a");
else
return h + ":" + (m < 10 ? "0" : "") + m;
}
示例8: 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
}
示例9: MaxHolesFlexibleConstraint
public MaxHolesFlexibleConstraint(Long id, String owner, String preference, String reference) {
super(id, owner, preference, reference);
Matcher matcher = Pattern.compile(FlexibleConstraintType.MAX_HOLES.getPattern()).matcher(reference);
if (matcher.find()) {
iMaxHolesOnADay = Integer.parseInt(matcher.group(2)) / Constants.SLOT_LENGTH_MIN;
iConstraintType = FlexibleConstraintType.MAX_HOLES;
}
}
示例10: MaxBreaksFlexibleConstraint
public MaxBreaksFlexibleConstraint(Long id, String owner, String preference, String reference) {
super(id, owner, preference, reference);
Matcher matcher = Pattern.compile(FlexibleConstraintType.MAX_BREAKS.getPattern()).matcher(reference);
if (matcher.find()) {
iMaxBlocksOnADay = 1 + Integer.parseInt(matcher.group(2));
iMaxBreakBetweenBTB = Integer.parseInt(matcher.group(3)) / Constants.SLOT_LENGTH_MIN;
iConstraintType = FlexibleConstraintType.MAX_BREAKS;
}
}
示例11: getStartTimeHeader
/** Start time for printing purposes
* @param useAmPm use 12-hour format
* @return time header (e.g., 7:30a)
**/
public String getStartTimeHeader(boolean useAmPm) {
int min = iStartSlot * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN;
int h = min / 60;
int m = min % 60;
if (useAmPm)
return (h > 12 ? h - 12 : h) + ":" + (m < 10 ? "0" : "") + m + (h >= 12 ? "p" : "a");
else
return h + ":" + (m < 10 ? "0" : "") + m;
}
示例12: getEndTimeHeader
/** End time for printing purposes
* @param useAmPm use 12-hour format
* @return end time (e.g., 8:20a)
**/
public String getEndTimeHeader(boolean useAmPm) {
int min = (iStartSlot + iLength) * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN - getBreakTime();
int m = min % 60;
int h = min / 60;
if (useAmPm)
return (h > 12 ? h - 12 : h) + ":" + (m < 10 ? "0" : "") + m + (h >= 12 ? "p" : "a");
else
return h + ":" + (m < 10 ? "0" : "") + m;
}
示例13: getEndTimeHeaderNoAdj
/** End time for printing purposes
* @param useAmPm use 12-hour format
* @return end time not counting break time (e.g., 8:30a)
**/
public String getEndTimeHeaderNoAdj(boolean useAmPm) {
int min = (iStartSlot + iLength) * Constants.SLOT_LENGTH_MIN + Constants.FIRST_SLOT_TIME_MIN;
int m = min % 60;
int h = min / 60;
if (useAmPm)
return (h > 12 ? h - 12 : h) + ":" + (m < 10 ? "0" : "") + m + (h >= 12 ? "p" : "a");
else
return h + ":" + (m < 10 ? "0" : "") + m;
}
示例14: 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
}
示例15: slot2time
protected String slot2time(int slot) {
int minutesSinceMidnight = Constants.SLOT_LENGTH_MIN * slot + Constants.FIRST_SLOT_TIME_MIN;
return sTwoNumbersDF.format(minutesSinceMidnight / 60) + sTwoNumbersDF.format(minutesSinceMidnight % 60);
}