    001package org.cpsolver.studentsct.online.expectations;
    002
    003import java.util.Set;
    004
    005import org.cpsolver.ifs.assignment.Assignment;
    006import org.cpsolver.ifs.model.Constraint;
    007import org.cpsolver.ifs.model.Value;
    008import org.cpsolver.studentsct.model.Enrollment;
    009import org.cpsolver.studentsct.model.Request;
    010import org.cpsolver.studentsct.model.Section;
    011
    012/**
    013 * Over-expected criterion interface. Various implementations can be provided.
    014 *
    015 * @version StudentSct 1.3 (Student Sectioning)<br>
    016 *          Copyright (C) 2014 Tomáš Müller<br>
    017 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    018 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    019 * <br>
    020 *          This library is free software; you can redistribute it and/or modify
    021 *          it under the terms of the GNU Lesser General Public License as
    022 *          published by the Free Software Foundation; either version 3 of the
    023 *          License, or (at your option) any later version. <br>
    024 * <br>
    025 *          This library is distributed in the hope that it will be useful, but
    026 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    027 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    028 *          Lesser General Public License for more details. <br>
    029 * <br>
    030 *          You should have received a copy of the GNU Lesser General Public
    031 *          License along with this library; if not see <a href='http://www.gnu.org/licenses'>http://www.gnu.org/licenses</a>.
    032 *
    033 */
    034public interface OverExpectedCriterion {
    035    /**
    036     * Expectation penalty, to be minimized
    037     * @param assignment current assignment
    038     * @param section section in question
    039     * @param request student course request
    040     * @return expectation penalty (typically 1.0 / number of subparts when over-expected, 0.0 otherwise)
    041     */
    042    public double getOverExpected(Assignment<Request, Enrollment> assignment, Section section, Request request);
    043
    044    /**
    045     * Expected space, for printing purposes
    046     * @param sectionLimit section limit, see {@link Section#getLimit()}
    047     * @param expectedSpace expectation, see {@link Section#getSpaceExpected()}
    048     * @return expected space to be printed (null if there are no expectations)
    049     */
    050    public Integer getExpected(int sectionLimit, double expectedSpace);
    051
    052    public static interface HasContext {
    053        /**
    054         * Expectation penalty, to be minimized.
    055         * A variant of the {@link OverExpectedCriterion#getOverExpected(Assignment, Section, Request)} method that can be called from {@link Constraint#computeConflicts(Assignment, Value, Set)}.
    056         * @param assignment current assignment
    057         * @param selection selected enrollment question
    058         * @param value an enrollment to be assigned
    059         * @param conflicts enrollments that have been already identified as conflicting
    060         * @return expectation penalty (typically 1.0 / number of subparts when over-expected, 0.0 otherwise)
    061         */
    062        public double getOverExpected(Assignment<Request, Enrollment> assignment, Enrollment selection, Enrollment value, Set<Enrollment> conflicts);
    063
    064        /**
    065         * Expectation penalty, to be minimized
    066         * @param assignment current assignment
    067         * @param enrollment current assignment of the student
    068         * @param index only use enrollments 0 .. index - 1 from the assignment array
    069         * @param section section in question
    070         * @param request student course request
    071         * @return expectation penalty (typically 1.0 / number of subparts when over-expected, 0.0 otherwise)
    072         */
    073        public double getOverExpected(Assignment<Request, Enrollment> assignment, Enrollment[] enrollment, int index, Section section, Request request);
    074    }
    075}