Examples of Exam


Examples of org.drools.planner.examples.examination.domain.Exam

        List<ExamInitializationWeight> examInitialWeightList = createExamAssigningScoreList(examination);

        for (ExamInitializationWeight examInitialWeight : examInitialWeightList) {
            Score unscheduledScore = scoreDirector.calculateScore();
            Exam leader = examInitialWeight.getExam();

            List<ExamToHandle> examToHandleList = new ArrayList<ExamToHandle>(5);
            if (leader.getExamCoincidence() == null) {
                examToHandleList.add(new ExamToHandle(leader));
            } else {
                for (Exam coincidenceExam : leader.getExamCoincidence().getCoincidenceExamSet()) {
                    examToHandleList.add(new ExamToHandle(coincidenceExam));
                }
            }

            List<PeriodScoring> periodScoringList = new ArrayList<PeriodScoring>(periodList.size());
            for (Period period : periodList) {
                for (ExamToHandle examToHandle : examToHandleList) {
                    Exam exam = examToHandle.getExam();
                    if (!examToHandle.isAdded()) {
                        scoreDirector.beforeEntityAdded(exam);
                        exam.setPeriod(period);
                        scoreDirector.afterEntityAdded(exam);
                        examToHandle.setAdded(true);
                    } else {
                        scoreDirector.beforeVariableChanged(exam, "period");
                        exam.setPeriod(period);
                        scoreDirector.afterVariableChanged(exam, "period");
                    }
                }
                Score score = scoreDirector.calculateScore();
                periodScoringList.add(new PeriodScoring(period, score));
            }
            Collections.sort(periodScoringList);

            scheduleLeader(periodScoringList, roomList, scoreDirector, unscheduledScore, examToHandleList, leader);
            examList.add(leader);

            // Schedule the non leaders
            for (ExamToHandle examToHandle : examToHandleList) {
                Exam exam = examToHandle.getExam();
                // Leader already has a room
                if (!exam.isCoincidenceLeader()) {
                    scheduleNonLeader(roomList, scoreDirector, exam);
                    examList.add(exam);
                }
            }
        }
View Full Code Here

Examples of org.drools.planner.examples.examination.domain.Exam

            if (bestScore.compareTo(periodScoring.getScore()) >= 0) {
                // No need to check the rest
                break;
            }
            for (ExamToHandle examToHandle : examToHandleList) {
                Exam exam = examToHandle.getExam();
                scoreDirector.beforeVariableChanged(exam, "period");
                exam.setPeriod(periodScoring.getPeriod());
                scoreDirector.afterVariableChanged(exam, "period");
            }
            for (Room room : roomList) {
                scoreDirector.beforeVariableChanged(leader, "room");
                leader.setRoom(room);
                scoreDirector.afterVariableChanged(leader, "room");
                Score score = scoreDirector.calculateScore();
                if (score.compareTo(unscheduledScore) < 0) {
                    if (score.compareTo(bestScore) > 0) {
                        bestScore = score;
                        bestPeriod = periodScoring.getPeriod();
                        bestRoom = room;
                    }
                } else if (score.equals(unscheduledScore)) {
                    perfectMatch = true;
                    break;
                } else {
                    throw new IllegalStateException("The score (" + score
                            + ") cannot be higher than unscheduledScore (" + unscheduledScore + ").");
                }
            }
            if (perfectMatch) {
                break;
            }
        }
        if (!perfectMatch) {
            if (bestPeriod == null || bestRoom == null) {
                throw new IllegalStateException("The bestPeriod (" + bestPeriod + ") or the bestRoom ("
                        + bestRoom + ") cannot be null.");
            }
            scoreDirector.beforeVariableChanged(leader, "room");
            leader.setRoom(bestRoom);
            scoreDirector.afterVariableChanged(leader, "room");
            for (ExamToHandle examToHandle : examToHandleList) {
                Exam exam = examToHandle.getExam();
                scoreDirector.beforeVariableChanged(exam, "period");
                exam.setPeriod(bestPeriod);
                scoreDirector.afterVariableChanged(exam, "period");
            }
        }
        logger.debug("    Exam ({}) initialized.", leader);
    }
View Full Code Here

