org.cpsolver.studentsct.online.expectations

## Class PercentageOverExpected

- java.lang.Object
- - org.cpsolver.studentsct.online.expectations.PercentageOverExpected

- All Implemented Interfaces:
    OverExpectedCriterion
  Direct Known Subclasses:
    AvoidUnbalancedWhenNoExpectations, FractionallyOverExpected, MoreSpaceThanExpected

      public class PercentageOverExpected
      extends Object
      implements OverExpectedCriterion

  A class is considered over-expected, when there less space available than expected. The expectations can be increased by the given percentage (parameter OverExpected.Percentage, defaults to 1.0). Expectation rounding can be defined by OverExpected.Rounding parameter, defaults to round (other values are none, ceil, and floor).
  Unlimited classes are never over-expected. A class is over-expected when the number of enrolled students (including the student in question) + expectations (multiplied by OverExpected.Percentage) is greater or equal the section limit.
  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses.
  Author:
    Tomáš Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PercentageOverExpected.Rounding` Expectations rounding

    - ### Nested classes/interfaces inherited from interface org.cpsolver.studentsct.online.expectations.OverExpectedCriterion

      `OverExpectedCriterion.HasContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PercentageOverExpected()`
    `PercentageOverExpected(DataProperties config)`
    `PercentageOverExpected(Double percentage)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `getEnrollment(Assignment<Request,Enrollment> assignment, Config config, Request request)` Config enrollment (using `OnlineConfig.getEnrollment()` if applicable}, `Config.getEnrollmentWeight(Assignment, Request)` otherwise)
    `protected double` | `getEnrollment(Assignment<Request,Enrollment> assignment, Section section, Request request)` Section enrollment (using `OnlineSection.getEnrollment()` if applicable}, `Section.getEnrollmentWeight(Assignment, Request)` otherwise)
    `Integer` | `getExpected(int sectionLimit, double expectedSpace)` Expected space, for printing purposes
    `protected int` | `getLimit(Section section)` Section limit (using `OnlineSection.getEnrollment()` if applicable}, `Section.getLimit()` otherwise)
    `protected int` | `getLimit(Subpart subpart)` Subpart limit (using `OnlineConfig.getEnrollment()` if applicable}, `Subpart.getLimit()` otherwise)
    `double` | `getOverExpected(Assignment<Request,Enrollment> assignment, Section section, Request request)` Expectation penalty, to be minimized
    `double` | `getPercentage()` Over-expected percentage, defaults to 1.0
    `protected boolean` | `hasExpectations(Subpart subpart)` Check if there are expectations on any of the sections of the given subpart
    `protected double` | `round(double value)` Round the given value using the rounding from OverExpected.Rounding parameter
    `void` | `setPercentage(Double percentage)` Over-expected percentage, defaults to 1.0
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PercentageOverExpected

          public PercentageOverExpected(DataProperties config)

    - #### PercentageOverExpected

          public PercentageOverExpected(Double percentage)

    - #### PercentageOverExpected

          public PercentageOverExpected()

  - ### Method Detail

    - #### getPercentage

          public double getPercentage()

      Over-expected percentage, defaults to 1.0
      Returns:
        expectations adjustment

    - #### setPercentage

          public void setPercentage(Double percentage)

      Over-expected percentage, defaults to 1.0
      Parameters:
        `percentage` - expectations adjustment

    - #### round

          protected double round(double value)

      Round the given value using the rounding from OverExpected.Rounding parameter
      Parameters:
        `value` - given value
      Returns:
        rounded value

    - #### hasExpectations

          protected boolean hasExpectations(Subpart subpart)

      Check if there are expectations on any of the sections of the given subpart
      Parameters:
        `subpart` - given subpart
      Returns:
        true if there is at least one section with positive `Section.getSpaceExpected()`

    - #### getEnrollment

          protected double getEnrollment(Assignment<Request,Enrollment> assignment,
                                         Config config,
                                         Request request)

      Config enrollment (using `OnlineConfig.getEnrollment()` if applicable}, `Config.getEnrollmentWeight(Assignment, Request)` otherwise)
      Parameters:
        `assignment` - current assignment
        `config` - given configuration
        `request` - given request
      Returns:
        current enrollment of the section, excluding the request

    - #### getEnrollment

          protected double getEnrollment(Assignment<Request,Enrollment> assignment,
                                         Section section,
                                         Request request)

      Section enrollment (using `OnlineSection.getEnrollment()` if applicable}, `Section.getEnrollmentWeight(Assignment, Request)` otherwise)
      Parameters:
        `assignment` - current assignment
        `section` - given section
        `request` - given request
      Returns:
        current enrollment of the section, excluding the request

    - #### getLimit

          protected int getLimit(Section section)

      Section limit (using `OnlineSection.getEnrollment()` if applicable}, `Section.getLimit()` otherwise)
      Parameters:
        `section` - given section
      Returns:
        limit of the given section

    - #### getLimit

          protected int getLimit(Subpart subpart)

      Subpart limit (using `OnlineConfig.getEnrollment()` if applicable}, `Subpart.getLimit()` otherwise)
      Parameters:
        `subpart` - given subpart
      Returns:
        limit of the given subpart

    - #### getOverExpected

          public double getOverExpected(Assignment<Request,Enrollment> assignment,
                                        Section section,
                                        Request request)

      Description copied from interface: `OverExpectedCriterion`
      Expectation penalty, to be minimized
      Specified by:
        `getOverExpected` in interface `OverExpectedCriterion`
      Parameters:
        `assignment` - current assignment
        `section` - section in question
        `request` - student course request
      Returns:
        expectation penalty (typically 1.0 / number of subparts when over-expected, 0.0 otherwise)

    - #### getExpected

          public Integer getExpected(int sectionLimit,
                                     double expectedSpace)

      Description copied from interface: `OverExpectedCriterion`
      Expected space, for printing purposes
      Specified by:
        `getExpected` in interface `OverExpectedCriterion`
      Parameters:
        `sectionLimit` - section limit, see `Section.getLimit()`
        `expectedSpace` - expectation, see `Section.getSpaceExpected()`
      Returns:
        expected space to be printed (null if there are no expectations)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`