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