|
||||||||||
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.FlexibleConstraint
public abstract class FlexibleConstraint
Flexible constraint.
This constraint expresses relations between several classes. Provides similar
functions as Group constraint. Unlike group constraint, Flexible constraint
is able to parse some of its parameters from its reference field
Nested Class Summary | |
---|---|
class |
FlexibleConstraint.Block
A block is a list of placements sorted by startSlot, which are BTB. |
static class |
FlexibleConstraint.FlexibleConstraintType
Flexible constraint types |
protected static class |
FlexibleConstraint.PlacementTimeComparator
Placement comparator: earlier placement first, shorter placement first if both start at the same time. |
Field Summary | |
---|---|
protected FlexibleConstraint.FlexibleConstraintType |
iConstraintType
|
protected String |
iReference
|
protected List<BitSet> |
iWeeks
|
Fields inherited from class net.sf.cpsolver.ifs.model.Constraint |
---|
iAssignedVariables, iConstraintListeners, iId |
Constructor Summary | |
---|---|
FlexibleConstraint(Long id,
String owner,
String preference,
String reference)
|
Method Summary | |
---|---|
void |
assigned(long iteration,
Placement value)
Given value is to be assigned to its varable. |
abstract void |
computeConflicts(Placement value,
Set<Placement> conflicts)
The only method which has to be implemented by any constraint. |
double |
getCurrentPreference(Set<Placement> conflicts,
HashMap<Lecture,Placement> assignments)
Return the current preference of the flexible constraint, considering conflicts and new assignments. |
String |
getName()
Constraint's name -- for printing purposes |
abstract double |
getNrViolations(Set<Placement> conflicts,
HashMap<Lecture,Placement> assignments)
|
String |
getOwner()
|
String |
getPrologPreference()
Prolog reference: "R" for required, "P" for prohibited", "-2",.."2" for preference |
String |
getReference()
|
protected Set<Placement> |
getRelevantPlacements(int dayCode,
Set<Placement> conflicts,
Placement value,
HashMap<Lecture,Placement> assignments,
BitSet week)
Returns placements of variables assigned to this constraint with assignment which satisfy following conditions: They must be taught in the day included in dayCode. |
FlexibleConstraint.FlexibleConstraintType |
getType()
|
List<BitSet> |
getWeeks()
|
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. |
protected List<FlexibleConstraint.Block> |
mergeToBlocks(List<Placement> sorted,
int maxBreakBetweenBTB)
Creates a list of blocks from a placements sorted by startSlot |
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, addVariable, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, removeConstraintListener, removeVariable, setModel, variables |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected FlexibleConstraint.FlexibleConstraintType iConstraintType
protected String iReference
protected List<BitSet> iWeeks
Constructor Detail |
---|
public FlexibleConstraint(Long id, String owner, String preference, String reference)
owner
- identifier of distribution preference the constraint was created forpreference
- time preference ("R" for required, "P" for prohibited, "-2",
"-1", "1", "2" for soft preference)reference
- parameters of the constraint in String formMethod Detail |
---|
public abstract 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 abstract double getNrViolations(Set<Placement> conflicts, HashMap<Lecture,Placement> assignments)
conflicts
- conflicting placements to be unassignedassignments
- assigned placements
public List<BitSet> getWeeks()
public boolean isConsistent(Placement value1, Placement value2)
Constraint
MacPropagation
).
isConsistent
in class Constraint<Lecture,Placement>
protected Set<Placement> getRelevantPlacements(int dayCode, Set<Placement> conflicts, Placement value, HashMap<Lecture,Placement> assignments, BitSet week)
dayCode
- representation of days in week combinationconflicts
- placements to be unassignedvalue
- placement to be assignedassignments
- placements of variablesweek
- bitset representing a date pattern
protected List<FlexibleConstraint.Block> mergeToBlocks(List<Placement> sorted, int maxBreakBetweenBTB)
sorted
- list of placements sorted by startSlotmaxBreakBetweenBTB
- maximum number of free slots between BTB placements
public boolean isHard()
Constraint
isHard
in class Constraint<Lecture,Placement>
public String getName()
Constraint
getName
in class Constraint<Lecture,Placement>
public FlexibleConstraint.FlexibleConstraintType getType()
public void assigned(long iteration, Placement value)
Constraint
assigned
in class Constraint<Lecture,Placement>
public String getReference()
public String getOwner()
public String getPrologPreference()
public double getCurrentPreference(Set<Placement> conflicts, HashMap<Lecture,Placement> assignments)
conflicts
- assignments
-
public void unassigned(long iteration, Placement value)
Constraint
unassigned
in class Constraint<Lecture,Placement>
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |