ttsolver.constraint
Class ResourceConstraint

java.lang.Object
  extended by ifs.model.Constraint
      extended by ttsolver.constraint.ResourceConstraint
Direct Known Subclasses:
InstructorConstraint

public class ResourceConstraint
extends Constraint

Resource constraint.
Classes using this resource can not overlap in time. All classes associated with this resource are considered to use this resource.

Version:
1.0
Author:
Tomáš Müller

Field Summary
protected  int iDays
          Number of days
protected  Lecture[] iResource
          table iResource[slot] = lecture using this resource placed in the given time slot (null if empty)
protected  int iSlotsPerDay
          Number of slots per day
 
Constructor Summary
ResourceConstraint(String id, String name, int slotsPerDay, int days)
          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 resource
 int getDays()
          Number of days
 String getName()
          Resource name
 Lecture[] getResource()
          Lookup table getResource()[slot] -> lecture using this resource placed in the given time slot (null if empty)
 String getResourceId()
          Resource 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)
          Resource usage 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, getDescription, 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
 

Field Detail

iResource

protected Lecture[] iResource
table iResource[slot] = lecture using this resource placed in the given time slot (null if empty)


iSlotsPerDay

protected int iSlotsPerDay
Number of slots per day


iDays

protected int iDays
Number of days

Constructor Detail

ResourceConstraint

public ResourceConstraint(String id,
                          String name,
                          int slotsPerDay,
                          int days)
Constructor

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

getResourceId

public String getResourceId()
Resource id


getName

public String getName()
Resource 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 resource placed in the given time slot (null if empty)


countUselessSlots

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


printUsage

protected void printUsage(StringBuffer sb)
Resource usage usage


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005 Tomáš Müller