    001package org.cpsolver.studentsct.online.selection;
    002
    003import java.util.Hashtable;
    004import java.util.Set;
    005
    006import org.cpsolver.ifs.assignment.Assignment;
    007import org.cpsolver.ifs.util.DataProperties;
    008import org.cpsolver.studentsct.model.CourseRequest;
    009import org.cpsolver.studentsct.model.Enrollment;
    010import org.cpsolver.studentsct.model.FreeTimeRequest;
    011import org.cpsolver.studentsct.model.Request;
    012import org.cpsolver.studentsct.model.Section;
    013import org.cpsolver.studentsct.model.Student;
    014import org.cpsolver.studentsct.online.OnlineSectioningModel;
    015import org.cpsolver.studentsct.online.expectations.OverExpectedCriterion;
    016import org.cpsolver.studentsct.online.selection.MultiCriteriaBranchAndBoundSelection.SelectionCriterion;
    017
    018/**
    019 * Computation of suggestions using a limited depth branch and bound, using a
    020 * multi-criteria selection criterion. Everything is the same, but
    021 * {@link MultiCriteriaBranchAndBoundSelection.SelectionCriterion#compare(Assignment, Enrollment[], Enrollment[])}
    022 * is used to compare two suggestions.
    023 *
    024 * @see MultiCriteriaBranchAndBoundSelection.SelectionCriterion
    025 *
    026 * @author  Tomáš Müller
    027 * @version StudentSct 1.3 (Student Sectioning)<br>
    028 *          Copyright (C) 2014 Tomáš Müller<br>
    029 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    030 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    031 * <br>
    032 *          This library is free software; you can redistribute it and/or modify
    033 *          it under the terms of the GNU Lesser General Public License as
    034 *          published by the Free Software Foundation; either version 3 of the
    035 *          License, or (at your option) any later version. <br>
    036 * <br>
    037 *          This library is distributed in the hope that it will be useful, but
    038 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    039 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    040 *          Lesser General Public License for more details. <br>
    041 * <br>
    042 *          You should have received a copy of the GNU Lesser General Public
    043 *          License along with this library; if not see <a
    044 *          href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>.
    045 *
    046 */
    047public class MultiCriteriaBranchAndBoundSuggestions extends SuggestionsBranchAndBound {
    048
    049    /**
    050     * Constructor
    051     *
    052     * @param properties
    053     *            configuration
    054     * @param student
    055     *            given student
    056     * @param assignment
    057     *            current assignment
    058     * @param requiredSections
    059     *            required sections
    060     * @param requiredFreeTimes
    061     *            required free times (free time requests that must be assigned)
    062     * @param preferredSections
    063     *            preferred sections
    064     * @param selectedRequest
    065     *            selected request
    066     * @param selectedSection
    067     *            selected section
    068     * @param filter
    069     *            section filter
    070     * @param maxSectionsWithPenalty
    071     *            maximal number of sections that have a positive
    072     *            over-expectation penalty
    073     *            {@link OverExpectedCriterion#getOverExpected(Assignment, Section, Request)}
    074     */
    075    public MultiCriteriaBranchAndBoundSuggestions(DataProperties properties, Student student,
    076            Assignment<Request, Enrollment> assignment, Hashtable<CourseRequest, Set<Section>> requiredSections,
    077            Set<FreeTimeRequest> requiredFreeTimes, Hashtable<CourseRequest, Set<Section>> preferredSections,
    078            Request selectedRequest, Section selectedSection, SuggestionFilter filter, double maxSectionsWithPenalty,
    079            boolean priorityWeighting) {
    080        super(properties, student, assignment, requiredSections, requiredFreeTimes, preferredSections, selectedRequest,
    081                selectedSection, filter, maxSectionsWithPenalty);
    082        if (priorityWeighting)
    083            iComparator = new OnlineSectioningCriterion(student, (OnlineSectioningModel) selectedRequest.getModel(),
    084                    assignment, preferredSections);
    085        else
    086            iComparator = new EqualWeightCriterion(student, (OnlineSectioningModel) selectedRequest.getModel(),
    087                    assignment, preferredSections);
    088    }
    089
    090    @Override
    091    protected int compare(Assignment<Request, Enrollment> assignment, Suggestion s1, Suggestion s2) {
    092        return ((SelectionCriterion) iComparator).compare(assignment, s1.getEnrollments(), s2.getEnrollments());
    093    }
    094
    095}