net.sf.cpsolver.exam.model
Class ExamRoom

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint<Exam,ExamPlacement>
      extended by net.sf.cpsolver.exam.model.ExamRoom
All Implemented Interfaces:
Comparable<Constraint<Exam,ExamPlacement>>

public class ExamRoom
extends Constraint<Exam,ExamPlacement>

A room. Only one exam can use a room at a time (period).

Version:
ExamTT 1.2 (Examination Timetabling)
Copyright (C) 2008 - 2010 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/.

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint
iAssignedVariables, iConstraintListeners, iId
 
Constructor Summary
ExamRoom(ExamModel model, long id, String name, int size, int altSize, Double coordX, Double coordY)
          Constructor
 
Method Summary
 void afterAssigned(long iteration, ExamPlacement p)
          An exam was assigned, update room assignment table
 void afterUnassigned(long iteration, ExamPlacement p)
          An exam was unassigned, update room assignment table
 void assigned(long iteration, ExamPlacement p)
          An exam was assigned, update room assignment table
 int compareTo(Constraint<Exam,ExamPlacement> o)
          Compare two rooms (by unique id)
 void computeConflicts(ExamPlacement p, Set<ExamPlacement> conflicts)
          Compute conflicts between the given assignment of an exam and all the current assignments (of this room)
 boolean equals(Object o)
          Checks two rooms for equality
 int getAltSize()
          Alternating seating capacity (to be used when Exam.hasAltSeating() is true)
 Double getCoordX()
          X coordinate
 Double getCoordY()
          Y coordinate
 double getDistanceInMeters(ExamRoom other)
          Distance between two rooms.
 String getName()
          Room name
 int getPenalty(ExamPeriod period)
          Return room penalty for given period
 int getPenalty(int period)
           
 ExamPlacement getPlacement(ExamPeriod period)
          Deprecated. If room sharing is allowed, this method only returns first exam. Use getPlacements(ExamPeriod) instead.
 List<ExamPlacement> getPlacements(ExamPeriod period)
          Exams placed at the given period
 ExamRoomSharing getRoomSharing()
           
 int getSize()
          Normal seating capacity (to be used when Exam.hasAltSeating() is false)
 int hashCode()
          Hash code
 boolean hasName()
          Room name
 boolean inConflict(ExamPlacement p)
          Checks whether there is a conflict between the given assignment of an exam and all the current assignments (of this room)
 boolean isAvailable()
          True if the room is available during at least one period,
 boolean isAvailable(ExamPeriod period)
          True if the room is available (for examination timetabling) during the given period
 boolean isAvailable(int period)
           
 boolean isConsistent(ExamPlacement p1, ExamPlacement p2)
          False if the given two assignments are using this room at the same period
 void setAvailable(ExamPeriod period, boolean available)
          Set whether the room is available (for examination timetabling) during the given period
 void setAvailable(int period, boolean available)
           
 void setPenalty(ExamPeriod period, int penalty)
          Set room penalty for given period
 void setPenalty(int period, int penalty)
           
 String toString()
          Room unique id
 void unassigned(long iteration, ExamPlacement p)
          An exam was unassigned, update room assignment table
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, addVariable, assignedVariables, constraintListeners, countAssignedVariables, countVariables, getDescription, getId, getModel, isHard, removeConstraintListener, removeVariable, setModel, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExamRoom

public ExamRoom(ExamModel model,
                long id,
                String name,
                int size,
                int altSize,
                Double coordX,
                Double coordY)
Constructor

Parameters:
model - examination timetabling model
id - unique id
size - room (normal) seating capacity
altSize - room alternating seating capacity (to be used when Exam.hasAltSeating() is true)
coordX - x coordinate
coordY - y coordinate
Method Detail

getDistanceInMeters

public double getDistanceInMeters(ExamRoom other)
Distance between two rooms. See DistanceMetric

Parameters:
other - another room
Returns:
distance between this and the given room

getSize

public int getSize()
Normal seating capacity (to be used when Exam.hasAltSeating() is false)


getAltSize

public int getAltSize()
Alternating seating capacity (to be used when Exam.hasAltSeating() is true)


getCoordX

public Double getCoordX()
X coordinate


getCoordY

public Double getCoordY()
Y coordinate


getPlacement

@Deprecated
public ExamPlacement getPlacement(ExamPeriod period)
Deprecated. If room sharing is allowed, this method only returns first exam. Use getPlacements(ExamPeriod) instead.

An exam placed at the given period.

Parameters:
period - a period
Returns:
a placement of an exam in this room at the given period, null if unused

getPlacements

public List<ExamPlacement> getPlacements(ExamPeriod period)
Exams placed at the given period

Parameters:
period - a period
Returns:
a placement of an exam in this room at the given period, null if unused (multiple placements can be returned if the room is shared between two or more exams)

isAvailable

public boolean isAvailable(ExamPeriod period)
True if the room is available (for examination timetabling) during the given period

Parameters:
period - a period
Returns:
true if an exam can be scheduled into this room at the given period, false if otherwise

isAvailable

public boolean isAvailable(int period)

isAvailable

public boolean isAvailable()
True if the room is available during at least one period,

Returns:
true if there is an examination period at which the room is available

setAvailable

public void setAvailable(ExamPeriod period,
                         boolean available)
Set whether the room is available (for examination timetabling) during the given period

Parameters:
period - a period
available - true if an exam can be scheduled into this room at the given period, false if otherwise

setAvailable

public void setAvailable(int period,
                         boolean available)

getPenalty

public int getPenalty(ExamPeriod period)
Return room penalty for given period


getPenalty

public int getPenalty(int period)

setPenalty

public void setPenalty(ExamPeriod period,
                       int penalty)
Set room penalty for given period


setPenalty

public void setPenalty(int period,
                       int penalty)

getRoomSharing

public ExamRoomSharing getRoomSharing()

computeConflicts

public void computeConflicts(ExamPlacement p,
                             Set<ExamPlacement> conflicts)
Compute conflicts between the given assignment of an exam and all the current assignments (of this room)

Specified by:
computeConflicts in class Constraint<Exam,ExamPlacement>
Parameters:
p - value to be assigned to its varaible
conflicts - resultant set of conflicting values

inConflict

public boolean inConflict(ExamPlacement p)
Checks whether there is a conflict between the given assignment of an exam and all the current assignments (of this room)

Overrides:
inConflict in class Constraint<Exam,ExamPlacement>

isConsistent

public boolean isConsistent(ExamPlacement p1,
                            ExamPlacement p2)
False if the given two assignments are using this room at the same period

Overrides:
isConsistent in class Constraint<Exam,ExamPlacement>

assigned

public void assigned(long iteration,
                     ExamPlacement p)
An exam was assigned, update room assignment table

Overrides:
assigned in class Constraint<Exam,ExamPlacement>

afterAssigned

public void afterAssigned(long iteration,
                          ExamPlacement p)
An exam was assigned, update room assignment table


unassigned

public void unassigned(long iteration,
                       ExamPlacement p)
An exam was unassigned, update room assignment table

Overrides:
unassigned in class Constraint<Exam,ExamPlacement>

afterUnassigned

public void afterUnassigned(long iteration,
                            ExamPlacement p)
An exam was unassigned, update room assignment table


equals

public boolean equals(Object o)
Checks two rooms for equality

Overrides:
equals in class Constraint<Exam,ExamPlacement>

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class Constraint<Exam,ExamPlacement>

getName

public String getName()
Room name

Overrides:
getName in class Constraint<Exam,ExamPlacement>

hasName

public boolean hasName()
Room name


toString

public String toString()
Room unique id

Overrides:
toString in class Object

compareTo

public int compareTo(Constraint<Exam,ExamPlacement> o)
Compare two rooms (by unique id)

Specified by:
compareTo in interface Comparable<Constraint<Exam,ExamPlacement>>
Overrides:
compareTo in class Constraint<Exam,ExamPlacement>