本文整理汇总了Java中org.cpsolver.studentsct.model.SctAssignment.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java SctAssignment.getTime方法的具体用法?Java SctAssignment.getTime怎么用?Java SctAssignment.getTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.cpsolver.studentsct.model.SctAssignment
的用法示例。
在下文中一共展示了SctAssignment.getTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
/**
* Check for overlapping sections that are attended by the same student
* @param a current assignment
* @return false, if there is such a case
*/
public boolean check(Assignment<Request, Enrollment> a) {
sLog.info("Checking for overlaps...");
boolean ret = true;
for (Student student : getModel().getStudents()) {
HashMap<TimeLocation, SctAssignment> times = new HashMap<TimeLocation, SctAssignment>();
for (Request request : student.getRequests()) {
Enrollment enrollment = a.getValue(request);
if (enrollment == null)
continue;
for (SctAssignment assignment : enrollment.getAssignments()) {
if (assignment.getTime() == null)
continue;
for (TimeLocation time: times.keySet()) {
if (time.hasIntersection(assignment.getTime())) {
sLog.error("Student " + student + " assignment " + assignment + " overlaps with "
+ times.get(time));
ret = false;
}
}
times.put(assignment.getTime(), assignment);
}
}
}
return ret;
}
示例2: enrollment2string
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
/**
* Convert given enrollment to a string (comma separated list of subpart
* names and time assignments only)
*/
private static String enrollment2string(Enrollment enrollment) {
StringBuffer sb = new StringBuffer();
Collection<SctAssignment> assignments = enrollment.getAssignments();
if (enrollment.isCourseRequest()) {
assignments = new TreeSet<SctAssignment>(new Comparator<SctAssignment>() {
@Override
public int compare(SctAssignment a1, SctAssignment a2) {
Section s1 = (Section) a1;
Section s2 = (Section) a2;
return s1.getSubpart().compareTo(s2.getSubpart());
}
});
assignments.addAll(enrollment.getAssignments());
}
for (Iterator<? extends SctAssignment> i = assignments.iterator(); i.hasNext();) {
SctAssignment a = i.next();
if (a instanceof Section)
sb.append(((Section) a).getSubpart().getName() + " ");
if (a.getTime() != null)
sb.append(a.getTime().getLongName(true));
if (i.hasNext())
sb.append(", ");
}
return sb.toString();
}
示例3: isOverlappingFreeTime
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
public boolean isOverlappingFreeTime(FreeTimeRequest request, Enrollment e) {
if (request.getTime() == null || e.isAllowOverlap()) return false;
for (SctAssignment assignment : e.getAssignments())
if (!assignment.isAllowOverlap() && assignment.getTime() != null && request.getTime().hasIntersection(assignment.getTime()))
return true;
return false;
}
示例4: inConflict
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
public boolean inConflict(SctAssignment a1, SctAssignment a2, boolean ignoreBreakTimeConflicts) {
if (a1.getTime() == null || a2.getTime() == null) return false;
if (ignoreBreakTimeConflicts) {
TimeLocation t1 = a1.getTime();
TimeLocation t2 = a2.getTime();
return t1.shareDays(t2) && shareHoursIgnoreBreakTime(t1, t2) && t1.shareWeeks(t2);
} else {
return a1.getTime().hasIntersection(a2.getTime());
}
}
示例5: toProto
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
public static OnlineSectioningLog.Section.Builder toProto(SctAssignment a, Course c, Reservation r) {
OnlineSectioningLog.Section.Builder section = OnlineSectioningLog.Section.newBuilder();
if (a instanceof Section) {
Section s = (Section)a;
section.setClazz(
OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(s.getId())
.setExternalId(c == null ? s.getName() : s.getName(c.getId()))
.setName(s.getName(-1l))
);
section.setSubpart(
OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(s.getSubpart().getId())
.setName(s.getSubpart().getName())
.setExternalId(s.getSubpart().getInstructionalType())
);
if (s.hasInstructors()) {
for (Instructor i: s.getInstructors()) {
OnlineSectioningLog.Entity.Builder instructor = OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(i.getId())
.setName(i.getName());
if (i.getExternalId() != null)
instructor.setExternalId(i.getExternalId());
else if (i.getEmail() != null)
instructor.setExternalId(i.getEmail());
section.addInstructor(instructor);
}
}
}
if (c != null) {
section.setCourse(
OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(c.getId())
.setName(c.getName()));
}
if (a.getTime() != null) {
OnlineSectioningLog.Time.Builder time = OnlineSectioningLog.Time.newBuilder();
time.setDays(a.getTime().getDayCode());
time.setStart(a.getTime().getStartSlot());
time.setLength(a.getTime().getLength());
if (a.getTime().getDatePatternName() != null && !a.getTime().getDatePatternName().isEmpty())
time.setPattern(a.getTime().getDatePatternName());
else if (a instanceof FreeTimeRequest)
time.setPattern("Free Time");
section.setTime(time);
}
if (a.getRooms() != null) {
for (RoomLocation room: a.getRooms()) {
section.addLocation(OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(room.getId())
.setName(room.getName())
);
}
}
if (r != null) {
OnlineSectioningLog.Entity.Builder reservation = OnlineSectioningLog.Entity.newBuilder()
.setUniqueId(r.getId());
if (r instanceof GroupReservation)
reservation.setType(OnlineSectioningLog.Entity.EntityType.GROUP_RESERVATION);
else if (r instanceof IndividualReservation)
reservation.setType(OnlineSectioningLog.Entity.EntityType.INDIVIDUAL_RESERVATION);
else if (r instanceof CurriculumReservation) {
reservation.setType(OnlineSectioningLog.Entity.EntityType.CURRICULUM_RESERVATION);
CurriculumReservation cr = (CurriculumReservation)r;
reservation.setName(cr.getAcademicArea() + (cr.getClassifications().isEmpty() ? "" : " " + cr.getClassifications()) + (cr.getMajors().isEmpty() ? "" : cr.getMajors()));
} else if (r instanceof CourseReservation)
reservation.setType(OnlineSectioningLog.Entity.EntityType.RESERVATION);
section.setReservation(reservation);
}
return section;
}
示例6: inConflict
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
/**
* Return true if the given two assignments are overlapping.
*
* @param a1
* an assignment
* @param a2
* an assignment
* @return true, if the given sections are in an overlapping conflict
*/
public boolean inConflict(SctAssignment a1, SctAssignment a2) {
if (a1.getTime() == null || a2.getTime() == null) return false;
if (a1 instanceof Section && a2 instanceof Section && ((Section)a1).isToIgnoreStudentConflictsWith(a2.getId())) return false;
return a1.getTime().hasIntersection(a2.getTime());
}
示例7: getPenalty
import org.cpsolver.studentsct.model.SctAssignment; //导入方法依赖的package包/类
/**
* Return penalty of an assignment. It is a penalty of its time (see
* {@link SctAssignment#getTime()}) or zero if the time is null.
* @param assignment section assignment
* @return penalty
*/
public double getPenalty(SctAssignment assignment) {
return (assignment.getTime() == null ? 0.0 : getPenalty(assignment.getTime()));
}