Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ttsolver.constraint
Class GroupConstraint

    java.lang.Object
      ifs.model.Constraint
          ttsolver.constraint.GroupConstraint

    public class GroupConstraint

extends Constraint

Group constraint.
This constraint expresses relations between several classes, e.g., that two sections of the same lecture can not be taught at the same time, or that some classes have to be taught one immediately after another. It can be either hard or soft.
Following constraints are now supported:

Constraint
SAME_TIME | Same time: given classes have to be taught in the same hours. If the classes are of different length, the smaller one cannot start before the longer one and it cannot end after the longer one.
SAME_DAYS | Same days: given classes have to be taught in the same day. If the classes are of different time patterns, the days of one class have to form a subset of the days of the other class.
BTB | Back-to-back constraint: given classes have to be taught in the same room and they have to follow one strictly after another.
BTB_TIME | Back-to-back constraint: given classes have to follow one strictly after another, but they can be taught in different rooms.
DIFF_TIME | Different time: given classes cannot overlap in time.
NHB(1), NHB(1.5), NHB(2), ... NHB(8) | Number of hours between: between the given classes, the exact number of hours have to be kept.
SAME_START | Same starting hour: given classes have to start in the same hour.
SAME_ROOM | Same room: given classes have to be placed in the same room.
NHB_GTE(1) | Greater than or equal to 1 hour between: between the given classes, the number of hours have to be one or more.
NHB_LT(6) | Less than 6 hours between: between the given classes, the number of hours have to be less than six.

Version:
  1.0
Author:
  Tomáš Müller

