net.sf.cpsolver.exam.model
Class ExamRoom

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

public class ExamRoom
extends Constraint
implements Comparable

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

Version:
ExamTT 1.1 (Examination Timetabling)
Copyright (C) 2008 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

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, int coordX, int coordY)
          Constructor
 
Method Summary
 void afterAssigned(long iteration, Value value)
          An exam was assigned, update room assignment table
 void afterUnassigned(long iteration, Value value)
          An exam was unassigned, update room assignment table
 void assigned(long iteration, Value value)
          An exam was assigned, update room assignment table
 int compareTo(Object o)
          Compare two rooms (by unique id)
 void computeConflicts(Value value, Set 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)
 int getCoordX()
          X coordinate
 int getCoordY()
          Y coordinate
 int getDistance(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)
          An exam placed at the given period
 int getSize()
          Normal seating capacity (to be used when Exam.hasAltSeating() is false)
 int hashCode()
          Hash code
 boolean hasName()
          Room name
 boolean inConflict(Value value)
          Checks whether there is a conflict between the given assignment of an exam and all the current assignments (of this room)
 boolean isAvailable(ExamPeriod period)
          True if the room is available (for examination timetabling) during the given period
 boolean isAvailable(int period)
           
 boolean isConsistent(Value value1, Value value2)
          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, Value value)
          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,
                int coordX,
                int 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

getDistance

public int getDistance(ExamRoom other)
Distance between two rooms. It is computed as Euclidean distance using the room coordinates, 1 unit equals to 10 meters.

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 int getCoordX()
X coordinate


getCoordY

public int getCoordY()
Y coordinate


getPlacement

public ExamPlacement getPlacement(ExamPeriod period)
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

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)

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)

computeConflicts

public void computeConflicts(Value value,
                             Set conflicts)
Compute conflicts between the given assignment of an exam and all the current assignments (of this room)

Specified by:
computeConflicts in class Constraint
Parameters:
value - value to be assigned to its varaible
conflicts - resultant set of conflicting values

inConflict

public boolean inConflict(Value value)
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

isConsistent

public boolean isConsistent(Value value1,
                            Value value2)
False if the given two assignments are using this room at the same period

Overrides:
isConsistent in class Constraint

assigned

public void assigned(long iteration,
                     Value value)
An exam was assigned, update room assignment table

Overrides:
assigned in class Constraint

afterAssigned

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


unassigned

public void unassigned(long iteration,
                       Value value)
An exam was unassigned, update room assignment table

Overrides:
unassigned in class Constraint

afterUnassigned

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


equals

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

Overrides:
equals in class Constraint

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class Constraint

getName

public String getName()
Room name

Overrides:
getName in class Constraint

hasName

public boolean hasName()
Room name


toString

public String toString()
Room unique id

Overrides:
toString in class Object

compareTo

public int compareTo(Object o)
Compare two rooms (by unique id)

Specified by:
compareTo in interface Comparable