net.sf.cpsolver.exam.model
Class ExamPlacement

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Value
      extended by net.sf.cpsolver.exam.model.ExamPlacement
All Implemented Interfaces:
Comparable

public class ExamPlacement
extends Value

Representation of an exam placement (problem value), i.e., assignment of an exam to period and room(s). Each placement has defined a period and a set of rooms. The exam as well as the rooms have to be available during the given period (see Exam.getPeriodPlacements() and Exam.getRoomPlacements()). The total size of rooms have to be equal or greater than the number of students enrolled in the exam Exam.getSize(), using either ExamRoom.getSize() or ExamRoom.getAltSize(), depending on Exam.hasAltSeating(). Also, the number of rooms has to be smaller or equal to Exam.getMaxRooms(). If Exam.getMaxRooms() is zero, the exam is only to be assigned to period (the set of rooms is empty).

The cost of an assignment consists of the following criteria:



Version:
ExamTT 1.1 (Examination Timetabling)
Copyright (C) 2008 Tomáš Müller
muller@unitime.org
Lazenska 391, 76314 Zlin, Czech Republic

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Field Summary
 
Fields inherited from class net.sf.cpsolver.ifs.model.Value
iValue
 
Constructor Summary
ExamPlacement(Exam exam, ExamPeriodPlacement periodPlacement, Set roomPlacements)
          Constructor
 
Method Summary
 boolean contains(ExamRoom room)
          True if given room is between getRoomPlacements()
 boolean equals(Object o)
          Compare two assignments for equality
 int getDistance(ExamPlacement other)
          Distance between two placements, i.e., maximal distance between a room of this placement and a room of the given placement.
 double getDistributionPenalty()
          Distribution penalty, i.e., sum weights of violated distribution constraints
 int getLargePenalty()
          Front load penalty (large exam is discouraged to be placed on or after a certain period)
 String getName()
          Assignment name (period / room(s))
 int getNrBackToBackConflicts()
          Number of back-to-back student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period.
 int getNrDirectConflicts()
          Number of direct student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the same period
 int getNrDistanceBackToBackConflicts()
          Number of back-to-back distance student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period and the distance getDistance(ExamPlacement) between these two exams is greater than ExamModel.getBackToBackDistance().
 int getNrInstructorBackToBackConflicts()
          Number of back-to-back instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period.
 int getNrInstructorDirectConflicts()
          Number of direct instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the same period
 int getNrInstructorDistanceBackToBackConflicts()
          Number of back-to-back distance instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period and the distance getDistance(ExamPlacement) between these two exams is greater than ExamModel.getBackToBackDistance().
 int getNrInstructorMoreThanTwoADayConflicts()
          Number of more than two exams a day instructor conflicts, i.e., when this exam is attended by an instructor student that attends two or more other exams at the same day.
 int getNrInstructorNotAvailableConflicts()
          Number of direct instructor conflicts caused by the fact that a student is not available
 int getNrMoreThanTwoADayConflicts()
          Number of more than two exams a day student conflicts, i.e., when this exam is attended by a student that attends two or more other exams at the same day.
 int getNrNotAvailableConflicts()
          Number of direct student conflicts caused by the fact that a student is not available
 ExamPeriod getPeriod()
          Assigned period
 double getPeriodDistributionPenalty()
          Period related distribution penalty, i.e., sum weights of violated distribution constraints
 int getPeriodPenalty()
          Cost for using a period, i.e., ExamPeriodPlacement.getPenalty()
 ExamPeriodPlacement getPeriodPlacement()
          Assigned period placement
 int getPerturbationPenalty()
          Perturbation penalty, i.e., penalty for using a different assignment than initial.
 double getRoomCost()
          Overall cost of using this set or rooms.
 double getRoomDistributionPenalty()
          Room related distribution penalty, i.e., sum weights of violated distribution constraints
 String getRoomName(String delim)
          Room names separated with the given delimiter
 int getRoomPenalty()
          Room penalty (penalty for using given rooms), i.e., sum of ExamRoomPlacement.getPenalty(ExamPeriod) of assigned rooms
 int getRoomPerturbationPenalty()
          Room perturbation penalty, i.e., number of assigned rooms different from initial.
 Set getRoomPlacements()
          Assigned rooms (it is empty when Exam.getMaxRooms() is zero)
 int getRoomSizePenalty()
          Cost for using room(s) that are too big
 double getRoomSplitDistancePenalty()
          Room split distance penalty, i.e., average distance between two rooms of this placement
 int getRoomSplitPenalty()
          Cost for using more than one room (nrSplits^2).
 int getRotationPenalty()
          Rotation penalty (an exam that has been in later period last times tries to be in an earlier period)
 int getSize()
          Overall size of assigned rooms
 double getTimeCost()
          Overall cost of using this period.
 int hashCode()
          Hash code
 double toDouble()
          Overall cost of using this placement.
 String toString()
          String representation -- returns a list of assignment costs
 
Methods inherited from class net.sf.cpsolver.ifs.model.Value
assigned, compareTo, conflicts, countAssignments, getDescription, getExtra, getId, isConsistent, lastAssignmentIteration, lastUnassignmentIteration, setExtra, setVariable, unassigned, valueEquals, variable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExamPlacement

public ExamPlacement(Exam exam,
                     ExamPeriodPlacement periodPlacement,
                     Set roomPlacements)
Constructor

Parameters:
exam - an exam
periodPlacement - period placement
roomPlacements - a set of room placements ExamRoomPlacement
Method Detail

getPeriod

public ExamPeriod getPeriod()
Assigned period


getPeriodPlacement

public ExamPeriodPlacement getPeriodPlacement()
Assigned period placement


getRoomPlacements

public Set getRoomPlacements()
Assigned rooms (it is empty when Exam.getMaxRooms() is zero)

Returns:
list of ExamRoomPlacement

getSize

public int getSize()
Overall size of assigned rooms


getNrDirectConflicts

public int getNrDirectConflicts()
Number of direct student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the same period


getNrNotAvailableConflicts

public int getNrNotAvailableConflicts()
Number of direct student conflicts caused by the fact that a student is not available


getNrBackToBackConflicts

public int getNrBackToBackConflicts()
Number of back-to-back student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period. If ExamModel.isDayBreakBackToBack() is false, back-to-back conflicts are only considered between consecutive periods that are of the same day.


getDistance

public int getDistance(ExamPlacement other)
Distance between two placements, i.e., maximal distance between a room of this placement and a room of the given placement. Method ExamRoom.getDistance(ExamRoom) is used to get a distance between two rooms.


getNrDistanceBackToBackConflicts

public int getNrDistanceBackToBackConflicts()
Number of back-to-back distance student conflicts, i.e., number of cases when this exam is attended by a student that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period and the distance getDistance(ExamPlacement) between these two exams is greater than ExamModel.getBackToBackDistance(). Distance back-to-back conflicts are only considered between consecutive periods that are of the same day.


getNrMoreThanTwoADayConflicts

public int getNrMoreThanTwoADayConflicts()
Number of more than two exams a day student conflicts, i.e., when this exam is attended by a student that attends two or more other exams at the same day.


getNrInstructorDirectConflicts

public int getNrInstructorDirectConflicts()
Number of direct instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the same period


getNrInstructorNotAvailableConflicts

public int getNrInstructorNotAvailableConflicts()
Number of direct instructor conflicts caused by the fact that a student is not available


getNrInstructorBackToBackConflicts

public int getNrInstructorBackToBackConflicts()
Number of back-to-back instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period. If ExamModel.isDayBreakBackToBack() is false, back-to-back conflicts are only considered between consecutive periods that are of the same day.


getNrInstructorDistanceBackToBackConflicts

