org.cpsolver.studentsct.heuristics.selection

## Class BranchBoundSelection.Selection

- java.lang.Object
- - org.cpsolver.studentsct.heuristics.selection.BranchBoundSelection.Selection

- Direct Known Subclasses:
    AssignInitialSelection.InitialSelection, CriticalCoursesBranchAndBoundSelection.CriticalCoursesSelection, MinCreditBranchAndBoundSelection.MinCreditSelection, OnlineSelection.EpsilonSelection, SuggestionSelection.Selection
  Enclosing class:
    BranchBoundSelection

      public class BranchBoundSelection.Selection
      extends Object

  Branch & bound selection for a student

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Enrollment[]` | `iAssignment` Current assignment
    `protected Enrollment[]` | `iBestAssignment` Best assignment
    `protected double` | `iBestValue` Best value
    `protected Assignment<Request,Enrollment>` | `iCurrentAssignment` Current assignment
    `protected Student` | `iStudent` Student
    `protected long` | `iT0` Start time
    `protected long` | `iT1` End time
    `protected boolean` | `iTimeoutReached` Was timeout reached
    `protected ArrayList<OnlineSectioningCriterion.TimeToAvoid>` | `iTimesToAvoid` Times to avoid (used when comparing enrollments)
    `protected HashMap<CourseRequest,List<Enrollment>>` | `iValues` Value cache

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Selection(Student student, Assignment<Request,Enrollment> assignment)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated 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
    `Enrollment` | `firstConflict(int idx, Enrollment enrollment)` First conflicting enrollment
    `protected double` | `getAssignmentPenalty(int i)` Assignment penalty
    `Enrollment[]` | `getBestAssignment()` Best schedule
    `int` | `getBestNrAssigned()` Number of requests assigned in the best schedule
    `double` | `getBestValue()` Value of the best schedule
    `double` | `getBound(int idx)` Bound for the current schedule
    `protected double` | `getBound(Request r)` Return bound of a request
    `Set<DistanceConflict.Conflict>` | `getDistanceConflicts(int idx)` Distance conflicts of idx-th assignment of the current schedule
    `int` | `getNrAssigned()` Number of assigned requests in the current schedule
    `int` | `getNrAssignedBound(int idx)` Bound for the number of assigned requests in the current schedule
    `double` | `getPenalty()` Penalty of the current schedule
    `double` | `getPenaltyBound(int idx)` Penalty bound of the current schedule
    `Set<StudentQuality.Conflict>` | `getStudentQualityConflicts(int idx)`
    `long` | `getTime()` Time (in milliseconds) the branch & bound did run
    `Set<TimeOverlapsCounter.Conflict>` | `getTimeOverlappingConflicts(int idx)` Time overlapping conflicts of idx-th assignment of the current schedule
    `double` | `getValue()` Value of the current schedule
    `protected double` | `getWeight(Enrollment enrollment, Set<DistanceConflict.Conflict> distanceConflicts, Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts)` Deprecated.
    `protected double` | `getWeight(Enrollment enrollment, Set<StudentQuality.Conflict> conflicts)`
    `boolean` | `inConflict(int idx, Enrollment enrollment)` True if the enrollment is conflicting
    `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.
    `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

    - #### iStudent

          protected Student iStudent

      Student

    - #### iT0

          protected long iT0

      Start time

    - #### iT1

          protected long iT1

      End time

    - #### iTimeoutReached

          protected boolean iTimeoutReached

      Was timeout reached

    - #### iAssignment

          protected Enrollment[] iAssignment

      Current assignment

    - #### iBestAssignment

          protected Enrollment[] iBestAssignment

      Best assignment

    - #### iBestValue

          protected double iBestValue

      Best value

    - #### iValues

          protected HashMap<CourseRequest,List<Enrollment>> iValues

      Value cache

    - #### iCurrentAssignment

          protected Assignment<Request,Enrollment> iCurrentAssignment

      Current assignment

    - #### iTimesToAvoid

          protected ArrayList<OnlineSectioningCriterion.TimeToAvoid> iTimesToAvoid

      Times to avoid (used when comparing enrollments)

  - ### Constructor Detail

    - #### Selection

          public Selection(Student student,
                           Assignment<Request,Enrollment> assignment)

      Constructor
      Parameters:
        `student` - selected student
        `assignment` - current assignment

  - ### Method Detail

    - #### select

          public BranchBoundSelection.BranchBoundNeighbour select()

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

    - #### isTimeoutReached

          public boolean isTimeoutReached()

      Was timeout reached
      Returns:
        true if the timeout was reached

    - #### getTime

          public long getTime()

      Time (in milliseconds) the branch & bound did run
      Returns:
        solver time

    - #### getBestAssignment

          public Enrollment[] getBestAssignment()

      Best schedule
      Returns:
        best schedule

    - #### getBestValue

          public double getBestValue()

      Value of the best schedule
      Returns:
        value of the best schedule

    - #### getBestNrAssigned

          public int getBestNrAssigned()

      Number of requests assigned in the best schedule
      Returns:
        number of assigned requests in the best schedule

    - #### getNrAssignedBound

          public int getNrAssignedBound(int idx)

      Bound for the number of assigned requests in the current schedule
      Parameters:
        `idx` - index of the request that is being considered
      Returns:
        bound for the given request

    - #### getDistanceConflicts

          public Set<DistanceConflict.Conflict> getDistanceConflicts(int idx)

      Distance conflicts of idx-th assignment of the current schedule
      Parameters:
        `idx` - index of the request
      Returns:
        set of distance conflicts

    - #### getTimeOverlappingConflicts

          public Set<TimeOverlapsCounter.Conflict> getTimeOverlappingConflicts(int idx)

      Time overlapping conflicts of idx-th assignment of the current schedule
      Parameters:
        `idx` - index of the request
      Returns:
        set of time overlapping conflicts

    - #### getStudentQualityConflicts

          public Set<StudentQuality.Conflict> getStudentQualityConflicts(int idx)

    - #### getWeight

          @Deprecated
          protected double getWeight(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.
      Parameters:
        `enrollment` - an enrollment
        `distanceConflicts` - set of distance conflicts
        `timeOverlappingConflicts` - set of time overlapping conflicts
      Returns:
        value of the assignment

    - #### getWeight

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

    - #### getBound

          protected double getBound(Request r)

      Return bound of a request
      Parameters:
        `r` - a request
      Returns:
        bound

    - #### getBound

          public double getBound(int idx)

      Bound for the current schedule
      Parameters:
        `idx` - index of the request
      Returns:
        current bound

    - #### getValue

          public double getValue()

      Value of the current schedule
      Returns:
        value of the current schedule

    - #### getAssignmentPenalty

          protected double getAssignmentPenalty(int i)

      Assignment penalty
      Parameters:
        `i` - index of the request
      Returns:
        assignment penalty

    - #### getPenalty

          public double getPenalty()

      Penalty of the current schedule
      Returns:
        penalty of the current schedule

    - #### getPenaltyBound

          public double getPenaltyBound(int idx)

      Penalty bound of the current schedule
      Parameters:
        `idx` - index of request
      Returns:
        current penalty bound

    - #### 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
      Parameters:
        `idx` - index of request
        `enrollment` - enrollment in question
      Returns:
        true if there is a conflict with previous enrollments

    - #### firstConflict

          public Enrollment firstConflict(int idx,
                                          Enrollment enrollment)

      First conflicting enrollment
      Parameters:
        `idx` - index of request
        `enrollment` - enrollment in question
      Returns:
        first conflicting enrollment

    - #### canAssign

          public boolean canAssign(Request request,
                                   int idx)

      True if the given request can be assigned
      Parameters:
        `request` - given request
        `idx` - index of request
      Returns:
        true if can be assigned

    - #### getNrAssigned

          public int getNrAssigned()

      Number of assigned requests in the current schedule
      Returns:
        number of assigned requests

    - #### canLeaveUnassigned

          protected boolean canLeaveUnassigned(Request request)

      Returns true if the given request can be left unassigned
      Parameters:
        `request` - given request
      Returns:
        true if can be left unassigned

    - #### values

          protected List<Enrollment> values(CourseRequest request)

      Returns list of available enrollments for a course request
      Parameters:
        `request` - given request
      Returns:
        list of enrollments to consider

    - #### backTrack

          public void backTrack(int idx)

      branch & bound search
      Parameters:
        `idx` - index of request