|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.cpsolver.ifs.model.Constraint net.sf.cpsolver.coursett.constraint.GroupConstraint
public class GroupConstraint
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 | Comment |
---|---|
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. |
Field Summary | |
---|---|
static String |
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 String |
TYPE_BTB_DAY
|
static String |
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 String |
TYPE_CAN_SHARE_ROOM
|
static String |
TYPE_CH_NOTOVERLAP
|
static String |
TYPE_DIFF_TIME
Different time: given classes cannot overlap in time. |
static String |
TYPE_EVERY_OTHER_DAY
|
static String |
TYPE_FOLLOWING_DAY
|
static String |
TYPE_MEET_WITH
|
static String |
TYPE_NDB_GT_1
|
static String |
TYPE_NHB_1
One hour between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_1_5
One and half hour between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_2
Two hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_3
Three hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_4
Four hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_4_5
Four and half hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_5
Five hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_6
Six hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_7
Seven hours between: between the given classes, the exact number of hours have to be kept. |
static String |
TYPE_NHB_8
Eight hours between: between the given classes, the exact number of hours have to be kept. |
static String |
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 String |
TYPE_NHB_LT_6
Less than 6 hours between: between the given classes, the number of hours have to be less than six. |
static String |
TYPE_PRECEDENCE
|
static String |
TYPE_SAME_DAYS
Same days: given classes have to be taught in the same day. |
static String |
TYPE_SAME_INSTR
|
static String |
TYPE_SAME_ROOM
Same room: given classes have to placed in the same room. |
static String |
TYPE_SAME_START
Same room: given classes have to placed in the same room. |
static String |
TYPE_SAME_STUDENTS
|
static String |
TYPE_SAME_TIME
Same time: given classes have to be taught in the same hours. |
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint |
---|
iAssignedVariables, iConstraintListeners |
Constructor Summary | |
---|---|
GroupConstraint()
|
|
GroupConstraint(Long id,
String type,
String preference)
Constructor |
Method Summary | |
---|---|
void |
addVariable(Variable variable)
Add a variable to this constraint |
void |
assigned(long iteration,
Value value)
Given value is to be assigned to its varable. |
static boolean |
canShareRooms(String type)
|
void |
computeConflicts(Value value,
Set conflicts)
The only method which has to be implemented by any constraint. |
Long |
getConstraintId()
Constraint id |
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) |
long |
getId()
Unique id |
String |
getName()
Constraint's name -- for printing purposes |
static String |
getName(String type)
|
int |
getPreference()
Constraint preference (0 if prohibited or reqired) |
String |
getPrologPreference()
Prolog reference: "R" for required, "P" for prohibited", "-2",.."2" for preference |
String |
getType()
ConstraString type (e.g, TYPE_SAME_TIME |
boolean |
inConflict(Value value)
Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint. |
boolean |
isChildrenNotOverlap(Lecture lec1,
Placement plc1,
Lecture lec2,
Placement plc2)
|
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 |
boolean |
isSatisfied()
|
void |
removeVariable(Variable variable)
Remove a variable from this constraint |
void |
setType(String 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, assignedVariables, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getModel, hashCode, removeConstraintListener, setModel, variables |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static String TYPE_SAME_TIME
public static String TYPE_SAME_DAYS
public static String TYPE_BTB
public static String TYPE_BTB_TIME
public static String TYPE_DIFF_TIME
public static String TYPE_NHB_1
public static String TYPE_NHB_2
public static String TYPE_NHB_3
public static String TYPE_NHB_4
public static String TYPE_NHB_5
public static String TYPE_NHB_6
public static String TYPE_NHB_7
public static String TYPE_NHB_8
public static String TYPE_SAME_START
public static String TYPE_SAME_ROOM
public static String TYPE_NHB_GTE_1
public static String TYPE_NHB_LT_6
public static String TYPE_NHB_1_5
public static String TYPE_NHB_4_5
public static String TYPE_SAME_STUDENTS
public static String TYPE_SAME_INSTR
public static String TYPE_CAN_SHARE_ROOM
public static String TYPE_PRECEDENCE
public static String TYPE_BTB_DAY
public static String TYPE_MEET_WITH
public static String TYPE_NDB_GT_1
public static String TYPE_CH_NOTOVERLAP
public static String TYPE_FOLLOWING_DAY
public static String TYPE_EVERY_OTHER_DAY
Constructor Detail |
---|
public GroupConstraint()
public GroupConstraint(Long id, String type, String preference)
id
- constraint idtype
- constraString type (e.g, "SAME_TIME")preference
- time preferent ("R" for required, "P" for prohibited, "-2", "-1", "1", "2" for soft preference)Method Detail |
---|
public void addVariable(Variable variable)
Constraint
addVariable
in class Constraint
public void removeVariable(Variable variable)
Constraint
removeVariable
in class Constraint
public Long getConstraintId()
public long getId()
Constraint
getId
in class Constraint
public String getType()
TYPE_SAME_TIME
public void setType(String type)
public boolean isRequired()
public boolean isProhibited()
public String getPrologPreference()
public boolean isConsistent(Value value1, Value value2)
Constraint
MacPropagation
).
isConsistent
in class Constraint
public void computeConflicts(Value value, Set conflicts)
Constraint
computeConflicts
in class Constraint
value
- value to be assigned to its varaibleconflicts
- resultant set of conflicting valuespublic boolean inConflict(Value value)
Constraint
MacPropagation
).
inConflict
in class Constraint
public int getPreference()
public int getCurrentPreference()
public int getCurrentPreference(Placement placement)
public void unassigned(long iteration, Value value)
Constraint
unassigned
in class Constraint
public void assigned(long iteration, Value value)
Constraint
assigned
in class Constraint
public String toString()
toString
in class Object
public boolean isHard()
Constraint
isHard
in class Constraint
public String getName()
Constraint
getName
in class Constraint
public static String getName(String type)
public static boolean canShareRooms(String type)
public boolean isSatisfied()
public boolean isChildrenNotOverlap(Lecture lec1, Placement plc1, Lecture lec2, Placement plc2)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |