org.cpsolver.studentsct.online.selection

## Class MultiCriteriaBranchAndBoundSelection

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

- All Implemented Interfaces:
    OnlineSectioningSelection

      public class MultiCriteriaBranchAndBoundSelection
      extends Object
      implements OnlineSectioningSelection

  Online student sectioning algorithm using multi-criteria selection. It is very similar to the `SuggestionSelection`, however, the {link `OnlineSelection` is used to compare two solutions and for branching.
  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 interface` | `MultiCriteriaBranchAndBoundSelection.SelectionComparator` Enrollment comparator
    `static interface` | `MultiCriteriaBranchAndBoundSelection.SelectionCriterion` Multi-criteria selection interface.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Assignment<Request,Enrollment>` | `iAssignment`
    `protected Enrollment[]` | `iBestAssignment` Best assignment
    `protected boolean` | `iBranchWhenSelectedHasNoConflict`
    `protected MultiCriteriaBranchAndBoundSelection.SelectionCriterion` | `iComparator`
    `protected Enrollment[]` | `iCurrentAssignment` Current assignment
    `protected OnlineSectioningModel` | `iModel`
    `protected Student` | `iStudent` Student
    `protected long` | `iT0` Start time
    `protected long` | `iT1` End time
    `protected int` | `iTimeout`
    `protected boolean` | `iTimeoutReached` Was timeout reached
    `protected HashMap<CourseRequest,List<Enrollment>>` | `iValues` Value cache

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiCriteriaBranchAndBoundSelection(DataProperties config)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `backTrack(int idx)` branch & bound search
    `boolean` | `canAssign(Request request, int idx)` True if the given request can be assigned
    `protected boolean` | `canLeaveUnassigned(Request request)` Returns true if the given request can be left unassigned
    `long` | `getTime()` Time (in milliseconds) the branch & bound did run
    `boolean` | `inConflict(int idx, Enrollment enrollment)` True if the enrollment is conflicting
    `boolean` | `isAllowed(int idx, Enrollment enrollment)`
    `boolean` | `isTimeoutReached()` Was timeout reached
    `void` | `saveBest()` Save the current schedule as the best
    `BranchBoundSelection.BranchBoundNeighbour` | `select()` Execute branch & bound, return the best found schedule for the selected student.
    `BranchBoundSelection.BranchBoundNeighbour` | `select(Assignment<Request,Enrollment> assignment, Student student)` Compute student schedule
    `BranchBoundSelection.BranchBoundNeighbour` | `select(Assignment<Request,Enrollment> assignment, Student student, MultiCriteriaBranchAndBoundSelection.SelectionCriterion comparator)`
    `void` | `setMaxOverExpected(double maxOverExpected)` Set hard limit on the `OverExpectedCriterion` penalty.
    `void` | `setModel(OnlineSectioningModel model)` Set online sectioning model
    `void` | `setPreferredSections(Hashtable<CourseRequest,Set<Section>> preferredSections)` Set preferred sections
    `void` | `setRequiredFreeTimes(Set<FreeTimeRequest> requiredFreeTimes)` Set required free times
    `void` | `setRequiredSections(Hashtable<CourseRequest,Set<Section>> requiredSections)` Set required sections
    `void` | `setRequiredUnassinged(Set<CourseRequest> requiredUnassignedRequests)` Set course requests that are to be left unassigned
    `void` | `setTimeout(int timeout)`
    `protected List<Enrollment>` | `values(CourseRequest request)` Returns list of available enrollments for a course request

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

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

- - ### Field Detail

    - #### iTimeout

          protected int iTimeout

    - #### iModel

          protected OnlineSectioningModel iModel

    - #### iAssignment

          protected Assignment<Request,Enrollment> iAssignment

    - #### iComparator

          protected MultiCriteriaBranchAndBoundSelection.SelectionCriterion iComparator

    - #### iBranchWhenSelectedHasNoConflict

          protected boolean iBranchWhenSelectedHasNoConflict

    - #### iStudent

          protected Student iStudent

      Student

    - #### iT0

          protected long iT0

      Start time

    - #### iT1

          protected long iT1

      End time

    - #### iTimeoutReached

          protected boolean iTimeoutReached

      Was timeout reached

    - #### iCurrentAssignment

          protected Enrollment[] iCurrentAssignment

      Current assignment

    - #### iBestAssignment

          protected Enrollment[] iBestAssignment

      Best assignment

    - #### iValues

          protected HashMap<CourseRequest,List<Enrollment>> iValues

      Value cache

  - ### Constructor Detail

    - #### MultiCriteriaBranchAndBoundSelection

          public MultiCriteriaBranchAndBoundSelection(DataProperties config)

  - ### Method Detail

    - #### setModel

          public void setModel(OnlineSectioningModel model)

      Description copied from interface: `OnlineSectioningSelection`
      Set online sectioning model
      Specified by:
        `setModel` in interface `OnlineSectioningSelection`
      Parameters:
        `model` - online sectioning model

    - #### setPreferredSections

          public void setPreferredSections(Hashtable<CourseRequest,Set<Section>> preferredSections)

      Description copied from interface: `OnlineSectioningSelection`
      Set preferred sections
      Specified by:
        `setPreferredSections` in interface `OnlineSectioningSelection`
      Parameters:
        `preferredSections` - preferred sections for each course request

    - #### setTimeout

          public void setTimeout(int timeout)

    - #### setRequiredSections

          public void setRequiredSections(Hashtable<CourseRequest,Set<Section>> requiredSections)

      Description copied from interface: `OnlineSectioningSelection`
      Set required sections
      Specified by:
        `setRequiredSections` in interface `OnlineSectioningSelection`
      Parameters:
        `requiredSections` - required sections for each course request

    - #### setRequiredFreeTimes

          public void setRequiredFreeTimes(Set<FreeTimeRequest> requiredFreeTimes)

      Description copied from interface: `OnlineSectioningSelection`
      Set required free times
      Specified by:
        `setRequiredFreeTimes` in interface `OnlineSectioningSelection`
      Parameters:
        `requiredFreeTimes` - required free times

    - #### select

          public BranchBoundSelection.BranchBoundNeighbour select(Assignment<Request,Enrollment> assignment,
                                                                  Student student,
                                                                  MultiCriteriaBranchAndBoundSelection.SelectionCriterion comparator)

    - #### select

          public BranchBoundSelection.BranchBoundNeighbour select(Assignment<Request,Enrollment> assignment,
                                                                  Student student)

      Description copied from interface: `OnlineSectioningSelection`
      Compute student schedule
      Specified by:
        `select` in interface `OnlineSectioningSelection`
      Parameters:
        `assignment` - current assignment
        `student` - student in question
      Returns:
        student schedule

    - #### select

          public BranchBoundSelection.BranchBoundNeighbour select()

      Execute branch & bound, return the best found schedule for the selected student.

    - #### isTimeoutReached

          public boolean isTimeoutReached()

      Was timeout reached

    - #### getTime

          public long getTime()

      Time (in milliseconds) the branch & bound did run

    - #### saveBest

          public void saveBest()

      Save the current schedule as the best

    - #### inConflict

          public boolean inConflict(int idx,
                                    Enrollment enrollment)

      True if the enrollment is conflicting

    - #### canAssign

          public boolean canAssign(Request request,
                                   int idx)

      True if the given request can be assigned

    - #### isAllowed

          public boolean isAllowed(int idx,
                                   Enrollment enrollment)

    - #### canLeaveUnassigned

          protected boolean canLeaveUnassigned(Request request)

      Returns true if the given request can be left unassigned

    - #### values

          protected List<Enrollment> values(CourseRequest request)

      Returns list of available enrollments for a course request

    - #### backTrack

          public void backTrack(int idx)

      branch & bound search

    - #### setRequiredUnassinged

          public void setRequiredUnassinged(Set<CourseRequest> requiredUnassignedRequests)

      Description copied from interface: `OnlineSectioningSelection`
      Set course requests that are to be left unassigned
      Specified by:
        `setRequiredUnassinged` in interface `OnlineSectioningSelection`
      Parameters:
        `requiredUnassignedRequests` - course requests that are required to be left unassigned

    - #### setMaxOverExpected

          public void setMaxOverExpected(double maxOverExpected)

      Description copied from interface: `OnlineSectioningSelection`
      Set hard limit on the `OverExpectedCriterion` penalty.
      Specified by:
        `setMaxOverExpected` in interface `OnlineSectioningSelection`
      Parameters:
        `maxOverExpected` - max over-expected limit