当前位置: 首页>>代码示例>>Java>>正文


Java ExamRoom类代码示例

本文整理汇总了Java中org.cpsolver.exam.model.ExamRoom的典型用法代码示例。如果您正苦于以下问题:Java ExamRoom类的具体用法?Java ExamRoom怎么用?Java ExamRoom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExamRoom类属于org.cpsolver.exam.model包,在下文中一共展示了ExamRoom类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAssignedExamsOfRoom

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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();
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:24,代码来源:ExamSolver.java

示例2: getExamsOfRoom

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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();
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:22,代码来源:ExamSolver.java

示例3: loadRoomAvailability

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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);
            }
        }
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:24,代码来源:ExamDatabaseLoader.java

示例4: loadRooms

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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));
        }
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:30,代码来源:ExamDatabaseLoader.java

示例5: ExamRoomInfo

import org.cpsolver.exam.model.ExamRoom; //导入依赖的package包/类
public ExamRoomInfo(ExamRoom room, int preference) {
    iId = room.getId();
    iName = room.getName();
    iCapacity = room.getSize();
    iExamCapacity = room.getAltSize();
    iPreference = preference;
    iX = room.getCoordX(); iY = room.getCoordY();
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:9,代码来源:ExamRoomInfo.java

示例6: getMinPenalty

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:10,代码来源:RoomPenalty.java

示例7: getMaxPenalty

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:10,代码来源:RoomPenalty.java

示例8: isAvailable

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:8,代码来源:RoomPenalty.java

示例9: report

import org.cpsolver.exam.model.ExamRoom; //导入依赖的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;
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:38,代码来源:ExamRoomSchedule.java

示例10: add

import org.cpsolver.exam.model.ExamRoom; //导入依赖的package包/类
@Override
public void add(String problem, ExamModel model) {
    int[] sizes = new int[] { 0, 100, 200, 400, 600 };
    int[] nrRooms = new int[] { 0, 0, 0, 0, 0 }, nrRoomsAlt = new int[] { 0, 0, 0, 0, 0 };
    int[] nrExams = new int[] { 0, 0, 0, 0, 0 }, nrExamsAlt = new int[] { 0, 0, 0, 0, 0 };
    double[] density = new double[] { 0, 0, 0, 0, 0 };
    
    Set<ExamRoom> rooms = new HashSet<ExamRoom>();
    for (Exam exam: model.variables()) {
        for (ExamRoomPlacement room: exam.getRoomPlacements()) {
            if (rooms.add(room.getRoom())) {
                for (int i = 0; i < sizes.length; i++) {
                    if (room.getRoom().getSize() >= sizes[i])
                        nrRooms[i] ++;
                    if (room.getRoom().getAltSize() >= sizes[i])
                        nrRoomsAlt[i] ++;
                }
            }
        }

        for (int i = 0; i < sizes.length; i++) {
            if (exam.getSize() >= sizes[i]) {
                nrExams[i] ++;
                if (exam.hasAltSeating())
                    nrExamsAlt[i] ++;
                for (Exam x: exam.getStudentCorrelatedExams())
                    if (x.getSize() >= sizes[i])
                        density[i] ++;
            }
        }
    }
    
    for (int i = 0; i < sizes.length; i++) {
        add(problem, "Rooms" + (sizes[i] == 0 ? "" : " (≥ " + sizes[i] + " seats)"), sNF.format(nrRooms[i]) + (sizes[i] == 0 ? "" : " (" + sNF.format(nrRoomsAlt[i]) + ")"));
    }
    for (int i = 0; i < sizes.length; i++) {
        add(problem, "Exams" + (sizes[i] == 0 ? "" : " (≥ " + sizes[i] + " seats)"), sNF.format(nrExams[i]) + (sizes[i] == 0 ? "" : " (" + sNF.format(nrExamsAlt[i]) + ")"));
    }
    for (int i = 0; i < sizes.length; i++) {
        add(problem, "Density" + (sizes[i] == 0 ? "" : " (≥ " + sizes[i] + " seats)"), sDF.format(100.0 * density[i] / (nrExams[i] * (nrExams[i] - 1))) + "%");
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:43,代码来源:MistaTables.java


注:本文中的org.cpsolver.exam.model.ExamRoom类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。