org.cpsolver.ifs.example.tt

## Class Location

- java.lang.Object
- - org.cpsolver.ifs.model.Value<Activity,Location>
  - - org.cpsolver.ifs.example.tt.Location

- All Implemented Interfaces:
    Comparable<Location>, AssignmentComparable<Location,Activity,Location>

      public class Location
      extends Value<Activity,Location>

  Location (value, i.e., a single placement of the activity). Location encodes a slot and a selection of resources.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 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/.

- - ### Field Summary

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

      `iValue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Location(Activity activity, int day, int hour, Resource[] resources)` Constructor. slot = nrHours * day + hour
    `Location(Activity activity, int slot, Resource[] resources)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `computeNrOfDiscouragedSlots()` Computes number of discouraged slots (over all resources and the activity)
    `boolean` | `containResource(Resource resource)` Returns true if the given resource is used by this location
    `String` | `getName()` Values name -- for printing purposes (E.g., Monday 7:30)
    `int` | `getNrOfDiscouragedSlots()` Number of slots (over all resources) which are discouraged
    `Resource` | `getResource(int idx)` Gets given resource
    `Resource[]` | `getResources()` Gets selection of resources
    `int` | `getSlot()` Gets slot
    `boolean` | `hasIntersection(Location location)` Returns true if the location intersects with another location.
    `boolean` | `isProhibited()` Returns true if the location is prohibited.
    `double` | `toDouble()` Placement value (for optimization) -- getNrOfDiscouragedSlots() is returned

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

      `compareTo, compareTo, conflicts, conflicts, equals, getDescription, getExtra, getId, hashCode, isConsistent, setExtra, setVariable, toDouble, toString, valueEquals, valueEquals, variable`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Location

          public Location(Activity activity,
                          int slot,
                          Resource[] resources)

      Constructor.
      Parameters:
        `activity` - parent activity
        `slot` - starting time
        `resources` - selection of resources

    - #### Location

          public Location(Activity activity,
                          int day,
                          int hour,
                          Resource[] resources)

      Constructor. slot = nrHours * day + hour
      Parameters:
        `activity` - parent activity
        `day` - day
        `hour` - starting hour
        `resources` - required resources

  - ### Method Detail

    - #### getSlot

          public int getSlot()

      Gets slot
      Returns:
        slot

    - #### getResources

          public Resource[] getResources()

      Gets selection of resources
      Returns:
        selection of resources

    - #### getResource

          public Resource getResource(int idx)

      Gets given resource
      Parameters:
        `idx` - index
      Returns:
        given resource

    - #### containResource

          public boolean containResource(Resource resource)

      Returns true if the given resource is used by this location
      Parameters:
        `resource` - given resource
      Returns:
        true if the given resource is used by this location

    - #### getNrOfDiscouragedSlots

          public int getNrOfDiscouragedSlots()

      Number of slots (over all resources) which are discouraged
      Returns:
        number of slots (over all resources) which are discouraged

    - #### toDouble

          public double toDouble()

      Placement value (for optimization) -- getNrOfDiscouragedSlots() is returned
      Overrides:
        `toDouble` in class `Value<Activity,Location>`
      Returns:
        this value's contribution to the solution value

    - #### computeNrOfDiscouragedSlots

          public int computeNrOfDiscouragedSlots()

      Computes number of discouraged slots (over all resources and the activity)
      Returns:
        number of discouraged slots

    - #### hasIntersection

          public boolean hasIntersection(Location location)

      Returns true if the location intersects with another location. This means the same resource is used in the same time.
      Parameters:
        `location` - another location
      Returns:
        true if this location intersects with the other location

    - #### isProhibited

          public boolean isProhibited()

      Returns true if the location is prohibited. This means that the activity or a required resource has a time slot which is used by this location prohibited.
      Returns:
        true if the location is prohibited

    - #### getName

          public String getName()

      Description copied from class: `Value`
      Values name -- for printing purposes (E.g., Monday 7:30)
      Overrides:
        `getName` in class `Value<Activity,Location>`
      Returns:
        value name