public abstract class FlexibleConstraint extends ConstraintWithContext<Lecture,Placement,FlexibleConstraint.FlexibleConstraintContext>
| Modifier and Type | Class and Description |
|---|---|
class |
FlexibleConstraint.Block
A block is a list of placements sorted by startSlot, which are BTB.
|
class |
FlexibleConstraint.FlexibleConstraintContext |
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 Integer |
iDayOfWeekOffset |
protected Boolean |
iPreciseDateComputation |
protected int |
iPreference |
protected String |
iReference |
protected List<BitSet> |
iWeeks |
iConstraintListeners, iIdsMaxSize| Constructor and Description |
|---|
FlexibleConstraint(Long id,
String owner,
String preference,
String reference)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
FlexibleConstraint.FlexibleConstraintContext |
createAssignmentContext(Assignment<Lecture,Placement> assignment)
Create a new assignment context for the given assignment.
|
double |
getCurrentPreference(Assignment<Lecture,Placement> assignment,
Set<Placement> conflicts,
HashMap<Lecture,Placement> assignments)
Return the current preference of the flexible constraint, considering conflicts and new assignments.
|
int |
getDayOfWeekOffset() |
String |
getName()
Constraint's name -- for printing purposes
|
abstract double |
getNrViolations(Assignment<Lecture,Placement> assignment,
Set<Placement> conflicts,
HashMap<Lecture,Placement> assignments)
Return current number of violations.
|
String |
getOwner() |
String |
getPrologPreference()
Prolog reference: "R" for required, "P" for prohibited", "-2",.."2" for
preference
|
String |
getReference() |
protected Set<Placement> |
getRelevantPlacements(Assignment<Lecture,Placement> assignment,
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()
Return weeks of the term.
|
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 |
isPreciseDateComputation() |
protected List<FlexibleConstraint.Block> |
mergeToBlocks(List<Placement> sorted,
int maxBreakBetweenBTB)
Creates a list of blocks from a placements sorted by startSlot
|
protected boolean |
shareWeeksAndDay(TimeLocation t,
BitSet week,
int dayCode)
Used to determine the daycode and week of a timelocation
|
String |
toString() |
assigned, getAssignmentContextReference, getContext, getContext, setAssignmentContextReference, setModel, unassignedaddConstraintListener, addVariable, assignedVariables, compareTo, computeConflicts, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, removeConstraintListener, removeVariable, variablesprotected int iPreference
protected FlexibleConstraint.FlexibleConstraintType iConstraintType
protected String iReference
protected Integer iDayOfWeekOffset
protected Boolean iPreciseDateComputation
public FlexibleConstraint(Long id, String owner, String preference, String reference)
id - unique idowner - 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 double getNrViolations(Assignment<Lecture,Placement> assignment, Set<Placement> conflicts, HashMap<Lecture,Placement> assignments)
assignment - current assignmentconflicts - conflicting placements to be unassignedassignments - assigned placementspublic List<BitSet> getWeeks()
public int getDayOfWeekOffset()
public boolean isPreciseDateComputation()
public boolean isConsistent(Placement value1, Placement value2)
ConstraintMacPropagation).isConsistent in class Constraint<Lecture,Placement>value1 - a valuevalue2 - a valueprotected Set<Placement> getRelevantPlacements(Assignment<Lecture,Placement> assignment, int dayCode, Set<Placement> conflicts, Placement value, HashMap<Lecture,Placement> assignments, BitSet week)
assignment - current assignmentdayCode - representation of days in week combinationconflicts - placements to be unassignedvalue - placement to be assignedassignments - placements of variablesweek - bitset representing a date patternprotected boolean shareWeeksAndDay(TimeLocation t, BitSet week, int dayCode)
t - timelocationweek - date pattern compared to timelocationdayCode - days compared to timelocationprotected 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()
ConstraintisHard in class Constraint<Lecture,Placement>public String getName()
ConstraintgetName in class Constraint<Lecture,Placement>public FlexibleConstraint.FlexibleConstraintType getType()
public String getReference()
public String getPrologPreference()
public double getCurrentPreference(Assignment<Lecture,Placement> assignment, Set<Placement> conflicts, HashMap<Lecture,Placement> assignments)
assignment - current assignmentconflicts - conflicting assignmentassignments - proposed assignmentspublic FlexibleConstraint.FlexibleConstraintContext createAssignmentContext(Assignment<Lecture,Placement> assignment)
HasAssignmentContextassignment - an assignment for which there needs to be an assignment context