public class ExamDistributionConstraint extends Constraint<Exam,ExamPlacement>
Modifier and Type | Field and Description |
---|---|
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 |
sDistSamePeriod
Same period constraint type
|
static int |
sDistSameRoom
Same room constraint type
|
static String[] |
sDistType
Distribution type name
|
iAssignedVariables, iConstraintListeners, iId
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 |
assigned(long iteration,
ExamPlacement value)
Given value is to be assigned to its varable.
|
boolean |
check(ExamPlacement first,
ExamPlacement second)
Check assignments of the given exams
|
void |
computeConflicts(ExamPlacement givenPlacement,
Set<ExamPlacement> conflicts)
Compute conflicts -- there is a conflict if the other variable is
assigned and
check(ExamPlacement, ExamPlacement) is
false |
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 |
inConflict(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()
Return true if this is hard constraint or this is a soft constraint
without any violation
|
boolean |
isSatisfied(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)
|
void |
unassigned(long iteration,
ExamPlacement value)
Given value is unassigned from its variable.
|
addConstraintListener, addVariable, assignedVariables, compareTo, constraintListeners, countAssignedVariables, countVariables, getDescription, getId, getModel, getName, hashCode, removeConstraintListener, removeVariable, setModel, 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 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 namepublic boolean isHard()
isHard
in class Constraint<Exam,ExamPlacement>
public int getWeight()
public int getType()
public String getTypeString()
public void computeConflicts(ExamPlacement givenPlacement, Set<ExamPlacement> conflicts)
check(ExamPlacement, ExamPlacement)
is
falsecomputeConflicts
in class Constraint<Exam,ExamPlacement>
givenPlacement
- value to be assigned to its varaibleconflicts
- resultant set of conflicting valuespublic boolean inConflict(ExamPlacement givenPlacement)
check(ExamPlacement, ExamPlacement)
is
falseinConflict
in class Constraint<Exam,ExamPlacement>
public boolean isConsistent(ExamPlacement first, ExamPlacement second)
check(ExamPlacement, ExamPlacement)
is
calledisConsistent
in class Constraint<Exam,ExamPlacement>
public 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()
public boolean isSatisfied(ExamPlacement p)
p
- exam assignment to be madepublic void assigned(long iteration, ExamPlacement value)
Constraint
assigned
in class Constraint<Exam,ExamPlacement>
public void unassigned(long iteration, ExamPlacement value)
Constraint
unassigned
in class Constraint<Exam,ExamPlacement>
public boolean isRoomRelated()
public boolean isPeriodRelated()