Examples of Exam


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

    public List<Move> createCachedMoveList(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.drools.planner.examples.examination.domain.Exam

    }

    private void addToCachedExamToMoveMap(int examListSize, List<Move> cachedMoveList) {
        for (Move cachedMove : cachedMoveList) {
            for (Object o : cachedMove.getPlanningEntities()) {
                Exam exam = (Exam) o;
                List<Move> moveList = cachedExamToMoveMap.get(exam);
                if (moveList == null) {
                    moveList = new ArrayList<Move>(examListSize);
                    cachedExamToMoveMap.put(exam, moveList);
                }
View Full Code Here

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

        if (nextShuffledExamListIndex >= shuffledExamList.size()) {
            // Just in time shuffling
            Collections.shuffle(shuffledExamList, localSearchStepScope.getWorkingRandom());
            nextShuffledExamListIndex = 0;
        }
        Exam exam = shuffledExamList.get(nextShuffledExamListIndex);
        List<Move> moveList = cachedExamToMoveMap.get(exam);
        nextShuffledExamListIndex++;
        return moveList.iterator();
    }
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

        localSearchSolverScope.setWorkingSolution(examination);
        WorkingMemory workingMemory = localSearchSolverScope.getWorkingMemory();

        localSearchSolverScope.calculateScoreFromWorkingMemory();
        // do RoomChangeMove
        Exam exam = findExamById(examination, 123L);
        Room room = findRoomById(examination, 0L);
        ExaminationMoveHelper.moveRoom(workingMemory, exam, room);
        Score score = localSearchSolverScope.calculateScoreFromWorkingMemory();
        localSearchSolverScope.assertWorkingScore(score);
    }
View Full Code Here

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

    private void addToCachedExamToMoveMap(int examListSize, List<Move> cachedMoveList) {
        for (Move cachedMove : cachedMoveList) {
            TabuPropertyEnabled tabuPropertyEnabledMove = (TabuPropertyEnabled) cachedMove;
            for (Object o : tabuPropertyEnabledMove.getTabuProperties()) {
                Exam exam = (Exam) o;
                List<Move> moveList = cachedExamToMoveMap.get(exam);
                if (moveList == null) {
                    moveList = new ArrayList<Move>(examListSize);
                    cachedExamToMoveMap.put(exam, moveList);
                }
View Full Code Here

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

        if (nextShuffledExamListIndex >= shuffledExamList.size()) {
            // Just in time shuffling
            Collections.shuffle(shuffledExamList, localSearchStepScope.getWorkingRandom());
            nextShuffledExamListIndex = 0;
        }
        Exam exam = shuffledExamList.get(nextShuffledExamListIndex);
        List<Move> moveList = cachedExamToMoveMap.get(exam);
        nextShuffledExamListIndex++;
        return moveList.iterator();
    }
View Full Code Here

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

        List<ExamInitializationWeight> examInitialWeightList = createExamAssigningScoreList(examination);

        for (ExamInitializationWeight examInitialWeight : examInitialWeightList) {
            Score unscheduledScore = abstractSolverScope.calculateScoreFromWorkingMemory();
            Exam leader = examInitialWeight.getExam();
            FactHandle leaderHandle = null;

            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) {
                    examToHandle.getExam().setPeriod(period);
                    if (examToHandle.getExamHandle() == null) {
                        examToHandle.setExamHandle(workingMemory.insert(examToHandle.getExam()));
                        if (examToHandle.getExam().isCoincidenceLeader()) {
                            leaderHandle = examToHandle.getExamHandle();
                        }
                    } else {
                        workingMemory.update(examToHandle.getExamHandle(), examToHandle.getExam());
                    }
                }
                Score score = abstractSolverScope.calculateScoreFromWorkingMemory();
                periodScoringList.add(new PeriodScoring(period, score));
            }
            Collections.sort(periodScoringList);

            scheduleLeader(periodScoringList, roomList, abstractSolverScope, workingMemory, unscheduledScore,
                    examToHandleList, leader, leaderHandle);
            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, abstractSolverScope, workingMemory, exam, examToHandle.getExamHandle());
                    examList.add(exam);
                }
            }
        }
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 (PeriodHardConstraint periodHardConstraint : examination.getPeriodHardConstraintList()) {
            if (periodHardConstraint.getPeriodHardConstraintType() == PeriodHardConstraintType.EXAM_COINCIDENCE) {
                Exam leftExam = topicToExamMap.get(periodHardConstraint.getLeftSideTopic());
                Exam rightExam = topicToExamMap.get(periodHardConstraint.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 (periodHardConstraint.getPeriodHardConstraintType() == PeriodHardConstraintType.AFTER) {
                Exam afterExam = topicToExamMap.get(periodHardConstraint.getLeftSideTopic());
                Exam beforeExam = topicToExamMap.get(periodHardConstraint.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

    public List<Move> createCachedMoveList(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 ExamSwitchMove(leftExam, rightExam));
            }
        }
        return moveList;
    }
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.