Examples of org.drools.planner.examples.examination.domain.Exam

    public List<Exam> createExamList(Examination examination) {
        List<Topic> topicList = examination.getTopicList();
        List<Exam> examList = new ArrayList<Exam>(topicList.size());
        Map<Topic, Exam> topicToExamMap = new HashMap<Topic, Exam>(topicList.size());
        for (Topic topic : topicList) {
            Exam exam = new Exam();
            exam.setId(topic.getId());
            exam.setTopic(topic);
            examList.add(exam);
            topicToExamMap.put(topic, exam);
        }
        for (PeriodPenalty periodPenalty : examination.getPeriodPenaltyList()) {
            if (periodPenalty.getPeriodPenaltyType() == PeriodPenaltyType.EXAM_COINCIDENCE) {
                Exam leftExam = topicToExamMap.get(periodPenalty.getLeftSideTopic());
                Exam rightExam = topicToExamMap.get(periodPenalty.getRightSideTopic());

                Set<Exam> newCoincidenceExamSet = new LinkedHashSet<Exam>(4);
                ExamCoincidence leftExamCoincidence = leftExam.getExamCoincidence();
                if (leftExamCoincidence != null) {
                    newCoincidenceExamSet.addAll(leftExamCoincidence.getCoincidenceExamSet());
                } else {
                    newCoincidenceExamSet.add(leftExam);
                }
                ExamCoincidence rightExamCoincidence = rightExam.getExamCoincidence();
                if (rightExamCoincidence != null) {
                    newCoincidenceExamSet.addAll(rightExamCoincidence.getCoincidenceExamSet());
                } else {
                    newCoincidenceExamSet.add(rightExam);
                }
                ExamCoincidence newExamCoincidence = new ExamCoincidence(newCoincidenceExamSet);
                for (Exam exam : newCoincidenceExamSet) {
                    exam.setExamCoincidence(newExamCoincidence);
                }
            } else if (periodPenalty.getPeriodPenaltyType() == PeriodPenaltyType.AFTER) {
                Exam afterExam = topicToExamMap.get(periodPenalty.getLeftSideTopic());
                Exam beforeExam = topicToExamMap.get(periodPenalty.getRightSideTopic());
                ExamBefore examBefore = beforeExam.getExamBefore();
                if (examBefore == null) {
                    examBefore = new ExamBefore(new LinkedHashSet<Exam>(2));
                    beforeExam.setExamBefore(examBefore);
                }
                examBefore.getAfterExamSet().add(afterExam);
            }
        }
        return examList;
View Full Code Here

Examples of org.drools.planner.examples.examination.domain.Exam

        private void createExamList(Examination examination) {
            List<Topic> topicList = examination.getTopicList();
            List<Exam> examList = new ArrayList<Exam>(topicList.size());
            Map<Topic, Exam> topicToExamMap = new HashMap<Topic, Exam>(topicList.size());
            for (Topic topic : topicList) {
                Exam exam = new Exam();
                exam.setId(topic.getId());
                exam.setTopic(topic);
                // Notice that we leave the PlanningVariable properties on null
                examList.add(exam);
                topicToExamMap.put(topic, exam);
            }
            for (PeriodPenalty periodPenalty : examination.getPeriodPenaltyList()) {
                if (periodPenalty.getPeriodPenaltyType() == PeriodPenaltyType.EXAM_COINCIDENCE) {
                    Exam leftExam = topicToExamMap.get(periodPenalty.getLeftSideTopic());
                    Exam rightExam = topicToExamMap.get(periodPenalty.getRightSideTopic());

                    Set<Exam> newCoincidenceExamSet = new LinkedHashSet<Exam>(4);
                    ExamCoincidence leftExamCoincidence = leftExam.getExamCoincidence();
                    if (leftExamCoincidence != null) {
                        newCoincidenceExamSet.addAll(leftExamCoincidence.getCoincidenceExamSet());
                    } else {
                        newCoincidenceExamSet.add(leftExam);
                    }
                    ExamCoincidence rightExamCoincidence = rightExam.getExamCoincidence();
                    if (rightExamCoincidence != null) {
                        newCoincidenceExamSet.addAll(rightExamCoincidence.getCoincidenceExamSet());
                    } else {
                        newCoincidenceExamSet.add(rightExam);
                    }
                    ExamCoincidence newExamCoincidence = new ExamCoincidence(newCoincidenceExamSet);
                    for (Exam exam : newCoincidenceExamSet) {
                        exam.setExamCoincidence(newExamCoincidence);
                    }
                } else if (periodPenalty.getPeriodPenaltyType() == PeriodPenaltyType.AFTER) {
                    Exam afterExam = topicToExamMap.get(periodPenalty.getLeftSideTopic());
                    Exam beforeExam = topicToExamMap.get(periodPenalty.getRightSideTopic());
                    ExamBefore examBefore = beforeExam.getExamBefore();
                    if (examBefore == null) {
                        examBefore = new ExamBefore(new LinkedHashSet<Exam>(2));
                        beforeExam.setExamBefore(examBefore);
                    }
                    examBefore.getAfterExamSet().add(afterExam);
                }
            }
            examination.setExamList(examList);
View Full Code Here

Examples of org.drools.planner.examples.examination.domain.Exam

    public List<Move> createMoveList(Solution solution) {
        Examination examination = (Examination) solution;
        List<Exam> examList = examination.getExamList();
        List<Move> moveList = new ArrayList<Move>();
        for (ListIterator<Exam> leftIt = examList.listIterator(); leftIt.hasNext();) {
            Exam leftExam = leftIt.next();
            for (ListIterator<Exam> rightIt = examList.listIterator(leftIt.nextIndex()); rightIt.hasNext();) {
                Exam rightExam = rightIt.next();
                moveList.add(new ExamSwapMove(leftExam, rightExam));
            }
        }
        return moveList;
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Exam

        return result;
    }

    private void fillSpecialSeasonExam(final ExamDateCertificateRequest request, final Enrolment enrolment,
            final ExamDateEntry entry) {
        final Exam specialSeasonExam = request.getExamFor(enrolment, Season.SPECIAL_SEASON_OBJ);
        if (specialSeasonExam != null) {
            entry.setSpecialSeasonDate(specialSeasonExam.getDayDateYearMonthDay().toString(DD_SLASH_MM_SLASH_YYYY, getLocale()));
            entry.setSpecialSeasonHour(specialSeasonExam.getBeginningDateHourMinuteSecond().toString("HH:mm"));
        }
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Exam

        }
    }

    private void fillSecondSeasonExam(final ExamDateCertificateRequest request, final Enrolment enrolment,
            final ExamDateEntry entry) {
        final Exam secondSeasonExam = request.getExamFor(enrolment, Season.SEASON2_OBJ);
        if (secondSeasonExam != null) {
            entry.setSecondSeasonDate(secondSeasonExam.getDayDateYearMonthDay().toString(DD_SLASH_MM_SLASH_YYYY, getLocale()));
            entry.setSecondSeasonHour(secondSeasonExam.getBeginningDateHourMinuteSecond().toString("HH:mm"));
        }
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Exam

        }
    }

    private void fillFirstSeasonExam(final ExamDateCertificateRequest request, final Enrolment enrolment,
            final ExamDateEntry entry) {
        final Exam firstSeasonExam = request.getExamFor(enrolment, Season.SEASON1_OBJ);
        if (firstSeasonExam != null) {
            entry.setFirstSeasonDate(firstSeasonExam.getDayDateYearMonthDay().toString(DD_SLASH_MM_SLASH_YYYY, getLocale()));
            entry.setFirstSeasonHour(firstSeasonExam.getBeginningDateHourMinuteSecond().toString("HH:mm"));
        }
    }
View Full Code Here

Examples of org.fenixedu.academic.domain.Exam

                final YearMonthDay evaluationDate = writtenEvaluation.getDayDateYearMonthDay();

                if (!evaluationDate.isBefore(weekStartYearMonthDay) && !evaluationDate.isAfter(weekEndYearMonthDay)) {

                    if (writtenEvaluation instanceof Exam) {
                        final Exam exam = (Exam) writtenEvaluation;
                        infoShowOccupations.add(InfoExam.newInfoFromDomain(exam));

                    } else if (writtenEvaluation instanceof WrittenTest) {
                        final WrittenTest writtenTest = (WrittenTest) writtenEvaluation;
                        infoShowOccupations.add(InfoWrittenTest.newInfoFromDomain(writtenTest));
View Full Code Here

Examples of org.fenixedu.academic.domain.Exam

                        constructCalendarLink(calendarLinks, writtenTest, executionCourse);
                    } else if (evaluation instanceof Project) {
                        final Project project = (Project) evaluation;
                        constructCalendarLink(calendarLinks, project, executionCourse);
                    } else if (evaluation instanceof Exam) {
                        final Exam exam = (Exam) evaluation;
                        if (exam.isExamsMapPublished()) {
                            constructEmptyCalendarLink(calendarLinks, exam, executionCourse);
                        }
                    }
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.