org.cpsolver.exam.model

## Class ExamPeriod

- java.lang.Object
- - org.cpsolver.exam.model.ExamPeriod

- All Implemented Interfaces:
    Comparable<ExamPeriod>

      public class ExamPeriod
      extends Object
      implements Comparable<ExamPeriod>

  Representation of an examination period. Examination timetabling model contains a list of non-overlapping examination periods. Each period has a day, starting time and a length (in minutes) defined. Each exam is to be assigned to one period that is available for the exam and that is of the same of greater length than the exam.
  A penalty weight (`getPenalty()`) can be assigned to each period. It is used to penalize unpopular examination times (e.g., evening or last-day).
  A list of periods is to be defined using `ExamModel.addPeriod(Long, String, String, int, int)`, inserting periods in the order of increasing days and times.
  Version:
    ExamTT 1.3 (Examination Timetabling)
    Copyright (C) 2007 - 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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExamPeriod(Long id, String day, String time, int length, int penalty)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(ExamPeriod p)`
    `boolean` | `equals(Object o)`
    `int` | `getDay()` Day index
    `String` | `getDayStr()` Day string, e.g., 07/12/10
    `Long` | `getId()` Period unique identifier
    `int` | `getIndex()` Period index
    `int` | `getLength()` Length of period in minutes
    `int` | `getPenalty()` Period weight to be used to penalize unpopular periods
    `Integer` | `getStartTime()`
    `int` | `getTime()` Time index
    `String` | `getTimeStr()` Time string, e.g., 8:00am-10:00am
    `int` | `hashCode()`
    `boolean` | `hasIntersection(Exam x1, Exam x2, ExamPeriod p)` Check if the first exam assigned to this period overlaps with the second exam assigned in the given period period
    `boolean` | `hasIntersection(ExamPeriod p)` Check if this period overlaps with the given period
    `ExamPeriod` | `next()` Next period
    `ExamPeriod` | `prev()` Previous period
    `void` | `setId(Long id)` Period unique identifier
    `void` | `setIndex(int index, int day, int time)` Set priod indexes (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
    `void` | `setNext(ExamPeriod next)` Set next period (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
    `void` | `setPrev(ExamPeriod prev)` Set previous period (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
    `void` | `setStartTime(Integer startTime)`
    `String` | `toDebugString()` String representation for debuging purposes
    `String` | `toString()` String representation

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

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

- - ### Constructor Detail

    - #### ExamPeriod

          public ExamPeriod(Long id,
                            String day,
                            String time,
                            int length,
                            int penalty)

      Constructor
      Parameters:
        `id` - period unique identifier
        `day` - day (e.g., 07/12/10)
        `time` - (e.g., 8:00am-10:00am)
        `length` - length of period in minutes
        `penalty` - penalization of using this period

  - ### Method Detail

    - #### getId

          public Long getId()

      Period unique identifier
      Returns:
        period unique id

    - #### setId

          public void setId(Long id)

      Period unique identifier
      Parameters:
        `id` - period unique id

    - #### getDayStr

          public String getDayStr()

      Day string, e.g., 07/12/10
      Returns:
        day of the period

    - #### getDay

          public int getDay()

      Day index
      Returns:
        index of the day within all days that are used for examination

    - #### getTimeStr

          public String getTimeStr()

      Time string, e.g., 8:00am-10:00am
      Returns:
        time of the period

    - #### getTime

          public int getTime()

      Time index
      Returns:
        index of the time within all time that are used for examination on the same day

    - #### getLength

          public int getLength()

      Length of period in minutes
      Returns:
        period length

    - #### getIndex

          public int getIndex()

      Period index
      Returns:
        index of the period within all examination periods

    - #### getPenalty

          public int getPenalty()

      Period weight to be used to penalize unpopular periods
      Returns:
        period weight

    - #### prev

          public ExamPeriod prev()

      Previous period
      Returns:
        period with index equal to index-1, null if this is the first period

    - #### next

          public ExamPeriod next()

      Next period
      Returns:
        period with index equal to index+1, null if this is the last period

    - #### setIndex

          public void setIndex(int index,
                               int day,
                               int time)

      Set priod indexes (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
      Parameters:
        `index` - period index
        `day` - day index
        `time` - time index

    - #### setPrev

          public void setPrev(ExamPeriod prev)

      Set previous period (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
      Parameters:
        `prev` - previous period

    - #### setNext

          public void setNext(ExamPeriod next)

      Set next period (only to be used by `ExamModel.addPeriod(Long, String, String, int, int)`)
      Parameters:
        `next` - next period

    - #### toString

          public String toString()

      String representation
      Overrides:
        `toString` in class `Object`
      Returns:
        day string time string

    - #### toDebugString

          public String toDebugString()

      String representation for debuging purposes
      Returns:
        day string time string (idx: index, day: day index, time: time index, weight: period penalty, prev: previous period, next: next period)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### compareTo

          public int compareTo(ExamPeriod p)

      Specified by:
        `compareTo` in interface `Comparable<ExamPeriod>`

    - #### getStartTime

          public Integer getStartTime()

    - #### setStartTime

          public void setStartTime(Integer startTime)

    - #### hasIntersection

          public boolean hasIntersection(ExamPeriod p)

      Check if this period overlaps with the given period
      Parameters:
        `p` - other period
      Returns:
        true if the two periods overlap in time (considering period lengths)

    - #### hasIntersection

          public boolean hasIntersection(Exam x1,
                                         Exam x2,
                                         ExamPeriod p)

      Check if the first exam assigned to this period overlaps with the second exam assigned in the given period period
      Parameters:
        `x1` - exam of this period
        `x2` - the other exam (of the period p)
        `p` - other period
      Returns:
        true if the two periods overlap in time (considering examination lengths)