public abstract class FlexibleConstraint extends Constraint<Lecture,Placement>
Modifier and Type | Class and Description |
---|---|
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.
|
Modifier and Type | Field and Description |
---|---|
protected FlexibleConstraint.FlexibleConstraintType |
iConstraintType |
protected String |
iReference |
protected List<BitSet> |
iWeeks |
iAssignedVariables, iConstraintListeners, iId
Constructor and Description |
---|
FlexibleConstraint(Long id,
String owner,
String preference,
String reference) |
Modifier and Type | Method and Description |
---|---|
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.
|
addConstraintListener, addVariable, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, removeConstraintListener, removeVariable, setModel, variables
protected FlexibleConstraint.FlexibleConstraintType iConstraintType
protected String iReference
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 formpublic 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 placementspublic 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 patternprotected List<FlexibleConstraint.Block> mergeToBlocks(List<Placement> sorted, int maxBreakBetweenBTB)
sorted
- list of placements sorted by startSlotmaxBreakBetweenBTB
- maximum number of free slots between BTB placementspublic 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 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>