|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.cpsolver.ifs.model.Variable net.sf.cpsolver.exam.model.Exam
public class Exam
Representation of an exam (problem variable).
Each exam has defined a length (in minutes), type (whether it is a section or a course exam),
seating type (whether it requires normal or alternate seating) and a maximal number of rooms.
If the maximal number of rooms is zero, the exam will be timetabled only in time (it does not
require a room).
An exam can be only assigned to a period ExamPeriod
that is long enough (see ExamPeriod.getLength()
)
and that is available for the exam (see getPeriodPlacements()
).
A set of rooms that are available in the given period (see ExamRoom.isAvailable(ExamPeriod)
, ExamRoomPlacement.isAvailable(ExamPeriod)
),
and which together cover the size of exam (number of students attending the exam) has to be
assigned to an exam. Based on the type of seating (see hasAltSeating()
), either
room sizes (see ExamRoom.getSize()
) or alternative seating sizes (see ExamRoom.getAltSize()
)
are used. An exam has a list of available rooms with their penalties assiciated with
(see getRoomPlacements()
).
Various penalties for an assignment of a period or a set of rooms may apply. See ExamPlacement
for more details.
Field Summary | |
---|---|
protected static DecimalFormat |
sDoubleFormat
|
Fields inherited from class net.sf.cpsolver.ifs.model.Variable |
---|
iId, iValue |
Constructor Summary | |
---|---|
Exam(long id,
String name,
int length,
boolean altSeating,
int maxRooms,
int minSize,
Vector periodPlacements,
Vector roomPlacements)
Constructor |
Method Summary | |
---|---|
void |
addContstraint(Constraint constraint)
Adds a constraint. |
void |
allowAllStudentConflicts(ExamPeriod period)
Allow all direct student conflict for the given period (see ExamStudent.canConflict(Exam, Exam) ). |
void |
assign(long iteration,
Value value)
Assign value to this variable. |
boolean |
checkDistributionConstraints(ExamPeriodPlacement period)
Check all distribution constraint that this exam is involved in |
boolean |
checkDistributionConstraints(ExamRoomPlacement room)
Check all distribution constraint that this exam is involved in |
int |
compareTo(Object o)
An exam with more correlated exams is preferred ( nrStudentCorrelatedExams() ). |
int |
countStudentConflicts(ExamPeriodPlacement period)
Number of students of this exam (that does not have direct conflicts allowed, see ExamStudent.canConflict(Exam, Exam) )
that attend some other exam in the given period. |
Set |
findBestAvailableRooms(ExamPeriodPlacement period)
Find best available rooms for the exam in the given period. |
Set |
findRoomsRandom(ExamPeriodPlacement period)
Randomly find a set of available rooms for the exam in the given period. |
Set |
findRoomsRandom(ExamPeriodPlacement period,
boolean checkConflicts)
Randomly find a set of available rooms for the exam in the given period. |
int |
getAveragePeriod()
Average period. |
int |
getDistributionConstraintPenalty(ExamRoomPlacement room)
Check all soft distribution constraint that this exam is involved in |
Vector |
getDistributionConstraints()
List of distribution constraints that this exam is involved in |
Vector |
getInstructors()
List of instructors that are assigned to this exam |
Hashtable |
getJointEnrollments()
Joint enrollments |
int |
getLength()
Length of the exam in minutes. |
int |
getMaxRooms()
Maximal number of rooms that can be assigned to the exam |
int |
getMinSize()
Minimal exam size, see getSize() |
String |
getName()
Exam name |
Vector |
getOwners()
Courses and/or sections that are having this exam |
Vector |
getOwners(ExamInstructor instructor)
Courses/sections of this exam into which the given instructor is enrolled into |
Vector |
getOwners(ExamStudent student)
Courses/sections of this exam into which the given student is enrolled into |
ExamPeriodPlacement |
getPeriodPlacement(ExamPeriod period)
Returns appropriate ExamPeriodPlacement for the given period, if it is available for this exam, null otherwise. |
ExamPeriodPlacement |
getPeriodPlacement(Long periodId)
Returns appropriate ExamPeriodPlacement for the given period, if it is available for this exam, null otherwise. |
Vector |
getPeriodPlacements()
Return list of possible period placements. |
Integer |
getPrintOffset()
Print offset -- for reporting purposes |
ExamRoomPlacement |
getRoomPlacement(ExamRoom room)
Returns appropriate ExamRoomPlacement for the given room, if it is available for this exam, null otherwise. |
ExamRoomPlacement |
getRoomPlacement(long roomId)
Returns appropriate ExamRoomPlacement for the given room, if it is available for this exam, null otherwise. |
Vector |
getRoomPlacements()
Return list of possible room placements. |
int |
getSize()
Exam size, it is bigger from getMinSize() and the number of students enrolled into the exam getStudents() . |
Integer |
getSizeOverride()
Override exam size with given value (revert to default when null) |
HashSet |
getStudentConflicts(ExamPeriod period)
List of exams that are assigned to the given period and share one or more students with this exam (that does not have direct conflicts allowed, see ExamStudent.canConflict(Exam, Exam) ). |
Vector |
getStudents()
List of students that are enrolled in the exam |
boolean |
hasAltSeating()
True if alternative seating is required ( ExamRoom.getAltSize() is to be used),
false if normal seating is required (ExamRoom.getSize() is to be used). |
boolean |
hasAveragePeriod()
True if there is an average period assigned to the exam. |
boolean |
hasName()
Exam name |
boolean |
hasStudentConflictWithPreAssigned(ExamPeriod period)
True, if there is a student of this exam (that does not have direct conflicts allowed, see ExamStudent.canConflict(Exam, Exam) )
that attends some other exam in the given period. |
boolean |
hasValues()
Return true if there are some values in the domain of this variable |
boolean |
isAllowDirectConflicts()
True if a direct student conflict is allowed, see ExamStudent.canConflict(Exam, Exam) |
int |
nrStudentCorrelatedExams()
Number of exams that are correlated with this exam (there is at least one student attending both exams). |
void |
removeContstraint(Constraint constraint)
Removes a constraint. |
void |
setAllowDirectConflicts(boolean allowDirectConflicts)
Set whether a direct student conflict is allowed, see ExamStudent.canConflict(Exam, Exam) |
void |
setAveragePeriod(int period)
Set average period. |
void |
setMaxRooms(int maxRooms)
Set maximal number of rooms that can be assigned to the exam |
void |
setMinSize(int minSize)
Minimal exam size, see getSize() |
void |
setName(String name)
Exam name |
void |
setPrintOffset(Integer printOffset)
Print offset -- for reporting purposes |
void |
setSizeOverride(Integer size)
Override exam size with given value (revert to default when null) |
String |
toString()
String representation |
Vector |
values()
Values (assignment of a period and a set of rooms) |
Methods inherited from class net.sf.cpsolver.ifs.model.Variable |
---|
addVariableListener, constraints, constraintVariables, countAssignments, equals, getAssignment, getBestAssignment, getBestAssignmentIteration, getDescription, getExtra, getId, getInitialAssignment, getModel, getVariableListeners, hardConstraints, hasAssignment, hashCode, hasInitialAssignment, lastAssignmentIteration, lastUnassignmentIteration, removeInitialValue, removeValue, removeVariableListener, setBestAssignment, setExtra, setInitialAssignment, setModel, setValues, softConstraints, unassign |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static DecimalFormat sDoubleFormat
Constructor Detail |
---|
public Exam(long id, String name, int length, boolean altSeating, int maxRooms, int minSize, Vector periodPlacements, Vector roomPlacements)
id
- exam unique idlength
- exam length in minutesaltSeating
- true if alternative seating is requestedmaxRooms
- maximum number of rooms to be usedminSize
- minimal size of rooms into which an exam can be assigned (see getSize()
)periodPlacements
- list of periods and their penalties ExamPeriodPlacement
into which an exam can be assignedroomPlacements
- list of rooms and their penalties ExamRoomPlacement
into which an exam can be assignedMethod Detail |
---|
public int getSize()
getMinSize()
and the number of students enrolled into the exam getStudents()
.
If getMaxRooms()
is greater than zero, an exam must be assigned into rooms which overall size (or alternative seating size if
hasAltSeating()
) must be equal or greater than this size.
public void setSizeOverride(Integer size)
public Integer getSizeOverride()
public Integer getPrintOffset()
public void setPrintOffset(Integer printOffset)
public int getMinSize()
getSize()
public void setMinSize(int minSize)
getSize()
public Vector values()
values
in class Variable
ExamPlacement
public Vector getRoomPlacements()
ExamRoomPlacement
public Vector getPeriodPlacements()
ExamPeriodPlacement
public boolean hasAltSeating()
ExamRoom.getAltSize()
is to be used),
false if normal seating is required (ExamRoom.getSize()
is to be used).
public int getLength()
public void setAveragePeriod(int period)
ExamPlacement.getRotationPenalty()
in order to
put more weight on exams that were badly assigned last time(s) and ensuring some form of
fairness.
period
- average periodpublic int getAveragePeriod()
ExamPlacement.getRotationPenalty()
in order to
put more weight on exams that were badly assigned last time(s) and ensuring some form of
fairness.
public boolean hasAveragePeriod()
ExamPlacement.getRotationPenalty()
in order to
put more weight on exams that were badly assigned last time(s) and ensuring some form of
fairness.
public boolean isAllowDirectConflicts()
ExamStudent.canConflict(Exam, Exam)
public void setAllowDirectConflicts(boolean allowDirectConflicts)
ExamStudent.canConflict(Exam, Exam)
allowDirectConflicts
- true if a direct student conflict is allowedpublic void addContstraint(Constraint constraint)
Model.addConstraint(Constraint)
is called.
addContstraint
in class Variable
constraint
- added constraintpublic void removeContstraint(Constraint constraint)
Model.removeConstraint(Constraint)
is called.
removeContstraint
in class Variable
constraint
- added constraintpublic Vector getStudents()
ExamStudent
public Vector getDistributionConstraints()
ExamDistributionConstraint
public Vector getInstructors()
ExamInstructor
public boolean checkDistributionConstraints(ExamPeriodPlacement period)
period
- a period to be assigned to this exam
public boolean checkDistributionConstraints(ExamRoomPlacement room)
room
- a room to be assigned to this exam
public int getDistributionConstraintPenalty(ExamRoomPlacement room)
room
- a room to be assigned to this exam
public int getMaxRooms()
public void setMaxRooms(int maxRooms)
maxRooms
- maximal number of rooms that can be assigned to the exampublic Set findBestAvailableRooms(ExamPeriodPlacement period)
period
- given period.
public Set findRoomsRandom(ExamPeriodPlacement period)
period
- given period.
public Set findRoomsRandom(ExamPeriodPlacement period, boolean checkConflicts)
period
- given period.checkConflicts
- if false, room and distribution conflicts are not checked
public int nrStudentCorrelatedExams()
public int compareTo(Object o)
nrStudentCorrelatedExams()
).
If it is the same, ratio number of students / number of available periods is used.
If the same, exam ids are used.
compareTo
in interface Comparable
compareTo
in class Variable
public boolean hasStudentConflictWithPreAssigned(ExamPeriod period)
ExamStudent.canConflict(Exam, Exam)
)
that attends some other exam in the given period.
period
- a period
public int countStudentConflicts(ExamPeriodPlacement period)
ExamStudent.canConflict(Exam, Exam)
)
that attend some other exam in the given period.
period
- a period
public HashSet getStudentConflicts(ExamPeriod period)
ExamStudent.canConflict(Exam, Exam)
).
period
- a period
Exam
(other than this exam, that are placed in the given period and create
prohibited direct conflicts)public void allowAllStudentConflicts(ExamPeriod period)
ExamStudent.canConflict(Exam, Exam)
).
period
- a periodpublic String toString()
toString
in class Variable
public String getName()
getName
in class Variable
public void setName(String name)
public boolean hasName()
public Hashtable getJointEnrollments()
Exam
(an exam that has at least one student in common with this exam) -> Vector
(list of students in common)public Vector getOwners()
ExamOwner
public Vector getOwners(ExamStudent student)
student
- a student that is enrolled into this exam
ExamOwner
which are having this exam with the given student enrolled inpublic Vector getOwners(ExamInstructor instructor)
instructor
- an instructor that is enrolled into this exam
ExamOwner
which are having this exam with the given instructor enrolled inpublic ExamPeriodPlacement getPeriodPlacement(Long periodId)
ExamPeriodPlacement
for the given period, if it is available for this exam, null otherwise.
public ExamRoomPlacement getRoomPlacement(long roomId)
ExamRoomPlacement
for the given room, if it is available for this exam, null otherwise.
public ExamPeriodPlacement getPeriodPlacement(ExamPeriod period)
ExamPeriodPlacement
for the given period, if it is available for this exam, null otherwise.
public ExamRoomPlacement getRoomPlacement(ExamRoom room)
ExamRoomPlacement
for the given room, if it is available for this exam, null otherwise.
public boolean hasValues()
hasValues
in class Variable
public void assign(long iteration, Value value)
Variable
assign
in class Variable
iteration
- current iterationvalue
- the value to be assigned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |