net.sf.cpsolver.exam.model
Class ExamPeriod

java.lang.Object
  extended by net.sf.cpsolver.exam.model.ExamPeriod
All Implemented Interfaces:
Comparable

public class ExamPeriod
extends Object
implements Comparable

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.1 (Examination Timetabling)
Copyright (C) 2007 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

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 2.1 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Constructor Summary
ExamPeriod(Long id, String day, String time, int length, int penalty)
          Constructor
 
Method Summary
 int compareTo(Object o)
           
 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
 int getTime()
          Time index
 String getTimeStr()
          Time string, e.g., 8:00am-10:00am
 int hashCode()
           
 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))
 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


setId

public void setId(Long id)
Period unique identifier


getDayStr

public String getDayStr()
Day string, e.g., 07/12/10


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


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(Object o)
Specified by:
compareTo in interface Comparable