ttsolver.constraint
Class RoomConstraint

java.lang.Object
  extended by ifs.model.Constraint
      extended by ttsolver.constraint.RoomConstraint

public class RoomConstraint
extends Constraint

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

Version:
1.0
Author:
Tomáš Müller

Constructor Summary
RoomConstraint(String id, String name, int slotsPerDay, int days, String description)
          Constructor
 
Method Summary
 void assigned(long iteration, Value value)
          Given value is to be assigned to its varable.
 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 getDays()
          Number of days
 String getDescription()
          Room description
 String getName()
          Room name
 Lecture[] getResource()
          Lookup table getResource()[slot] -> lecture using this room placed in the given time slot (null if empty)
 String getResourceId()
          Room id
 int getSlotsPerDay()
          Number of slots per day
 boolean inConflict(Value value)
          Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
 boolean isConsistent(Value value1, Value value2)
          Returns true if the given assignments are consistent respecting this constraint.
protected  void printUsage(StringBuffer sb)
          Room usage
 String toString()
           
 void unassigned(long iteration, Value value)
          Given value is unassigned from its varable.
 
Methods inherited from class ifs.model.Constraint
addConstraintListener, addVariable, assignedVariables, countAssignedVariables, countVariables, getId, getInfo, getModel, hashCode, isHard, removeConstraintListener, removeVariable, setModel, variables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoomConstraint

public RoomConstraint(String id,
                      String name,
                      int slotsPerDay,
                      int days,
                      String description)
Constructor

Parameters:
id - room id
name - room name
slotsPerDay - number of slots per day
days - number of days
description - room description
Method Detail

getResourceId

public String getResourceId()
Room id


getName

public String getName()
Room name

Overrides:
getName in class Constraint

getSlotsPerDay

public int getSlotsPerDay()
Number of slots per day


getDays

public int getDays()
Number of days


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 Lecture[] getResource()
Lookup table getResource()[slot] -> lecture using this room placed in the given time slot (null if empty)


countUselessSlots

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


printUsage

protected void printUsage(StringBuffer sb)
Room usage


toString

public String toString()
Overrides:
toString in class Object

getDescription

public String getDescription()
Room description

Overrides:
getDescription in class Constraint


Copyright © 2005 Tomáš Müller