net.sf.cpsolver.studentsct.heuristics.selection

## Class BranchBoundSelection.Selection

- java.lang.Object
- - net.sf.cpsolver.studentsct.heuristics.selection.BranchBoundSelection.Selection

- Direct Known Subclasses:
    OnlineSelection.EpsilonSelection
  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 Student` | `iStudent` Student
    `protected long` | `iT0` Start time
    `protected long` | `iT1` End time
    `protected boolean` | `iTimeoutReached` Was timeout reached
    `protected HashMap<CourseRequest,List<Enrollment>>` | `iValues` Value cache

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Selection(Student student)` Constructor

  - ### 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
    `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
    `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)` Weight of an assignment.
    `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

  - ### Constructor Detail

    - #### Selection

          public Selection(Student student)

      Constructor
      Parameters:
        `student` - selected student

  - ### Method Detail

    - #### 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

    - #### getBestAssignment

          public Enrollment[] getBestAssignment()

      Best schedule

    - #### getBestValue

          public double getBestValue()

      Value of the best schedule

    - #### getBestNrAssigned

          public int getBestNrAssigned()

      Number of requests assigned in the best schedule

    - #### getNrAssignedBound

          public int getNrAssignedBound(int idx)

      Bound for the number of assigned requests in the current schedule

    - #### getDistanceConflicts

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

      Distance conflicts of idx-th assignment of the current schedule

    - #### getTimeOverlappingConflicts

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

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

    - #### getWeight

          protected double getWeight(Enrollment enrollment,
                                     Set<DistanceConflict.Conflict> distanceConflicts,
                                     Set<TimeOverlapsCounter.Conflict> timeOverlappingConflicts)

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

    - #### getBound

          protected double getBound(Request r)

      Return bound of a request

    - #### getBound

          public double getBound(int idx)

      Bound for the current schedule

    - #### getValue

          public double getValue()

      Value of the current schedule

    - #### getAssignmentPenalty

          protected double getAssignmentPenalty(int i)

      Assignment penalty

    - #### getPenalty

          public double getPenalty()

      Penalty of the current schedule

    - #### getPenaltyBound

          public double getPenaltyBound(int idx)

      Penalty bound of the current schedule

    - #### 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

    - #### firstConflict

          public Enrollment firstConflict(int idx,
                                          Enrollment enrollment)

      First conflicting enrollment

    - #### canAssign

          public boolean canAssign(Request request,
                                   int idx)

      True if the given request can be assigned

    - #### getNrAssigned

          public int getNrAssigned()

      Number of assigned requests in the current schedule

    - #### 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