org.cpsolver.ifs.example.tt

## Class Resource

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<V,T>
  - - org.cpsolver.ifs.assignment.context.ConstraintWithContext<Activity,Location,Resource.Context>
    - - org.cpsolver.ifs.example.tt.Resource

- All Implemented Interfaces:
    Comparable<Constraint<Activity,Location>>, CanHoldContext, HasAssignmentContext<Activity,Location,Resource.Context>

      public class Resource
      extends ConstraintWithContext<Activity,Location,Resource.Context>

  Resource constraint
  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/.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `Resource.Context` Assignment context

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `TYPE_CLASS`
    `static int` | `TYPE_INSTRUCTOR`
    `static int` | `TYPE_OTHER`
    `static int` | `TYPE_ROOM`

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

      `iConstraintListeners, iId`

    - ### Fields inherited from interface org.cpsolver.ifs.assignment.context.CanHoldContext

      `sMaxSize`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Resource(String id, int type, String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addDiscouragedSlot(int slot)`
    `void` | `addDiscouragedSlot(int day, int hour)`
    `void` | `addProhibitedSlot(int slot)`
    `void` | `addProhibitedSlot(int day, int hour)`
    `void` | `computeConflicts(Assignment<Activity,Location> assignment, Location location, Set<Location> conflicts)` The only method which has to be implemented by any constraint.
    `Resource.Context` | `createAssignmentContext(Assignment<Activity,Location> assignment)` Create a new assignment context for the given assignment.
    `Set<Integer>` | `getDiscouragedSlots()`
    `String` | `getName()` Constraint's name -- for printing purposes
    `Set<Integer>` | `getProhibitedSlots()`
    `String` | `getResourceId()`
    `int` | `getType()`
    `boolean` | `inConflict(Assignment<Activity,Location> assignment, Location location)` Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
    `boolean` | `isConsistent(Location l1, Location l2)` Returns true if the given assignments are consistent respecting this constraint.
    `boolean` | `isDiscouragedSlot(int slot)`
    `boolean` | `isDiscouragedSlot(int day, int hour)`
    `boolean` | `isProhibited(int day, int hour, int length)`
    `boolean` | `isProhibitedSlot(int slot)`
    `boolean` | `isProhibitedSlot(int day, int hour)`

    - ### Methods inherited from class org.cpsolver.ifs.assignment.context.ConstraintWithContext

      `assigned, getAssignmentContextReference, getContext, getContext, setAssignmentContextReference, setModel, unassigned`

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

      `addConstraintListener, addVariable, assignedVariables, compareTo, computeConflictsNoForwardCheck, constraintListeners, countAssignedVariables, countVariables, equals, getDescription, getId, getModel, hashCode, isHard, removeConstraintListener, removeVariable, variables`

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

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

- - ### Field Detail

    - #### TYPE_ROOM

          public static final int TYPE_ROOM

      See Also:
        Constant Field Values

    - #### TYPE_INSTRUCTOR

          public static final int TYPE_INSTRUCTOR

      See Also:
        Constant Field Values

    - #### TYPE_CLASS

          public static final int TYPE_CLASS

      See Also:
        Constant Field Values

    - #### TYPE_OTHER

          public static final int TYPE_OTHER

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Resource

          public Resource(String id,
                          int type,
                          String name)

  - ### Method Detail

    - #### getResourceId

          public String getResourceId()

    - #### getName

          public String getName()

      Description copied from class: `Constraint`
      Constraint's name -- for printing purposes
      Overrides:
        `getName` in class `Constraint<Activity,Location>`
      Returns:
        constraint name

    - #### getType

          public int getType()

    - #### getProhibitedSlots

          public Set<Integer> getProhibitedSlots()

    - #### getDiscouragedSlots

          public Set<Integer> getDiscouragedSlots()

    - #### addProhibitedSlot

          public void addProhibitedSlot(int day,
                                        int hour)

    - #### addDiscouragedSlot

          public void addDiscouragedSlot(int day,
                                         int hour)

    - #### isProhibitedSlot

          public boolean isProhibitedSlot(int day,
                                          int hour)

    - #### isDiscouragedSlot

          public boolean isDiscouragedSlot(int day,
                                           int hour)

    - #### addProhibitedSlot

          public void addProhibitedSlot(int slot)

    - #### addDiscouragedSlot

          public void addDiscouragedSlot(int slot)

    - #### isProhibitedSlot

          public boolean isProhibitedSlot(int slot)

    - #### isDiscouragedSlot

          public boolean isDiscouragedSlot(int slot)

    - #### isProhibited

          public boolean isProhibited(int day,
                                      int hour,
                                      int length)

    - #### computeConflicts

          public void computeConflicts(Assignment<Activity,Location> assignment,
                                       Location location,
                                       Set<Location> conflicts)

      Description copied from class: `Constraint`
      The only method which has to be implemented by any constraint. It returns the values which needs to be unassigned in order to make this constraint consistent with the given value if it is assigned to its variable. The computed list of conflicting values is added to the given set of conflicts.
      Specified by:
        `computeConflicts` in class `Constraint<Activity,Location>`
      Parameters:
        `assignment` - current assignment
        `location` - value to be assigned to its variable
        `conflicts` - resultant set of conflicting values

    - #### inConflict

          public boolean inConflict(Assignment<Activity,Location> assignment,
                                    Location location)

      Description copied from class: `Constraint`
      Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint. This method is used by MAC (see `MacPropagation`).
      Overrides:
        `inConflict` in class `Constraint<Activity,Location>`
      Parameters:
        `assignment` - current assignment
        `location` - given value
      Returns:
        true if there is a conflict with other assigned variables of the constraint

    - #### isConsistent

          public boolean isConsistent(Location l1,
                                      Location l2)

      Description copied from class: `Constraint`
      Returns true if the given assignments are consistent respecting this constraint. This method is used by MAC (see `MacPropagation`).
      Overrides:
        `isConsistent` in class `Constraint<Activity,Location>`
      Parameters:
        `l1` - a value
        `l2` - a value
      Returns:
        true if the constraint is ok with the assignment

    - #### createAssignmentContext

          public Resource.Context createAssignmentContext(Assignment<Activity,Location> assignment)

      Description copied from interface: `HasAssignmentContext`
      Create a new assignment context for the given assignment. If there are already some variables assigned in the value, the method should make sure that the context is appropriately initialized.
      Parameters:
        `assignment` - an assignment for which there needs to be an assignment context
      Returns:
        a new instance of the assignment context, filled according to the given assignment