public int getNrInstructorDistanceBackToBackConflicts()
Number of back-to-back distance instructor conflicts, i.e., number of cases when this exam is attended by an instructor that attends some other exam at the previous ExamPeriod.prev() or following ExamPeriod.next() period and the distance getDistance(ExamPlacement) between these two exams is greater than ExamModel.getBackToBackDistance(). Distance back-to-back conflicts are only considered between consecutive periods that are of the same day.


getNrInstructorMoreThanTwoADayConflicts

public int getNrInstructorMoreThanTwoADayConflicts()
Number of more than two exams a day instructor conflicts, i.e., when this exam is attended by an instructor student that attends two or more other exams at the same day.


getRoomSizePenalty

public int getRoomSizePenalty()
Cost for using room(s) that are too big

Returns:
difference between total room size (computed using either ExamRoom.getSize() or ExamRoom.getAltSize() based on Exam.hasAltSeating()) and the number of students Exam.getSize()

getRoomSplitPenalty

public int getRoomSplitPenalty()
Cost for using more than one room (nrSplits^2).

Returns:
penalty (1 for 2 rooms, 4 for 3 rooms, 9 for 4 rooms, etc.)

getPeriodPenalty

public int getPeriodPenalty()
Cost for using a period, i.e., ExamPeriodPlacement.getPenalty()


getRotationPenalty

public int getRotationPenalty()
Rotation penalty (an exam that has been in later period last times tries to be in an earlier period)


getLargePenalty

public int getLargePenalty()
Front load penalty (large exam is discouraged to be placed on or after a certain period)

Returns:
zero if not large exam or if before ExamModel.getLargePeriod(), one otherwise

getRoomPenalty

public int getRoomPenalty()
Room penalty (penalty for using given rooms), i.e., sum of ExamRoomPlacement.getPenalty(ExamPeriod) of assigned rooms


getPerturbationPenalty

public int getPerturbationPenalty()
Perturbation penalty, i.e., penalty for using a different assignment than initial. Only applicable when ExamModel.isMPP() is true (minimal perturbation problem).

Returns:
|period index - initial period index | * exam size

getRoomPerturbationPenalty

public int getRoomPerturbationPenalty()
Room perturbation penalty, i.e., number of assigned rooms different from initial. Only applicable when ExamModel.isMPP() is true (minimal perturbation problem).

Returns:
|period index - initial period index | * exam size

getRoomSplitDistancePenalty

public double getRoomSplitDistancePenalty()
Room split distance penalty, i.e., average distance between two rooms of this placement


getDistributionPenalty

public double getDistributionPenalty()
Distribution penalty, i.e., sum weights of violated distribution constraints


getRoomDistributionPenalty

public double getRoomDistributionPenalty()
Room related distribution penalty, i.e., sum weights of violated distribution constraints


getPeriodDistributionPenalty

public double getPeriodDistributionPenalty()
Period related distribution penalty, i.e., sum weights of violated distribution constraints


toDouble

public double toDouble()
Overall cost of using this placement. The cost of an assignment consists of the following criteria:

Overrides:
toDouble in class Value

getTimeCost

public double getTimeCost()
Overall cost of using this period. The time cost of an assignment consists of the following criteria:


getRoomCost

public double getRoomCost()
Overall cost of using this set or rooms. The room cost of an assignment consists of the following criteria:


getRoomName

public String getRoomName(String delim)
Room names separated with the given delimiter


getName

public String getName()
Assignment name (period / room(s))

Overrides:
getName in class Value

toString

public String toString()
String representation -- returns a list of assignment costs

Overrides:
toString in class Value

equals

public boolean equals(Object o)
Compare two assignments for equality

Overrides:
equals in class Value

hashCode

public int hashCode()
Hash code

Overrides:
hashCode in class Value

contains

public boolean contains(ExamRoom room)
True if given room is between getRoomPlacements()