當前位置: 首頁>>代碼示例>>Java>>正文


Java PeriodPenalty類代碼示例

本文整理匯總了Java中org.cpsolver.exam.criteria.PeriodPenalty的典型用法代碼示例。如果您正苦於以下問題:Java PeriodPenalty類的具體用法?Java PeriodPenalty怎麽用?Java PeriodPenalty使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PeriodPenalty類屬於org.cpsolver.exam.criteria包,在下文中一共展示了PeriodPenalty類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ExamAssignment

import org.cpsolver.exam.criteria.PeriodPenalty; //導入依賴的package包/類
public ExamAssignment(org.cpsolver.exam.model.Exam exam, ExamPlacement placement, Assignment<org.cpsolver.exam.model.Exam, ExamPlacement> assignment) {
    super(exam);
    if (placement!=null) {
        iNrDirectConflicts = (int)exam.getModel().getCriterion(StudentDirectConflicts.class).getValue(assignment, placement, null) +
        					 (int)exam.getModel().getCriterion(StudentNotAvailableConflicts.class).getValue(assignment, placement, null);
        iNrMoreThanTwoADayConflicts = (int)exam.getModel().getCriterion(StudentMoreThan2ADayConflicts.class).getValue(assignment, placement, null);
        iNrBackToBackConflicts = (int)exam.getModel().getCriterion(StudentBackToBackConflicts.class).getValue(assignment, placement, null);
        iNrDistanceBackToBackConflicts = (int)exam.getModel().getCriterion(StudentDistanceBackToBackConflicts.class).getValue(assignment, placement, null);
        iPeriodPenalty = (int)exam.getModel().getCriterion(PeriodPenalty.class).getValue(assignment, placement, null);
        iRoomSizePenalty = (int)exam.getModel().getCriterion(RoomSizePenalty.class).getValue(assignment, placement, null);
        iRoomSplitPenalty = (int)exam.getModel().getCriterion(RoomSplitPenalty.class).getValue(assignment, placement, null);
        iRotationPenalty = (int)exam.getModel().getCriterion(ExamRotationPenalty.class).getValue(assignment, placement, null);
        iRoomPenalty = (int)exam.getModel().getCriterion(RoomPenalty.class).getValue(assignment, placement, null);
        iNrInstructorDirectConflicts = (int)exam.getModel().getCriterion(InstructorDirectConflicts.class).getValue(assignment, placement, null) +
        		(int)exam.getModel().getCriterion(InstructorNotAvailableConflicts.class).getValue(assignment, placement, null);
        iNrInstructorMoreThanTwoADayConflicts = (int)exam.getModel().getCriterion(InstructorMoreThan2ADayConflicts.class).getValue(assignment, placement, null);
        iNrInstructorBackToBackConflicts = (int)exam.getModel().getCriterion(InstructorBackToBackConflicts.class).getValue(assignment, placement, null);
        iNrInstructorDistanceBackToBackConflicts = (int)exam.getModel().getCriterion(InstructorDistanceBackToBackConflicts.class).getValue(assignment, placement, null);
        iValue = placement.toDouble(assignment);
        iPeriodId = placement.getPeriod().getId();
        iPeriodIdx = placement.getPeriod().getIndex();
        iRooms = new TreeSet<ExamRoomInfo>();
        iPeriodPref = (exam.getPeriodPlacements().size()==1?PreferenceLevel.sRequired:PreferenceLevel.int2prolog(iPeriodPenalty));
        if (placement.getRoomPlacements()!=null) {
            boolean reqRoom = placement.getRoomPlacements().size()==exam.getRoomPlacements().size();
            for (Iterator i=placement.getRoomPlacements().iterator();i.hasNext();) {
                ExamRoomPlacement room = (ExamRoomPlacement)i.next();
                iRooms.add(new ExamRoomInfo(room.getRoom(), (reqRoom?PreferenceLevel.sIntLevelRequired:room.getPenalty(placement.getPeriod()))));
            }
        }
        MinMaxPreferenceCombination pc = new MinMaxPreferenceCombination();
        for (ExamDistributionConstraint dc: placement.variable().getDistributionConstraints()) {
            if (dc.isHard() || dc.isSatisfied(assignment)) continue;
            pc.addPreferenceInt(dc.getWeight());
        }
        iDistPref = pc.getPreferenceProlog(); 
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:39,代碼來源:ExamAssignment.java


注:本文中的org.cpsolver.exam.criteria.PeriodPenalty類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。