org.cpsolver.exam.model

## Class ExamPlacement

- java.lang.Object
- - org.cpsolver.ifs.model.Value<Exam,ExamPlacement>
  - - org.cpsolver.exam.model.ExamPlacement

- All Implemented Interfaces:
    Comparable<ExamPlacement>, AssignmentComparable<ExamPlacement,Exam,ExamPlacement>

      public class ExamPlacement
      extends Value<Exam,ExamPlacement>

  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).
  Version:
    ExamTT 1.3 (Examination Timetabling)
    Copyright (C) 2008 - 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    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 3 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 see http://www.gnu.org/licenses/.
  Author:
    Tomáš Müller

- - ### Field Summary

    - ### Fields inherited from class org.cpsolver.ifs.model.Value

      `iValue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExamPlacement(Exam exam, ExamPeriodPlacement periodPlacement, Set<ExamRoomPlacement> roomPlacements)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(ExamRoom room)` True if given room is between `getRoomPlacements()`
    `boolean` | `equals(Object o)` Compare two assignments for equality
    `double` | `getDistanceInMeters(ExamPlacement other)` Distance between two placements, i.e., maximal distance between a room of this placement and a room of the given placement.
    `String` | `getName()` Assignment name (period / room(s))
    `ExamPeriod` | `getPeriod()` Assigned period
    `ExamPeriodPlacement` | `getPeriodPlacement()` Assigned period placement
    `double` | `getRoomCost(Assignment<Exam,ExamPlacement> assignment)` Overall cost of using this set or rooms.
    `String` | `getRoomName(String delim)` Room names separated with the given delimiter
    `Set<ExamRoomPlacement>` | `getRoomPlacements()` Assigned rooms (it is empty when `Exam.getMaxRooms()` is zero)
    `double` | `getTimeCost(Assignment<Exam,ExamPlacement> assignment)` Overall cost of using this period.
    `int` | `hashCode()` Hash code
    `double` | `toDouble(Assignment<Exam,ExamPlacement> assignment)` Overall cost of using this placement.
    `String` | `toString()` String representation -- returns a list of assignment costs
    `String` | `toString(Assignment<Exam,ExamPlacement> assignment)` String representation -- returns a list of assignment costs

    - ### Methods inherited from class org.cpsolver.ifs.model.Value

      `compareTo, compareTo, conflicts, conflicts, getDescription, getExtra, getId, isConsistent, setExtra, setVariable, toDouble, valueEquals, 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<ExamRoomPlacement> roomPlacements)

      Constructor
      Parameters:
        `exam` - an exam
        `periodPlacement` - period placement
        `roomPlacements` - a set of room placements `ExamRoomPlacement`

  - ### Method Detail

    - #### getPeriod

          public ExamPeriod getPeriod()

      Assigned period
      Returns:
        assigned period

    - #### getPeriodPlacement

          public ExamPeriodPlacement getPeriodPlacement()

      Assigned period placement
      Returns:
        assigned period placement

    - #### getRoomPlacements

          public Set<ExamRoomPlacement> getRoomPlacements()

      Assigned rooms (it is empty when `Exam.getMaxRooms()` is zero)
      Returns:
        list of `ExamRoomPlacement`

    - #### getDistanceInMeters

          public double getDistanceInMeters(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.getDistanceInMeters(ExamRoom)` is used to get a distance between two rooms.
      Parameters:
        `other` - other placement
      Returns:
        maximal distance to the other placement

    - #### toDouble

          public double toDouble(Assignment<Exam,ExamPlacement> assignment)

      Overall cost of using this placement.
      Overrides:
        `toDouble` in class `Value<Exam,ExamPlacement>`
      Parameters:
        `assignment` - current assignment
      Returns:
        this value's contribution to the solution value

    - #### getTimeCost

          public double getTimeCost(Assignment<Exam,ExamPlacement> assignment)

      Overall cost of using this period.
      Parameters:
        `assignment` - current assignment
      Returns:
        sum of all criteria weighted `Criterion.getWeight()` period values `ExamCriterion.getPeriodValue(Assignment, ExamPlacement)`

    - #### getRoomCost

          public double getRoomCost(Assignment<Exam,ExamPlacement> assignment)

      Overall cost of using this set or rooms.
      Parameters:
        `assignment` - current assignment
      Returns:
        sum of all criteria weighted `Criterion.getWeight()` room values `ExamCriterion.getRoomValue(Assignment, ExamPlacement)`

    - #### getRoomName

          public String getRoomName(String delim)

      Room names separated with the given delimiter
      Parameters:
        `delim` - delimiter
      Returns:
        delimiter separated list of room names

    - #### getName

          public String getName()

      Assignment name (period / room(s))
      Overrides:
        `getName` in class `Value<Exam,ExamPlacement>`
      Returns:
        value name

    - #### toString

          public String toString(Assignment<Exam,ExamPlacement> assignment)

      String representation -- returns a list of assignment costs
      Parameters:
        `assignment` - current assignment
      Returns:
        debug string

    - #### toString

          public String toString()

      String representation -- returns a list of assignment costs
      Overrides:
        `toString` in class `Value<Exam,ExamPlacement>`

    - #### equals

          public boolean equals(Object o)

      Compare two assignments for equality
      Overrides:
        `equals` in class `Value<Exam,ExamPlacement>`

    - #### hashCode

          public int hashCode()

      Hash code
      Overrides:
        `hashCode` in class `Value<Exam,ExamPlacement>`

    - #### contains

          public boolean contains(ExamRoom room)

      True if given room is between `getRoomPlacements()`
      Parameters:
        `room` - a room
      Returns:
        true if this placement contains the given room