Field Summary
`static int` | `TYPE_BTB` Back-to-back constraint: given classes have to be taught in the same room and they have to follow one strictly after another.
`static int` | `TYPE_BTB_TIME` Back-to-back constraint: given classes have to follow one strictly after another, but they can be taught in different rooms.
`static int` | `TYPE_DIFF_TIME` Different time: given classes cannot overlap in time.
`static int` | `TYPE_NHB_1` One hour between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_1_5` One and half hour between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_2` Two hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_3` Three hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_4` Four hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_4_5` Four and half hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_5` Five hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_6` Six hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_7` Seven hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_8` Eight hours between: between the given classes, the exact number of hours have to be kept.
`static int` | `TYPE_NHB_GTE_1` Greater than or equal to 1 hour between: between the given classes, the number of hours have to be one or more.
`static int` | `TYPE_NHB_LT_6` Less than 6 hours between: between the given classes, the number of hours have to be less than six.
`static int` | `TYPE_SAME_DAYS` Same days: given classes have to be taught in the same day.
`static int` | `TYPE_SAME_ROOM` Same room: given classes have to placed in the same room.
`static int` | `TYPE_SAME_START` Same room: given classes have to placed in the same room.
`static int` | `TYPE_SAME_TIME` Same time: given classes have to be taught in the same hours.

Constructor Summary
`GroupConstraint(long id, int type, String preference)` Constructor
`GroupConstraint(long id, String type, String preference)` 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` | `getCurrentPreference()` Current constraint preference (0 if prohibited or reqired, depends on current satisfaction of the constraint)
`int` | `getCurrentPreference(Placement placement)` Current constraint preference (if given placement is assigned)
`String` | `getDescription()` Constraint's description -- for printing purposes
`Counter` | `getGlobalPreference()` Global preference counter
`long` | `getId()` Constraint id
`String` | `getName()` Constraint's name -- for printing purposes
`int` | `getPreference()` Constraint preference (0 if prohibited or reqired)
`String` | `getPrologPreference()` Prolog reference: "R" for required, "P" for prohibited", "-2",.."2" for preference
`int` | `getType()` Constraint type (e.g, `TYPE_SAME_TIME`
`String` | `getTypeStr()` Constraint type (e.g, "SAME_TIME")
`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.
`boolean` | `isHard()` Returns true if the constraint is hard.
`boolean` | `isProhibited()` Is constraint prohibited
`boolean` | `isRequired()` Is constraint required
`void` | `setGlobalPreference(Counter globalPreference)` Global preference counter
`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, getInfo, getModel, hashCode, removeConstraintListener, removeVariable, setModel, variables`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### TYPE_SAME_TIME

    public static int TYPE_SAME_TIME

  Same time: given classes have to be taught in the same hours. If the classes are of different length, the smaller one cannot start before the longer one and it cannot end after the longer one.

### TYPE_SAME_DAYS

    public static int TYPE_SAME_DAYS

  Same days: given classes have to be taught in the same day. If the classes are of different time patterns, the days of one class have to form a subset of the days of the other class.

### TYPE_BTB

    public static int TYPE_BTB

  Back-to-back constraint: given classes have to be taught in the same room and they have to follow one strictly after another.

### TYPE_BTB_TIME

    public static int TYPE_BTB_TIME

  Back-to-back constraint: given classes have to follow one strictly after another, but they can be taught in different rooms.

### TYPE_DIFF_TIME

    public static int TYPE_DIFF_TIME

  Different time: given classes cannot overlap in time.

### TYPE_NHB_1

    public static int TYPE_NHB_1

  One hour between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_2

    public static int TYPE_NHB_2

  Two hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_3

    public static int TYPE_NHB_3

  Three hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_4

    public static int TYPE_NHB_4

  Four hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_5

    public static int TYPE_NHB_5

  Five hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_6

    public static int TYPE_NHB_6

  Six hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_7

    public static int TYPE_NHB_7

  Seven hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_8

    public static int TYPE_NHB_8

  Eight hours between: between the given classes, the exact number of hours have to be kept.

### TYPE_SAME_START

    public static int TYPE_SAME_START

  Same room: given classes have to placed in the same room.

### TYPE_SAME_ROOM

    public static int TYPE_SAME_ROOM

  Same room: given classes have to placed in the same room.

### TYPE_NHB_GTE_1

    public static int TYPE_NHB_GTE_1

  Greater than or equal to 1 hour between: between the given classes, the number of hours have to be one or more.

### TYPE_NHB_LT_6

    public static int TYPE_NHB_LT_6

  Less than 6 hours between: between the given classes, the number of hours have to be less than six.

### TYPE_NHB_1_5

    public static int TYPE_NHB_1_5

  One and half hour between: between the given classes, the exact number of hours have to be kept.

### TYPE_NHB_4_5

    public static int TYPE_NHB_4_5

  Four and half hours between: between the given classes, the exact number of hours have to be kept.

Constructor Detail

### GroupConstraint

    public GroupConstraint(long id,
                           int type,
                           String preference)

  Constructor

  Parameters:
    `id` - constraint id
    `type` - constraint type (e.g, `TYPE_SAME_TIME`)
    `preference` - time preferent ("R" for required, "P" for prohibited, "-2", "-1", "1", "2" for soft preference)

### GroupConstraint

    public GroupConstraint(long id,
                           String type,
                           String preference)

  Constructor

  Parameters:
    `id` - constraint id
    `type` - constraint type (e.g, "SAME_TIME")
    `preference` - time preferent ("R" for required, "P" for prohibited, "-2", "-1", "1", "2" for soft preference)

Method Detail

### getId

    public long getId()

  Constraint id

  Overrides:
    `getId` in class `Constraint`

### getType

    public int getType()

  Constraint type (e.g, `TYPE_SAME_TIME`

### getTypeStr

    public String getTypeStr()

  Constraint type (e.g, "SAME_TIME")

### isRequired

    public boolean isRequired()

  Is constraint required

### isProhibited

    public boolean isProhibited()

  Is constraint prohibited

### getPrologPreference

    public String getPrologPreference()

  Prolog reference: "R" for required, "P" for prohibited", "-2",.."2" for preference

### setGlobalPreference

    public void setGlobalPreference(Counter globalPreference)

  Global preference counter

### getGlobalPreference

    public Counter getGlobalPreference()

  Global preference counter

### 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`

### 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`

### getPreference

    public int getPreference()

  Constraint preference (0 if prohibited or reqired)

### getCurrentPreference

    public int getCurrentPreference()

  Current constraint preference (0 if prohibited or reqired, depends on current satisfaction of the constraint)

### getCurrentPreference

    public int getCurrentPreference(Placement placement)

  Current constraint preference (if given placement is assigned)

### 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`

### 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`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### isHard

    public boolean isHard()

  Description copied from class: `Constraint`
  Returns true if the constraint is hard. Only hard constraints are allowed to unassign a variable when there is a conflict with a value that is being assigned

  Overrides:
    `isHard` in class `Constraint`

### getName

    public String getName()

  Description copied from class: `Constraint`
  Constraint's name -- for printing purposes

  Overrides:
    `getName` in class `Constraint`

### getDescription

    public String getDescription()

  Description copied from class: `Constraint`
  Constraint's description -- for printing purposes

  Overrides:
    `getDescription` in class `Constraint`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 Tomáš Müller