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