org.cpsolver.studentsct.online.selection

## Class OnlineSectioningCriterion

- java.lang.Object
- - org.cpsolver.studentsct.online.selection.OnlineSectioningCriterion

- All Implemented Interfaces:
    MultiCriteriaBranchAndBoundSelection.SelectionComparator, MultiCriteriaBranchAndBoundSelection.SelectionCriterion
  Direct Known Subclasses:
    EqualWeightCriterion

      public class OnlineSectioningCriterion
      extends Object
      implements MultiCriteriaBranchAndBoundSelection.SelectionCriterion

  Multi-criteria selection criterion. This provides a lexicographical order of solutions using the following criteria:
  - best priority & alternativity ignoring free time requests (a better solution has a higher priority course assigned or does not use alternative request if possible)
  - avoid or minimize course time overlaps
  - minimise use of over-expected classes (this prevents students of getting into classes that we know will be needed later in the process)
  - best priority & alternativity including free time requests (this is to prevent students of gaming the system by adding free time requests)
  - maximise selection (preferred sections)
  - avoid or minimise time overlaps (for classes that are allowed to overlap and for free time requests)
  - avoid or minimise distance conflicts
  - avoid classes that have no time assignment (arranged hours)
  - balance sections
  - minimise class penalties (expressing how much a class is over-expected)
  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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OnlineSectioningCriterion.TimeToAvoid` Time to be avoided.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double[]` | `iQalityWeights`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OnlineSectioningCriterion(Student student, OnlineSectioningModel model, Assignment<Request,Enrollment> assignment, Hashtable<CourseRequest,Set<Section>> preferredSections)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canImprove(Assignment<Request,Enrollment> assignment, int maxIdx, Enrollment[] current, Enrollment[] best)` Bound
    `int` | `compare(Assignment<Request,Enrollment> assignment, Enrollment[] current, Enrollment[] best)` Compare two solutions
    `int` | `compare(Assignment<Request,Enrollment> assignment, Enrollment e1, Enrollment e2)` Compare two enrollments
    `Set<DistanceConflict.Conflict>` | `getDistanceConflicts(Enrollment[] assignment, int idx)` Distance conflicts of idx-th assignment of the current schedule
    `protected OnlineSectioningModel` | `getModel()`
    `protected Set<Section>` | `getPreferredSections(Request request)`
    `Request` | `getRequest(int index)`
    `protected Student` | `getStudent()`
    `Set<StudentQuality.Conflict>` | `getStudentQualityConflicts(Enrollment[] assignment, int idx)`
    `Set<TimeOverlapsCounter.Conflict>` | `getTimeOverlappingConflicts(Enrollment[] assignment, int idx)` Time overlapping conflicts of idx-th assignment of the current schedule
    `protected List<OnlineSectioningCriterion.TimeToAvoid>` | `getTimesToAvoid()`
    `double` | `getTotalWeight(Assignment<Request,Enrollment> assignment, Enrollment[] enrollemnts)` For backward compatibility, return a weighted sum
    `protected double` | `getWeight(Assignment<Request,Enrollment> assignment, Enrollment enrollment, Set<DistanceConflict.Conflict> distanceConflicts, Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts)` Deprecated.
    `protected double` | `getWeight(Assignment<Request,Enrollment> assignment, Enrollment enrollment, Set<StudentQuality.Conflict> conflicts)`
    `boolean` | `isFreeTime(int index)`

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

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

- - ### Field Detail

    - #### iQalityWeights

          protected double[] iQalityWeights

  - ### Constructor Detail

    - #### OnlineSectioningCriterion

          public OnlineSectioningCriterion(Student student,
                                           OnlineSectioningModel model,
                                           Assignment<Request,Enrollment> assignment,
                                           Hashtable<CourseRequest,Set<Section>> preferredSections)

      Constructor
      Parameters:
        `student` - current student
        `model` - online student sectioning model
        `assignment` - current assignment
        `preferredSections` - preferred sections

  - ### Method Detail

    - #### getModel

          protected OnlineSectioningModel getModel()

    - #### getStudent

          protected Student getStudent()

    - #### getPreferredSections

          protected Set<Section> getPreferredSections(Request request)

    - #### getTimesToAvoid

          protected List<OnlineSectioningCriterion.TimeToAvoid> getTimesToAvoid()

    - #### getDistanceConflicts

          public Set<DistanceConflict.Conflict> getDistanceConflicts(Enrollment[] assignment,
                                                                     int idx)

      Distance conflicts of idx-th assignment of the current schedule

    - #### getTimeOverlappingConflicts

          public Set<TimeOverlapsCounter.Conflict> getTimeOverlappingConflicts(Enrollment[] assignment,
                                                                               int idx)

      Time overlapping conflicts of idx-th assignment of the current schedule

    - #### getStudentQualityConflicts

          public Set<StudentQuality.Conflict> getStudentQualityConflicts(Enrollment[] assignment,
                                                                         int idx)

    - #### getWeight

          @Deprecated
          protected double getWeight(Assignment<Request,Enrollment> assignment,
                                                 Enrollment enrollment,
                                                 Set<DistanceConflict.Conflict> distanceConflicts,
                                                 Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts)

      Deprecated.
      Weight of an assignment. Unlike `StudentWeights.getWeight(Assignment, Enrollment, Set, Set)`, only count this side of distance conflicts and time overlaps.

    - #### getWeight

          protected double getWeight(Assignment<Request,Enrollment> assignment,
                                     Enrollment enrollment,
                                     Set<StudentQuality.Conflict> conflicts)

    - #### getRequest

          public Request getRequest(int index)

    - #### isFreeTime

          public boolean isFreeTime(int index)

    - #### compare

          public int compare(Assignment<Request,Enrollment> assignment,
                             Enrollment[] current,
                             Enrollment[] best)

      Description copied from interface: `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      Compare two solutions
      Specified by:
        `compare` in interface `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      Parameters:
        `assignment` - current assignment
        `current` - current solution
        `best` - best known solution
      Returns:
        true if current solution is better than the best one

    - #### canImprove

          public boolean canImprove(Assignment<Request,Enrollment> assignment,
                                    int maxIdx,
                                    Enrollment[] current,
                                    Enrollment[] best)

      Description copied from interface: `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      Bound
      Specified by:
        `canImprove` in interface `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      Parameters:
        `assignment` - current assignment
        `maxIdx` - current request index
        `current` - current solution
        `best` - best known solution
      Returns:
        if the current solution can be extended and possibly improve upon the best known solution

    - #### getTotalWeight

          public double getTotalWeight(Assignment<Request,Enrollment> assignment,
                                       Enrollment[] enrollemnts)

      Description copied from interface: `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      For backward compatibility, return a weighted sum
      Specified by:
        `getTotalWeight` in interface `MultiCriteriaBranchAndBoundSelection.SelectionCriterion`
      Parameters:
        `assignment` - current assignment
        `enrollemnts` - current solution
      Returns:
        solution weight (weighted sum)

    - #### compare

          public int compare(Assignment<Request,Enrollment> assignment,
                             Enrollment e1,
                             Enrollment e2)

      Description copied from interface: `MultiCriteriaBranchAndBoundSelection.SelectionComparator`
      Compare two enrollments
      Specified by:
        `compare` in interface `MultiCriteriaBranchAndBoundSelection.SelectionComparator`
      Parameters:
        `assignment` - current assignment
        `e1` - first enrollment
        `e2` - second enrollment
      Returns:
        -1 if the first enrollment is better than the second etc.