|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.cpsolver.ifs.model.Variable<Exam,ExamPlacement>
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,
List<ExamPeriodPlacement> periodPlacements,
List<ExamRoomPlacement> roomPlacements)
Constructor |
Method Summary | |
---|---|
void |
addContstraint(Constraint<Exam,ExamPlacement> 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,
ExamPlacement placement)
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(Exam 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<ExamRoomPlacement> |
findBestAvailableRooms(ExamPeriodPlacement period)
Find best available rooms for the exam in the given period. |
Set<ExamRoomPlacement> |
findRoomsRandom(ExamPeriodPlacement period)
Randomly find a set of available rooms for the exam in the given period. |
Set<ExamRoomPlacement> |
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 |
List<ExamDistributionConstraint> |
getDistributionConstraints()
List of distribution constraints that this exam is involved in |
List<ExamInstructor> |
getInstructors()
List of instructors that are assigned to this exam |
Map<Exam,List<ExamStudent>> |
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 |
List<ExamOwner> |
getOwners()
Courses and/or sections that are having this exam |
Collection<ExamOwner> |
getOwners(ExamInstructor instructor)
Courses/sections of this exam into which the given instructor is enrolled into |
Collection<ExamOwner> |
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. |
List<ExamPeriodPlacement> |
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. |
List<ExamRoomPlacement> |
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<Exam> |
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) ). |
Set<Exam> |
getStudentCorrelatedExams()
Exams that are correlated with this exam (there is at least one student attending both exams). |
List<ExamStudent> |
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<Exam,ExamPlacement> 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 |
List<ExamPlacement> |
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, List<ExamPeriodPlacement> periodPlacements, List<ExamRoomPlacement> 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 List<ExamPlacement> values()
values
in class Variable<Exam,ExamPlacement>
ExamPlacement
public List<ExamRoomPlacement> getRoomPlacements()
ExamRoomPlacement
public List<ExamPeriodPlacement> 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)
ExamRotationPenalty
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()
ExamRotationPenalty
in order to put more weight on
exams that were badly assigned last time(s) and ensuring some form of
fairness.
public boolean hasAveragePeriod()
ExamRotationPenalty
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<Exam,ExamPlacement> constraint)
Model.addConstraint(Constraint)
is called.
addContstraint
in class Variable<Exam,ExamPlacement>
constraint
- added constraintpublic void removeContstraint(Constraint<Exam,ExamPlacement> constraint)
Model.removeConstraint(Constraint)
is
called.
removeContstraint
in class Variable<Exam,ExamPlacement>
constraint
- added constraintpublic List<ExamStudent> getStudents()
ExamStudent
public List<ExamDistributionConstraint> getDistributionConstraints()
ExamDistributionConstraint
public List<ExamInstructor> 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<ExamRoomPlacement> findBestAvailableRooms(ExamPeriodPlacement period)
period
- given period.
public Set<ExamRoomPlacement> findRoomsRandom(ExamPeriodPlacement period)
period
- given period.
public Set<ExamRoomPlacement> findRoomsRandom(ExamPeriodPlacement period, boolean checkConflicts)
period
- given period.checkConflicts
- if false, room and distribution conflicts are not checked
public int nrStudentCorrelatedExams()
public Set<Exam> getStudentCorrelatedExams()
public int compareTo(Exam 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<Exam>
compareTo
in class Variable<Exam,ExamPlacement>
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<Exam> 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<Exam,ExamPlacement>
public String getName()
getName
in class Variable<Exam,ExamPlacement>
public void setName(String name)
public boolean hasName()
public Map<Exam,List<ExamStudent>> getJointEnrollments()
Exam
(an exam that has at least one student in
common with this exam) -> List
(list of students in
common)public List<ExamOwner> getOwners()
ExamOwner
public Collection<ExamOwner> getOwners(ExamStudent student)
student
- a student that is enrolled into this exam
ExamOwner
which are having this
exam with the given student enrolled inpublic Collection<ExamOwner> 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<Exam,ExamPlacement>
public void assign(long iteration, ExamPlacement placement)
Variable
assign
in class Variable<Exam,ExamPlacement>
iteration
- current iterationplacement
- the value to be assigned
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |