net.sf.cpsolver.coursett.constraint
Class RoomConstraint

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Constraint
      extended by net.sf.cpsolver.coursett.constraint.RoomConstraint
Direct Known Subclasses:
DiscouragedRoomConstraint

public class RoomConstraint
extends Constraint

Room constraint.
Classes with the same room can not overlap in time.

Version:
CourseTT 1.1 (University Course Timetabling)
Copyright (C) 2006 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
RoomConstraint(Long id, String name, Long buildingId, int capacity, RoomSharingModel roomSharingModel, int x, int y, boolean ignoreTooFar, boolean constraint)
          Constructor
 
Method Summary
 void assigned(long iteration, Value value)
          Given value is to be assigned to its varable.
 void clearCache()
           
 void computeConflicts(Value value, Set conflicts)
          The only method which has to be implemented by any constraint.
 int countUselessSlots()
          Number of useless slots for this room
 int countUselessSlots(Placement placement)
          Number of useless slots for this room
 int countUselessSlotsBrokenTimePatterns()
          Number of useless slots for this room
 int countUselessSlotsHalfHours()
          Number of useless slots for this room
 Vector[] getAvailableArray()
           
 Long getBuildingId()
          Building id
 int getCapacity()
          Capacity
 boolean getConstraint()
           
 boolean getIgnoreTooFar()
           
 String getName()
          Room name
 Placement getPlacement(int slot, int day)
           
 int getPosX()
          X-position of the building
 int getPosY()
          Y-position of the building
 Vector getResource(int slot)
          Lookup table getResource()[slot] -> lecture using this room placed in the given time slot (null if empty)
 Long getResourceId()
          Room id
 Placement[] getResourceOfWeek(int startDay)
           
 String getRoomName()
           
 RoomSharingModel getSharingModel()
           
 Long getType()
           
 boolean inConflict(Value value)
          Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
 boolean isAvailable(int slot)
           
 boolean isAvailable(Lecture lecture, TimeLocation time, Long scheduler)
           
 boolean isConsistent(Value value1, Value value2)
          Returns true if the given assignments are consistent respecting this constraint.
protected  void printUsage(StringBuffer sb)
          Room usage
 void setCoordinates(int x, int y)
          Position of the building
 void setNotAvailable(Placement placement)
           
 void setType(Long type)
           
 String toString()
           
 void unassigned(long iteration, Value value)
          Given value is unassigned from its varable.
 
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint
addConstraintListener, addVariable, assignedVariables, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, isHard, removeConstraintListener, removeVariable, setModel, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoomConstraint

public RoomConstraint(Long id,
                      String name,
                      Long buildingId,
                      int capacity,
                      RoomSharingModel roomSharingModel,
                      int x,
                      int y,
                      boolean ignoreTooFar,
                      boolean constraint)
Constructor

Method Detail

setNotAvailable

public void setNotAvailable(Placement placement)

isAvailable

public boolean isAvailable(int slot)

isAvailable

public boolean isAvailable(Lecture lecture,
                           TimeLocation time,
                           Long scheduler)

getAvailableArray

public Vector[] getAvailableArray()

getSharingModel

public RoomSharingModel getSharingModel()

getResourceId

public Long getResourceId()
Room id


getBuildingId

public Long getBuildingId()
Building id


getName

public String getName()
Room name

Overrides:
getName in class Constraint

getRoomName

public String getRoomName()

getCapacity

public int getCapacity()
Capacity


getPlacement

public Placement getPlacement(int slot,
                              int day)

computeConflicts

public void computeConflicts(Value value,
                             Set conflicts)
Description copied from class: Constraint
The only method which has to be implemented by any constraint. It returns the values which needs to be unassigned in order to make this constraint consistent with the given value if it is assigned to its variable. The computed list of conflicting values is added to the given set of conflicts.

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)
Description copied from class: Constraint
Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint. This method is used by MAC (see MacPropagation).

Overrides:
inConflict in class Constraint

isConsistent

public boolean isConsistent(Value value1,
                            Value value2)
Description copied from class: Constraint
Returns true if the given assignments are consistent respecting this constraint. This method is used by MAC (see MacPropagation).

Overrides:
isConsistent in class Constraint

assigned

public void assigned(long iteration,
                     Value value)
Description copied from class: Constraint
Given value is to be assigned to its varable. In this method, the constraint should unassigns all varaibles which are in conflict with the given assignment because of this constraint.

Overrides:
assigned in class Constraint

unassigned

public void unassigned(long iteration,
                       Value value)
Description copied from class: Constraint
Given value is unassigned from its varable.

Overrides:
unassigned in class Constraint

getResource

public Vector getResource(int slot)
Lookup table getResource()[slot] -> lecture using this room placed in the given time slot (null if empty)


getResourceOfWeek

public Placement[] getResourceOfWeek(int startDay)

countUselessSlots

public int countUselessSlots()
Number of useless slots for this room


countUselessSlotsHalfHours

public int countUselessSlotsHalfHours()
Number of useless slots for this room


countUselessSlotsBrokenTimePatterns

public int countUselessSlotsBrokenTimePatterns()
Number of useless slots for this room


clearCache

public void clearCache()

countUselessSlots

public int countUselessSlots(Placement placement)
Number of useless slots for this room


printUsage

protected void printUsage(StringBuffer sb)
Room usage


toString

public String toString()
Overrides:
toString in class Object

setCoordinates

public void setCoordinates(int x,
                           int y)
Position of the building


getPosX

public int getPosX()
X-position of the building


getPosY

public int getPosY()
Y-position of the building


getIgnoreTooFar

public boolean getIgnoreTooFar()

getConstraint

public boolean getConstraint()

getType

public Long getType()

setType

public void setType(Long type)