|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.cpsolver.ifs.model.Constraint<Lecture,Placement>
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. |
Nested Class Summary | |
---|---|
static class |
GroupConstraint.ConstraintType
Group constraint type. |
static class |
GroupConstraint.Flag
Group constraint building blocks (individual constraints that need more than GroupConstraint.PairCheck ) |
static interface |
GroupConstraint.PairCheck
Group constraints that can be checked on pairs of classes (e.g., same room means any two classes are in the same room), only need to implement this interface. |
Field Summary |
---|
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint |
---|
iAssignedVariables, iConstraintListeners, iId |
Constructor Summary | |
---|---|
GroupConstraint()
|
|
GroupConstraint(Long id,
GroupConstraint.ConstraintType type,
String preference)
Constructor |
Method Summary | |
---|---|
void |
addVariable(Lecture lecture)
Add a variable to this constraint |
void |
assigned(long iteration,
Placement value)
Given value is to be assigned to its varable. |
boolean |
canShareRoom()
|
void |
computeConflicts(Placement value,
Set<Placement> conflicts)
The only method which has to be implemented by any constraint. |
boolean |
equals(Object o)
Compare two constraints for equality ( Constraint.getId() is used) |
void |
forwardCheck(Placement value,
Set<Placement> conflicts,
Set<GroupConstraint> ignore)
|
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) |
protected long |
getGeneratedId()
Generated unique id |
long |
getId()
Unique 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 |
GroupConstraint.ConstraintType |
getType()
ConstraString type (e.g, GroupConstraint.ConstraintType.SAME_TIME ) |
boolean |
inConflict(Placement 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(Placement value1,
Placement 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()
|
boolean |
isSatisfiedPair(Placement plc1,
Placement plc2)
|
void |
removeVariable(Lecture lecture)
Remove a variable from this constraint |
void |
setModel(Model<Lecture,Placement> model)
Sets the model which the constraint belongs to |
void |
setType(GroupConstraint.ConstraintType type)
|
String |
toString()
|
void |
unassigned(long iteration,
Placement value)
Given value is unassigned from its variable. |
Methods inherited from class net.sf.cpsolver.ifs.model.Constraint |
---|
addConstraintListener, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, getDescription, getModel, hashCode, removeConstraintListener, variables |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GroupConstraint()
public GroupConstraint(Long id, GroupConstraint.ConstraintType type, String preference)
id
- constraint idtype
- constraString type (e.g, GroupConstraint.ConstraintType.SAME_TIME
)preference
- time preference ("R" for required, "P" for prohibited, "-2",
"-1", "1", "2" for soft preference)Method Detail |
---|
public void setModel(Model<Lecture,Placement> model)
Constraint
setModel
in class Constraint<Lecture,Placement>
public void addVariable(Lecture lecture)
Constraint
addVariable
in class Constraint<Lecture,Placement>
public void removeVariable(Lecture lecture)
Constraint
removeVariable
in class Constraint<Lecture,Placement>
public Long getConstraintId()
public long getId()
Constraint
getId
in class Constraint<Lecture,Placement>
protected long getGeneratedId()
public GroupConstraint.ConstraintType getType()
GroupConstraint.ConstraintType.SAME_TIME
)
public void setType(GroupConstraint.ConstraintType type)
public boolean isRequired()
public boolean isProhibited()
public String getPrologPreference()
public boolean isConsistent(Placement value1, Placement value2)
Constraint
MacPropagation
).
isConsistent
in class Constraint<Lecture,Placement>
public void computeConflicts(Placement value, Set<Placement> conflicts)
Constraint
computeConflicts
in class Constraint<Lecture,Placement>
value
- value to be assigned to its varaibleconflicts
- resultant set of conflicting valuespublic void forwardCheck(Placement value, Set<Placement> conflicts, Set<GroupConstraint> ignore)
public boolean inConflict(Placement value)
Constraint
MacPropagation
).
inConflict
in class Constraint<Lecture,Placement>
public int getPreference()
public int getCurrentPreference()
public int getCurrentPreference(Placement placement)
public void unassigned(long iteration, Placement value)
Constraint
unassigned
in class Constraint<Lecture,Placement>
public void assigned(long iteration, Placement value)
Constraint
assigned
in class Constraint<Lecture,Placement>
public String toString()
toString
in class Object
public boolean isHard()
Constraint
isHard
in class Constraint<Lecture,Placement>
public String getName()
Constraint
getName
in class Constraint<Lecture,Placement>
public boolean isSatisfied()
public boolean isChildrenNotOverlap(Lecture lec1, Placement plc1, Lecture lec2, Placement plc2)
public boolean isSatisfiedPair(Placement plc1, Placement plc2)
public boolean canShareRoom()
public boolean equals(Object o)
Constraint
Constraint.getId()
is used)
equals
in class Constraint<Lecture,Placement>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |