本文整理汇总了Java中org.cpsolver.exam.model.ExamPeriod类的典型用法代码示例。如果您正苦于以下问题:Java ExamPeriod类的具体用法?Java ExamPeriod怎么用?Java ExamPeriod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExamPeriod类属于org.cpsolver.exam.model包,在下文中一共展示了ExamPeriod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssignedExamsOfRoom
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public Collection<ExamAssignmentInfo> getAssignedExamsOfRoom(Long roomId) {
Lock lock = currentSolution().getLock().readLock();
lock.lock();
try {
ExamRoom room = null;
for (ExamRoom r: ((ExamModel)currentSolution().getModel()).getRooms()) {
if (r.getId()==roomId) {
room = r; break;
}
}
if (room==null) return null;
Vector<ExamAssignmentInfo> ret = new Vector<ExamAssignmentInfo>();
for (ExamPeriod period: ((ExamModel)currentSolution().getModel()).getPeriods()) {
for (ExamPlacement placement: room.getPlacements(currentSolution().getAssignment(), period)) {
ret.add(new ExamAssignmentInfo(placement, currentSolution().getAssignment()));
}
}
return ret;
} finally {
lock.unlock();
}
}
示例2: getAssignedExamsOfInstructor
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public Collection<ExamAssignmentInfo> getAssignedExamsOfInstructor(Long instructorId) {
Lock lock = currentSolution().getLock().readLock();
lock.lock();
try {
ExamInstructor instructor = null;
for (ExamInstructor i: ((ExamModel)currentSolution().getModel()).getInstructors()) {
if (i.getId()==instructorId) {
instructor = i; break;
}
}
if (instructor==null) return null;
Vector<ExamAssignmentInfo> ret = new Vector<ExamAssignmentInfo>();
for (ExamPeriod period: ((ExamModel)currentSolution().getModel()).getPeriods()) {
Set exams = instructor.getExams(currentSolution().getAssignment(), period);
if (exams!=null)
for (Iterator i=exams.iterator();i.hasNext();) {
Exam exam = (Exam)i.next();
ret.add(new ExamAssignmentInfo(currentSolution().getAssignment().getValue(exam), currentSolution().getAssignment()));
}
}
return ret;
} finally {
lock.unlock();
}
}
示例3: getExamsOfRoom
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public TreeSet<ExamAssignment> getExamsOfRoom(long locationId) {
Lock lock = currentSolution().getLock().readLock();
lock.lock();
try {
ExamModel model = (ExamModel)currentSolution().getModel();
ExamRoom room = null;
for (ExamRoom r: model.getRooms()) {
if (r.getId()==locationId) { room = r; break; }
}
if (room==null) return null;
TreeSet<ExamAssignment> ret = new TreeSet();
for (ExamPeriod period: model.getPeriods()) {
for (ExamPlacement placement: room.getPlacements(currentSolution().getAssignment(), period))
ret.add(new ExamAssignment(placement, currentSolution().getAssignment()));
}
return ret;
} finally {
lock.unlock();
}
}
示例4: loadPeriods
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
protected void loadPeriods() {
Set periods = org.unitime.timetable.model.ExamPeriod.findAll(iSessionId, iExamTypeId);
iProgress.setPhase("Loading periods...", periods.size());
for (Iterator i=periods.iterator();i.hasNext();) {
iProgress.incProgress();
org.unitime.timetable.model.ExamPeriod period = (org.unitime.timetable.model.ExamPeriod)i.next();
String pref = period.getPrefLevel().getPrefProlog();
//if (PreferenceLevel.sProhibited.equals(pref)) continue;
ExamPeriod p = getModel().addPeriod(
period.getUniqueId(),
period.getStartDateLabel(),
period.getStartTimeLabel()+" - "+period.getEndTimeLabel(),
Constants.SLOT_LENGTH_MIN*period.getLength(),
pref2weight(pref));
if (PreferenceLevel.sProhibited.equals(pref)) iProhibitedPeriods.add(p);
iPeriods.put(period.getUniqueId(),p);
}
}
示例5: loadRoomAvailability
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
public void loadRoomAvailability(RoomAvailabilityInterface availability) {
Set periods = org.unitime.timetable.model.ExamPeriod.findAll(iSessionId, iExamTypeId);
Date[] bounds = org.unitime.timetable.model.ExamPeriod.getBounds(new SessionDAO().get(iSessionId), iExamTypeId);
ExamType type = ExamTypeDAO.getInstance().get(iExamTypeId);
String exclude = (type.getType() == ExamType.sExamTypeFinal ? RoomAvailabilityInterface.sFinalExamType : RoomAvailabilityInterface.sMidtermExamType);
roomAvailabilityActivate(availability, bounds[0],bounds[1],exclude);
iProgress.setPhase("Loading room availability...", iAllRooms.size());
for (Iterator i=iAllRooms.iterator();i.hasNext();) {
iProgress.incProgress();
Location location = (Location)i.next();
ExamRoom roomEx = iRooms.get(location.getUniqueId());
if (roomEx==null) continue;
Collection<TimeBlock> times = getRoomAvailability(availability, location, bounds[0], bounds[1], exclude);
if (times==null) continue;
for (TimeBlock time : times) {
for (Iterator j=periods.iterator();j.hasNext();) {
org.unitime.timetable.model.ExamPeriod period = (org.unitime.timetable.model.ExamPeriod)j.next();
ExamPeriod periodEx = iPeriods.get(period.getUniqueId());
if (periodEx!=null && period.overlap(time)) roomEx.setAvailable(periodEx, false);
}
}
}
}
示例6: getValue
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, Collection<Exam> variables) {
int ret = 0;
ExamModel m = (ExamModel)getModel();
Set<Integer> days = new HashSet<Integer>();
for (ExamPeriod p: m.getPeriods()) {
if (days.add(p.getDay())) {
Map<ExamInstructor, Set<Exam>> instructors = ((ExamModel)getModel()).getInstructorsOfDay(assignment, p);
for (Set<Exam> exams: instructors.values()) {
int nrExams = exams.size();
if (nrExams > 2)
ret += nrExams - 2;
}
}
}
return ret;
}
示例7: getValue
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
ExamPeriod period = value.getPeriod();
Map<ExamStudent, Set<Exam>> students = ((ExamModel)getModel()).getStudentsOfDay(assignment, period);
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = students.get(s);
if (exams == null || exams.size() < 2) continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 2)
penalty++;
}
/*
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = s.getExamsADay(assignment, period);
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 2)
penalty++;
}
*/
return penalty;
}
示例8: getValue
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, ExamPlacement value, Set<ExamPlacement> conflicts) {
Exam exam = value.variable();
int penalty = 0;
ExamPeriod period = value.getPeriod();
Map<ExamStudent, Set<Exam>> students = ((ExamModel)getModel()).getStudentsOfPeriod(assignment, period);
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = students.get(s);
if (exams == null) continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
/*
for (ExamStudent s : exam.getStudents()) {
Set<Exam> exams = s.getExams(assignment, period);
if (exams.isEmpty()) continue;
int nrExams = exams.size() + (exams.contains(exam) ? 0 : 1);
if (nrExams > 1)
penalty++;
}
*/
return penalty;
}
示例9: ExamResourceUnavailability
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
public ExamResourceUnavailability(ExamPeriod period, Long id, String type, String name, String date, String time, String room, int size, Set<Long> studentIds, Set<Long> instructorIds) {
iPeriod = period;
iId = id;
iType = type;
iName = name;
iDate = date;
iTime = time;
iRoom = room;
iSize = size;
iStudentIds = studentIds;
iInstructorIds = instructorIds;
}
示例10: loadRooms
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
protected void loadRooms() {
iAllRooms = Location.findAllExamLocations(iSessionId,iExamTypeId);
iProgress.setPhase("Loading rooms...", iAllRooms.size());
for (Iterator i=iAllRooms.iterator();i.hasNext();) {
iProgress.incProgress();
Location location = (Location)i.next();
ExamRoom room = new ExamRoom(getModel(),
location.getUniqueId(),
location.getLabel(),
location.getCapacity(),
location.getExamCapacity(),
location.getCoordinateX(),
location.getCoordinateY());
getModel().addConstraint(room);
getModel().getRooms().add(room);
iRooms.put(room.getId(),room);
if (location.getPermanentId()!=null) iPermId2Room.put(location.getPermanentId(), room);
for (Iterator j=location.getExamPreferences(iExamTypeId).entrySet().iterator();j.hasNext();) {
Map.Entry entry = (Map.Entry)j.next();
ExamPeriod period = iPeriods.get(((org.unitime.timetable.model.ExamPeriod)entry.getKey()).getUniqueId());
String pref = ((PreferenceLevel)entry.getValue()).getPrefProlog();
if (period==null) continue;
if (PreferenceLevel.sProhibited.equals(pref))
room.setAvailable(period.getIndex(), false);
else
room.setPenalty(period.getIndex(), pref2weight(pref));
}
}
}
示例11: getMinPenalty
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
private int getMinPenalty(ExamRoom r) {
int min = Integer.MAX_VALUE;
for (ExamPeriod p : ((ExamModel)getModel()).getPeriods()) {
if (r.isAvailable(p) && (iSoftRooms == null || r.getPenalty(p) != iSoftRooms)) {
min = Math.min(min, r.getPenalty(p));
}
}
return min;
}
示例12: getMaxPenalty
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
private int getMaxPenalty(ExamRoom r) {
int max = Integer.MIN_VALUE;
for (ExamPeriod p : ((ExamModel)getModel()).getPeriods()) {
if (r.isAvailable(p) && (iSoftRooms == null || r.getPenalty(p) != iSoftRooms)) {
max = Math.max(max, r.getPenalty(p));
}
}
return max;
}
示例13: isAvailable
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
private boolean isAvailable(ExamRoom r) {
for (ExamPeriod p : ((ExamModel)getModel()).getPeriods()) {
if (r.isAvailable(p) && (iSoftRooms == null || r.getPenalty(p) != iSoftRooms))
return true;
}
return false;
}
示例14: getValue
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
@Override
public double getValue(Assignment<Exam, ExamPlacement> assignment, Collection<Exam> variables) {
int ret = 0;
ExamModel m = (ExamModel)getModel();
for (ExamPeriod p: m.getPeriods()) {
Map<ExamInstructor, Set<Exam>> instructors = ((ExamModel)getModel()).getInstructorsOfPeriod(assignment, p);
for (Set<Exam> exams: instructors.values()) {
int nrExams = exams.size();
if (nrExams > 1)
ret += nrExams - 1;
}
}
return ret;
}
示例15: report
import org.cpsolver.exam.model.ExamPeriod; //导入依赖的package包/类
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
CSVFile csv = new CSVFile();
csv.setHeader(new CSVField[] { new CSVField("Room"), new CSVField("Cap"), new CSVField("AltCap"),
new CSVField("Period"), new CSVField("Date"), new CSVField("Time"), new CSVField("Exam"),
new CSVField("Enrl") });
List<ExamRoom> rooms = new ArrayList<ExamRoom>(iModel.getRooms());
Collections.sort(rooms, new Comparator<ExamRoom>() {
@Override
public int compare(ExamRoom r1, ExamRoom r2) {
int cmp = -Double.compare(r1.getSize(), r2.getSize());
if (cmp != 0)
return cmp;
cmp = -Double.compare(r1.getAltSize(), r2.getAltSize());
if (cmp != 0)
return cmp;
return r1.compareTo(r2);
}
});
for (ExamRoom room : rooms) {
boolean first = true;
int day = -1;
for (ExamPeriod period : iModel.getPeriods()) {
for (ExamPlacement placement: room.getPlacements(assignment, period)) {
Exam exam = placement.variable();
csv.addLine(new CSVField[] { new CSVField(first ? room.getName() : ""),
new CSVField(first ? "" + room.getSize() : ""),
new CSVField(first ? "" + room.getAltSize() : ""), new CSVField(period.getIndex() + 1),
new CSVField(day == period.getDay() ? "" : period.getDayStr()),
new CSVField(period.getTimeStr()), new CSVField(exam.getName()),
new CSVField(exam.getStudents().size()) });
first = false;
day = period.getDay();
}
}
}
return csv;
}