org.cpsolver.coursett.model

## Class TimeLocation

- java.lang.Object
- - org.cpsolver.coursett.model.TimeLocation

- Direct Known Subclasses:
    EnrolledClass

      public class TimeLocation
      extends Object

  Time part of placement.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    Copyright (C) 2006 - 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 interface` | `TimeLocation.IntEnumeration`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeLocation(int dayCode, int startTime, int length, int pref, double normPref, int datePatternPreference, Long datePatternId, String datePatternName, BitSet weekCode, int breakTime)` Constructor
    `TimeLocation(int dayCode, int startTime, int length, int pref, double normPref, Long datePatternId, String datePatternName, BitSet weekCode, int breakTime)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countDates(int dayOfWeekOffset)` Count how many times this time location is meeting
    `boolean` | `equals(Object o)`
    `int` | `getBreakTime()`
    `Long` | `getDatePatternId()`
    `String` | `getDatePatternName()`
    `int` | `getDatePatternPreference()`
    `TimeLocation.IntEnumeration` | `getDates(int dayOfWeekOffset)` List dates when this time location meets.
    `int` | `getDayCode()` Days (combination of 1 for Monday, 2 for Tuesday, ...)
    `String` | `getDayHeader()` Days for printing purposes
    `TimeLocation.IntEnumeration` | `getDays()` Days
    `int[]` | `getDaysArray()`
    `String` | `getEndTimeHeader()` Deprecated.
    `String` | `getEndTimeHeader(boolean useAmPm)` End time for printing purposes
    `String` | `getEndTimeHeaderNoAdj()` Deprecated.
    `String` | `getEndTimeHeaderNoAdj(boolean useAmPm)` End time for printing purposes
    `int` | `getFirstMeeting(int dayOfWeekOffset)`
    `int` | `getLastMeeting(int dayOfWeekOffset)`
    `int` | `getLength()` Length
    `String` | `getLongName()` Deprecated.
    `String` | `getLongName(boolean useAmPm)`
    `String` | `getLongNameNoAdj()`
    `String` | `getLongNameNoAdj(boolean useAmPm)`
    `String` | `getName()` Deprecated.
    `String` | `getName(boolean useAmPm)` Text representation
    `double` | `getNormalizedPreference()` Normalized preference
    `int` | `getNrMeetings()` Number of meetings
    `int` | `getNrSlotsPerMeeting()` Length
    `int` | `getNrWeeks()`
    `int` | `getNrWeeks(int startDay, int endDay)`
    `int` | `getPreference()` Preference
    `TimeLocation.IntEnumeration` | `getSlots()` Used slots
    `int` | `getStartSlot()` Start slot
    `TimeLocation.IntEnumeration` | `getStartSlots()` Used start slots (for each meeting)
    `String` | `getStartTimeHeader()` Deprecated.
    `String` | `getStartTimeHeader(boolean useAmPm)` Start time for printing purposes
    `Long` | `getTimePatternId()` Time pattern model (can be null)
    `BitSet` | `getWeekCode()`
    `boolean` | `hasDate(int dayOfWeek, BitSet week, int dayOfWeekOffset)` Check if the time location has the given date, identified by a day of the week and a week pattern
    `boolean` | `hasDate(int date, int dayOfWeekOffset)` Check if the given time location has a particular date
    `boolean` | `hasDay(int day)`
    `int` | `hashCode()`
    `boolean` | `hasIntersection(TimeLocation anotherLocation)` true if overlap
    `int` | `nrSharedDays(TimeLocation anotherLocation)` number of overlapping days
    `int` | `nrSharedHours(TimeLocation anotherLocation)` number of overlapping time slots (ignoring days)
    `boolean` | `overlaps(int dayCode, BitSet weekCode, int dayOfWeekOffset)` Check if the time location has at least one date from a set identified by a day code and a bit set.
    `void` | `setBreakTime(int breakTime)`
    `void` | `setDatePattern(Long datePatternId, String datePatternName, BitSet weekCode)`
    `void` | `setNormalizedPreference(double normalizedPreference)`
    `void` | `setPreference(int preference)`
    `void` | `setTimePatternId(Long timePatternId)`
    `boolean` | `shareDays(TimeLocation anotherLocation)` true if days overlap
    `boolean` | `shareHours(TimeLocation anotherLocation)` true if hours overlap
    `boolean` | `shareWeeks(BitSet weekCode)` true if weeks overlap
    `boolean` | `shareWeeks(TimeLocation anotherLocation)` true if weeks overlap
    `String` | `toString()`

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

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

- - ### Constructor Detail

    - #### TimeLocation

          public TimeLocation(int dayCode,
                              int startTime,
                              int length,
                              int pref,
                              double normPref,
                              int datePatternPreference,
                              Long datePatternId,
                              String datePatternName,
                              BitSet weekCode,
                              int breakTime)

      Constructor
      Parameters:
        `dayCode` - days (combination of 1 for Monday, 2 for Tuesday, ...)
        `startTime` - start slot
        `length` - number of slots
        `pref` - time preference
        `normPref` - normalized preference
        `datePatternPreference` - date pattern preference
        `datePatternId` - date pattern unique id
        `datePatternName` - date pattern name
        `weekCode` - date pattern (binary string with 1 for each day when classes take place)
        `breakTime` - break time in minutes

    - #### TimeLocation

          public TimeLocation(int dayCode,
                              int startTime,
                              int length,
                              int pref,
                              double normPref,
                              Long datePatternId,
                              String datePatternName,
                              BitSet weekCode,
                              int breakTime)

  - ### Method Detail

    - #### getNrMeetings

          public int getNrMeetings()

      Number of meetings
      Returns:
        number of meetings

    - #### getBreakTime

          public int getBreakTime()

    - #### setBreakTime

          public void setBreakTime(int breakTime)

    - #### getDayCode

          public int getDayCode()

      Days (combination of 1 for Monday, 2 for Tuesday, ...)
      Returns:
        days of the week of this time

    - #### getDayHeader

          public String getDayHeader()

      Days for printing purposes
      Returns:
        day header (e.g., MWF for Monday - Wednesday - Friday time)

    - #### getStartTimeHeader

          public String getStartTimeHeader(boolean useAmPm)

      Start time for printing purposes
      Parameters:
        `useAmPm` - use 12-hour format
      Returns:
        time header (e.g., 7:30a)

    - #### getStartTimeHeader

          @Deprecated
          public String getStartTimeHeader()

      Deprecated.
      Start time for printing purposes
      Returns:
        time header (e.g., 7:30a)

    - #### getEndTimeHeader

          public String getEndTimeHeader(boolean useAmPm)

      End time for printing purposes
      Parameters:
        `useAmPm` - use 12-hour format
      Returns:
        end time (e.g., 8:20a)

    - #### getEndTimeHeader

          @Deprecated
          public String getEndTimeHeader()

      Deprecated.
      End time for printing purposes
      Returns:
        end time (e.g., 8:20a)

    - #### getEndTimeHeaderNoAdj

          public String getEndTimeHeaderNoAdj(boolean useAmPm)

      End time for printing purposes
      Parameters:
        `useAmPm` - use 12-hour format
      Returns:
        end time not counting break time (e.g., 8:30a)

    - #### getEndTimeHeaderNoAdj

          @Deprecated
          public String getEndTimeHeaderNoAdj()

      Deprecated.
      End time for printing purposes
      Returns:
        end time not counting break time (e.g., 8:30a)

    - #### getStartSlot

          public int getStartSlot()

      Start slot
      Returns:
        start slot

    - #### shareDays

          public boolean shareDays(TimeLocation anotherLocation)

      true if days overlap
      Parameters:
        `anotherLocation` - another time
      Returns:
        true if days of the week overlaps

    - #### nrSharedDays

          public int nrSharedDays(TimeLocation anotherLocation)

      number of overlapping days
      Parameters:
        `anotherLocation` - another time
      Returns:
        number of days of the week that the two times share

    - #### shareHours

          public boolean shareHours(TimeLocation anotherLocation)

      true if hours overlap
      Parameters:
        `anotherLocation` - another time
      Returns:
        true if the two times overlap in time (just the time of the day is considered)

    - #### nrSharedHours

          public int nrSharedHours(TimeLocation anotherLocation)

      number of overlapping time slots (ignoring days)
      Parameters:
        `anotherLocation` - another time
      Returns:
        number of time slots the two location overlap

    - #### shareWeeks

          public boolean shareWeeks(TimeLocation anotherLocation)

      true if weeks overlap
      Parameters:
        `anotherLocation` - another time
      Returns:
        true if the date patterns overlap

    - #### shareWeeks

          public boolean shareWeeks(BitSet weekCode)

      true if weeks overlap
      Parameters:
        `weekCode` - another date pattern
      Returns:
        true if the date patterns overlap

    - #### hasDay

          public boolean hasDay(int day)

    - #### hasIntersection

          public boolean hasIntersection(TimeLocation anotherLocation)

      true if overlap
      Parameters:
        `anotherLocation` - another time
      Returns:
        true if the two times overlap, this means that all three checks `shareDays(TimeLocation)`, `shareHours(TimeLocation)` and `shareWeeks(TimeLocation)` are true.

    - #### getSlots

          public TimeLocation.IntEnumeration getSlots()

      Used slots
      Returns:
        enumeration of used slots

    - #### getStartSlots

          public TimeLocation.IntEnumeration getStartSlots()

      Used start slots (for each meeting)
      Returns:
        enumeration of start slots for each meeting of the time

    - #### getDays

          public TimeLocation.IntEnumeration getDays()

      Days
      Returns:
        enumeration of days of week of the time

    - #### getDaysArray

          public int[] getDaysArray()

    - #### getName

          public String getName(boolean useAmPm)

      Text representation
      Parameters:
        `useAmPm` - 12-hour format
      Returns:
        time name (e.g., MWF 7:30a)

    - #### getName

          @Deprecated
          public String getName()

      Deprecated.

    - #### getLongName

          public String getLongName(boolean useAmPm)

    - #### getLongName

          @Deprecated
          public String getLongName()

      Deprecated.

    - #### getLongNameNoAdj

          public String getLongNameNoAdj(boolean useAmPm)

    - #### getLongNameNoAdj

          public String getLongNameNoAdj()

    - #### getPreference

          public int getPreference()

      Preference
      Returns:
        time preference

    - #### setPreference

          public void setPreference(int preference)

    - #### getLength

          public int getLength()

      Length
      Returns:
        time length (in the number of slots)

    - #### getNrSlotsPerMeeting

          public int getNrSlotsPerMeeting()

      Length
      Returns:
        time length (in the number of slots)

    - #### getNormalizedPreference

          public double getNormalizedPreference()

      Normalized preference
      Returns:
        normalized preference

    - #### setNormalizedPreference

          public void setNormalizedPreference(double normalizedPreference)

    - #### getTimePatternId

          public Long getTimePatternId()

      Time pattern model (can be null)
      Returns:
        time pattern unique id

    - #### getDatePatternId

          public Long getDatePatternId()

    - #### setTimePatternId

          public void setTimePatternId(Long timePatternId)

    - #### getWeekCode

          public BitSet getWeekCode()

    - #### getDatePatternName

          public String getDatePatternName()

    - #### setDatePattern

          public void setDatePattern(Long datePatternId,
                                     String datePatternName,
                                     BitSet weekCode)

    - #### getDatePatternPreference

          public int getDatePatternPreference()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### getNrWeeks

          public int getNrWeeks()

    - #### getNrWeeks

          public int getNrWeeks(int startDay,
                                int endDay)

    - #### getFirstMeeting

          public int getFirstMeeting(int dayOfWeekOffset)

    - #### getLastMeeting

          public int getLastMeeting(int dayOfWeekOffset)

    - #### getDates

          public TimeLocation.IntEnumeration getDates(int dayOfWeekOffset)

      List dates when this time location meets.
      Returns:
        enumeration of dates of this time (indexes to the `getWeekCode()` for matching days of the week)

    - #### hasDate

          public boolean hasDate(int date,
                                 int dayOfWeekOffset)

      Check if the given time location has a particular date
      Parameters:
        `date` - a date, expressed as an index to the `getWeekCode()`
        `dayOfWeekOffset` - day of the week offset for the weeks pattern
      Returns:
        true if this time location is meeting on the given date

    - #### hasDate

          public boolean hasDate(int dayOfWeek,
                                 BitSet week,
                                 int dayOfWeekOffset)

      Check if the time location has the given date, identified by a day of the week and a week pattern
      Parameters:
        `dayOfWeek` - day of the week
        `week` - week pattern, or null when only days of the week are to be checked
        `dayOfWeekOffset` - day of the week offset for the weeks pattern
      Returns:
        true if this time location is meeting on the given date

    - #### overlaps

          public boolean overlaps(int dayCode,
                                  BitSet weekCode,
                                  int dayOfWeekOffset)

      Check if the time location has at least one date from a set identified by a day code and a bit set. Precise computation of individual dates are used instead of just checking whether the day codes and week codes are overlapping.
      Parameters:
        `dayCode` - day codes
        `weekCode` - week code
        `dayOfWeekOffset` - day of the week offset for the weeks pattern
      Returns:
        true if there is at least one overlapping date

    - #### countDates

          public int countDates(int dayOfWeekOffset)

      Count how many times this time location is meeting
      Parameters:
        `dayOfWeekOffset` - day of the week offset for the weeks pattern
      Returns:
        number of dates during which this time location is meeting