public class ExamDistributionConstraint extends ConstraintWithContext<Exam,ExamPlacement,ExamDistributionConstraint.Context>
Modifier and Type | Class and Description |
---|---|
class |
ExamDistributionConstraint.Context |
Modifier and Type | Field and Description |
---|---|
static int |
sDistDifferentDay
Different day constraint type
|
static int |
sDistDifferentPeriod
Different period constraint type
|
static int |
sDistDifferentRoom
Different room constraint type
|
static int |
sDistPrecedence
Precedence constraint type
|
static int |
sDistPrecedenceRev
Precedence constraint type (reverse order)
|
static int |
sDistSameDay
Same day constraint type
|
static int |
sDistSamePeriod
Same period constraint type
|
static int |
sDistSameRoom
Same room constraint type
|
static String[] |
sDistType
Distribution type name
|
iConstraintListeners, iId
sMaxSize
Constructor and Description |
---|
ExamDistributionConstraint(long id,
int type,
boolean hard,
int weight)
Constructor
|
ExamDistributionConstraint(long id,
String type,
boolean hard,
int weight)
Constructor
|
ExamDistributionConstraint(long id,
String type,
String pref)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
computeConflicts(Assignment<Exam,ExamPlacement> assignment,
ExamPlacement givenPlacement,
Set<ExamPlacement> conflicts)
Compute conflicts -- there is a conflict if the other variable is
assigned and
check(ExamPlacement, ExamPlacement) is
false |
ExamDistributionConstraint.Context |
createAssignmentContext(Assignment<Exam,ExamPlacement> assignment)
Create a new assignment context for the given assignment.
|
boolean |
equals(Object o)
Compare with other constraint for equality
|
int |
getType()
Constraint type
|
String |
getTypeString()
Constraint type name
|
int |
getWeight()
If not hard, penalty for violation
|
boolean |
check(ExamPlacement first,
ExamPlacement second)
Check assignments of the given exams
|
boolean |
inConflict(Assignment<Exam,ExamPlacement> assignment,
ExamPlacement givenPlacement)
Check for conflict -- there is a conflict if the other variable is
assigned and
check(ExamPlacement, ExamPlacement) is
false |
boolean |
isConsistent(ExamPlacement first,
ExamPlacement second)
Consistency check --
check(ExamPlacement, ExamPlacement) is
called |
boolean |
isHard()
True if hard (must be satisfied), false for soft (should be satisfied)
|
boolean |
isPeriodRelated()
True if the constraint is related to periods
|
boolean |
isRoomRelated()
True if the constraint is related to rooms
|
boolean |
isSatisfied(Assignment<Exam,ExamPlacement> assignment)
Return true if this is hard constraint or this is a soft constraint
without any violation
|
boolean |
isSatisfied(Assignment<Exam,ExamPlacement> assignment,
ExamPlacement p)
Return true if this is hard constraint or this is a soft constraint
without any violation
|
String |
toString()
String representation -- constraint type name (exam 1, exam 2)
|
assigned, getAssignmentContextReference, getContext, getContext, setAssignmentContextReference, setModel, unassigned
addConstraintListener, addVariable, assignedVariables, compareTo, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, getDescription, getId, getModel, getName, hashCode, removeConstraintListener, removeVariable, variables
public static final int sDistSameRoom
public static final int sDistDifferentRoom
public static final int sDistSamePeriod
public static final int sDistDifferentPeriod
public static final int sDistPrecedence
public static final int sDistPrecedenceRev
public static final int sDistSameDay
public static final int sDistDifferentDay
public ExamDistributionConstraint(long id, int type, boolean hard, int weight)
id
- constraint unique idtype
- constraint typehard
- true if the constraint is hard (cannot be violated)weight
- if not hard, penalty for violationpublic ExamDistributionConstraint(long id, String type, String pref)
id
- constraint unique idtype
- constraint type (EX_SAME_PREF, EX_SAME_ROOM, or EX_PRECEDENCE)pref
- preference (R/P for required/prohibited, or -2, -1, 0, 1, 2
for preference (from preferred to discouraged))public ExamDistributionConstraint(long id, String type, boolean hard, int weight)
id
- constraint unique idtype
- constraint type namehard
- true if the constraint is hardweight
- constraint penalty if violated (for soft constraint)public boolean isHard()
isHard
in class Constraint<Exam,ExamPlacement>
public int getWeight()
public int getType()
public String getTypeString()
sDistType
)public void computeConflicts(Assignment<Exam,ExamPlacement> assignment, ExamPlacement givenPlacement, Set<ExamPlacement> conflicts)
check(ExamPlacement, ExamPlacement)
is
falsecomputeConflicts
in class Constraint<Exam,ExamPlacement>
assignment
- current assignmentgivenPlacement
- value to be assigned to its variableconflicts
- resultant set of conflicting valuespublic boolean inConflict(Assignment<Exam,ExamPlacement> assignment, ExamPlacement givenPlacement)
check(ExamPlacement, ExamPlacement)
is
falseinConflict
in class Constraint<Exam,ExamPlacement>
assignment
- current assignmentgivenPlacement
- given valuepublic boolean isConsistent(ExamPlacement first, ExamPlacement second)
check(ExamPlacement, ExamPlacement)
is
calledisConsistent
in class Constraint<Exam,ExamPlacement>
first
- a valuesecond
- a valuepublic boolean check(ExamPlacement first, ExamPlacement second)
first
- assignment of the first examsecond
- assignment of the second exampublic boolean equals(Object o)
equals
in class Constraint<Exam,ExamPlacement>
public boolean isSatisfied(Assignment<Exam,ExamPlacement> assignment)
assignment
- current assignmentpublic boolean isSatisfied(Assignment<Exam,ExamPlacement> assignment, ExamPlacement p)
assignment
- current assignmentp
- exam assignment to be madepublic boolean isRoomRelated()
public boolean isPeriodRelated()
public ExamDistributionConstraint.Context createAssignmentContext(Assignment<Exam,ExamPlacement> assignment)
HasAssignmentContext
assignment
- an assignment for which there needs to be an assignment context