本文整理汇总了Java中org.cpsolver.studentsct.model.SctAssignment类的典型用法代码示例。如果您正苦于以下问题:Java SctAssignment类的具体用法?Java SctAssignment怎么用?Java SctAssignment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SctAssignment类属于org.cpsolver.studentsct.model包,在下文中一共展示了SctAssignment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Conflict
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Constructor
*
* @param student
* related student
* @param share number of slots in common between the two conflicting sections
* @param e1 first enrollment
* @param a1
* first conflicting section
* @param e2 second enrollment
* @param a2
* second conflicting section
*/
public Conflict(Student student, int share, Enrollment e1, SctAssignment a1, Enrollment e2, SctAssignment a2) {
iStudent = student;
if (a1.compareById(a2) < 0 ) {
iA1 = a1;
iA2 = a2;
iE1 = e1;
iE2 = e2;
} else {
iA1 = a2;
iA2 = a1;
iE1 = e2;
iE2 = e1;
}
iHashCode = (iStudent.getId() + ":" + iA1.getId() + ":" + iA2.getId()).hashCode();
iShare = share;
}
示例2: allConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* The set of all conflicts ({@link Conflict} objects) of the given
* enrollment and other enrollments that are assigned to the same student.
* @param assignment current assignment
* @param enrollment given enrollment
* @return all conflicts of the given enrollment
*/
public Set<Conflict> allConflicts(Assignment<Request, Enrollment> assignment, Enrollment enrollment) {
Set<Conflict> ret = new HashSet<Conflict>();
if (enrollment.getRequest() instanceof FreeTimeRequest) return ret;
for (Request request : enrollment.getStudent().getRequests()) {
if (request.equals(enrollment.getRequest())) continue;
Enrollment other = assignment.getValue(request);
if (request instanceof FreeTimeRequest) {
FreeTimeRequest ft = (FreeTimeRequest)request;
ret.addAll(conflicts(enrollment, ft.createEnrollment()));
continue;
} else if (other != null) {
ret.addAll(conflicts(enrollment, other));
}
}
for (Unavailability unavailability: enrollment.getStudent().getUnavailabilities())
for (SctAssignment section: enrollment.getAssignments())
if (inConflict(section, unavailability))
ret.add(new Conflict(enrollment.getStudent(), share(section, unavailability), enrollment, section, unavailability.createEnrollment(), unavailability));
return ret;
}
示例3: computeAllConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Compute a set of all time overlapping conflicts ({@link Conflict} objects).
* @param assignment current assignment
* @return set of all time conflicts in the assignment
*/
public Set<Conflict> computeAllConflicts(Assignment<Request, Enrollment> assignment) {
Set<Conflict> ret = new HashSet<Conflict>();
for (Request r1 : getModel().variables()) {
Enrollment e1 = assignment.getValue(r1);
if (e1 == null || r1 instanceof FreeTimeRequest || r1.equals(iOldVariable))
continue;
for (Request r2 : r1.getStudent().getRequests()) {
Enrollment e2 = assignment.getValue(r2);
if (r2 instanceof FreeTimeRequest) {
FreeTimeRequest ft = (FreeTimeRequest)r2;
ret.addAll(conflicts(e1, ft.createEnrollment()));
} else if (e2 != null && r1.getId() < r2.getId() && !r2.equals(iOldVariable)) {
ret.addAll(conflicts(e1, e2));
}
}
for (Unavailability unavailability: e1.getStudent().getUnavailabilities())
for (SctAssignment section: e1.getAssignments())
if (inConflict(section, unavailability))
ret.add(new Conflict(e1.getStudent(), share(section, unavailability), e1, section, unavailability.createEnrollment(), unavailability));
}
return ret;
}
示例4: 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;
}
示例5: 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();
}
示例6: 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;
}
示例7: 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());
}
}
示例8: share
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
public int share(SctAssignment a1, SctAssignment a2, boolean ignoreBreakTimeConflicts) {
if (!inConflict(a1, a2, ignoreBreakTimeConflicts)) return 0;
if (ignoreBreakTimeConflicts) {
return a1.getTime().nrSharedDays(a2.getTime()) * nrSharedHoursIgnoreBreakTime(a1.getTime(), a2.getTime());
} else {
return 5 * a1.getTime().nrSharedDays(a2.getTime()) * a1.getTime().nrSharedHours(a2.getTime());
}
}
示例9: nrConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Return number of time overlapping conflicts that are between two enrollments. It
* is the total share between pairs of assignments of these enrollments that are in a
* time overlap.
*
* @param e1
* an enrollment
* @param e2
* an enrollment
* @return number of time overlapping conflict between given enrollments
*/
public int nrConflicts(Enrollment e1, Enrollment e2) {
if (!e1.getStudent().equals(e2.getStudent())) return 0;
if (e1.getRequest() instanceof FreeTimeRequest && e2.getRequest() instanceof FreeTimeRequest) return 0;
int cnt = 0;
for (SctAssignment s1 : e1.getAssignments()) {
for (SctAssignment s2 : e2.getAssignments()) {
if (inConflict(s1, s2))
cnt += share(s1, s2);
}
}
return cnt;
}
示例10: conflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Return a set of time overlapping conflicts ({@link Conflict} objects) between
* given (course) enrollments.
*
* @param e1
* an enrollment
* @param e2
* an enrollment
* @return list of time overlapping conflicts that are between assignment of the
* given enrollments
*/
public Set<Conflict> conflicts(Enrollment e1, Enrollment e2) {
Set<Conflict> ret = new HashSet<Conflict>();
if (!e1.getStudent().equals(e2.getStudent())) return ret;
if (e1.getRequest() instanceof FreeTimeRequest && e2.getRequest() instanceof FreeTimeRequest) return ret;
for (SctAssignment s1 : e1.getAssignments()) {
for (SctAssignment s2 : e2.getAssignments()) {
if (inConflict(s1, s2))
ret.add(new Conflict(e1.getStudent(), share(s1, s2), e1, s1, e2, s2));
}
}
return ret;
}
示例11: nrFreeTimeConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Total sum of all free time conflict of the given enrollment.
* @param enrollment given enrollment
* @return number of all free time conflicts of the given enrollment
*/
public int nrFreeTimeConflicts(Enrollment enrollment) {
if (enrollment.getRequest() instanceof FreeTimeRequest) return 0;
int cnt = 0;
for (Request request : enrollment.getStudent().getRequests()) {
if (request instanceof FreeTimeRequest) {
FreeTimeRequest ft = (FreeTimeRequest)request;
for (SctAssignment section: enrollment.getAssignments())
cnt += share(section, ft);
}
}
return cnt;
}
示例12: freeTimeConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Return a set of free time conflict of the given enrollment.
* @param enrollment given enrollment
* @return set of all free time conflicts of the given enrollment
*/
public Set<Conflict> freeTimeConflicts(Enrollment enrollment) {
Set<Conflict> ret = new HashSet<Conflict>();
if (enrollment.getRequest() instanceof FreeTimeRequest) return ret;
for (Request request : enrollment.getStudent().getRequests()) {
if (request instanceof FreeTimeRequest) {
FreeTimeRequest ft = (FreeTimeRequest)request;
for (SctAssignment section: enrollment.getAssignments()) {
if (inConflict(section, ft))
ret.add(new Conflict(enrollment.getStudent(), share(section, ft), enrollment, section, ft.createEnrollment(), ft));
}
}
}
return ret;
}
示例13: nrNotAvailableTimeConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Total sum of all unavailability time conflict of the given enrollment.
* @param enrollment given enrollment
* @return number of all unavailability time conflicts of the given enrollment
*/
public int nrNotAvailableTimeConflicts(Enrollment enrollment) {
if (enrollment.getRequest() instanceof FreeTimeRequest) return 0;
int cnt = 0;
for (Unavailability unavailability: enrollment.getStudent().getUnavailabilities())
for (SctAssignment section: enrollment.getAssignments())
cnt += share(section, unavailability);
return cnt;
}
示例14: notAvailableTimeConflicts
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
/**
* Return a set of unavailability time conflict of the given enrollment.
* @param enrollment given enrollment
* @return set of all unavailability time conflicts of the given enrollment
*/
public Set<Conflict> notAvailableTimeConflicts(Enrollment enrollment) {
Set<Conflict> ret = new HashSet<Conflict>();
if (enrollment.getRequest() instanceof FreeTimeRequest) return ret;
for (Unavailability unavailability: enrollment.getStudent().getUnavailabilities())
for (SctAssignment section: enrollment.getAssignments())
if (inConflict(section, unavailability))
ret.add(new Conflict(enrollment.getStudent(), share(section, unavailability), enrollment, section, null, unavailability));
return ret;
}
示例15: toProto
import org.cpsolver.studentsct.model.SctAssignment; //导入依赖的package包/类
public static OnlineSectioningLog.Section.Builder toProto(SctAssignment a) {
return toProto(a, null, null);
}