net.sf.cpsolver.coursett.constraint

## Class DiscouragedRoomConstraint

- java.lang.Object
- - net.sf.cpsolver.ifs.model.Constraint<Lecture,Placement>
  - - net.sf.cpsolver.coursett.constraint.RoomConstraint
    - - net.sf.cpsolver.coursett.constraint.DiscouragedRoomConstraint

- All Implemented Interfaces:
    Comparable<Constraint<Lecture,Placement>>, WeakeningConstraint<Lecture,Placement>

      public class DiscouragedRoomConstraint
      extends RoomConstraint
      implements WeakeningConstraint<Lecture,Placement>

  Discouraged room constraint. This constraint is based on `RoomConstraint`, however, it tries to minimize the usage of the room as much as possible.
  Version:
    CourseTT 1.2 (University Course Timetabling)
    Copyright (C) 2006 - 2010 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 net.sf.cpsolver.ifs.model.Constraint

      `iAssignedVariables, iConstraintListeners, iId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DiscouragedRoomConstraint(DataProperties config, Long id, String name, Long buildingId, int capacity, RoomSharingModel roomSharingModel, Double x, Double y, boolean ignoreTooFar, boolean constraint)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assigned(long iteration, Placement value)` Given value is to be assigned to its varable.
    `void` | `computeConflicts(Placement value, Set<Placement> conflicts)` The only method which has to be implemented by any constraint.
    `int` | `getLimit()`
    `String` | `getName()` Room name
    `int` | `getUsage()`
    `boolean` | `inConflict(Placement value)` Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
    `boolean` | `isConsistent(Placement value1, Placement value2)` Returns true if the given assignments are consistent respecting this constraint.
    `boolean` | `isEnabled()`
    `boolean` | `isOverLimit(Placement value)`
    `void` | `setEnabled(boolean enabled)`
    `String` | `toString()`
    `void` | `unassigned(long iteration, Placement value)` Given value is unassigned from its variable.
    `void` | `weaken()` Weaken the constraint.
    `void` | `weaken(Placement value)` Weaken the constraint enough so that it can assign the given value.

    - ### Methods inherited from class net.sf.cpsolver.coursett.constraint.RoomConstraint

      `getAvailableArray, getBuildingId, getCapacity, getConstraint, getIgnoreTooFar, getPlacement, getPosX, getPosY, getResource, getResourceId, getResourceOfWeek, getRoomName, getSharingModel, getType, isAvailable, isAvailable, printUsage, setCoordinates, setNotAvailable, setType`

    - ### Methods inherited from class net.sf.cpsolver.ifs.model.Constraint

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

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

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

- - ### Constructor Detail

    - #### DiscouragedRoomConstraint

          public DiscouragedRoomConstraint(DataProperties config,
                                           Long id,
                                           String name,
                                           Long buildingId,
                                           int capacity,
                                           RoomSharingModel roomSharingModel,
                                           Double x,
                                           Double y,
                                           boolean ignoreTooFar,
                                           boolean constraint)

  - ### Method Detail

    - #### getLimit

          public int getLimit()

    - #### getUsage

          public int getUsage()

    - #### isOverLimit

          public boolean isOverLimit(Placement value)

    - #### computeConflicts

          public void computeConflicts(Placement value,
                                       Set<Placement> 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.
      Overrides:
        `computeConflicts` in class `RoomConstraint`
      Parameters:
        `value` - value to be assigned to its varaible
        `conflicts` - resultant set of conflicting values

    - #### inConflict

          public boolean inConflict(Placement value)

      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 `RoomConstraint`

    - #### isConsistent

          public boolean isConsistent(Placement value1,
                                      Placement value2)

      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 `RoomConstraint`

    - #### assigned

          public void assigned(long iteration,
                               Placement value)

      Description copied from class: `Constraint`
      Given value is to be assigned to its varable. In this method, the constraint should unassigns all varaibles which are in conflict with the given assignment because of this constraint.
      Overrides:
        `assigned` in class `RoomConstraint`

    - #### unassigned

          public void unassigned(long iteration,
                                 Placement value)

      Description copied from class: `Constraint`
      Given value is unassigned from its variable.
      Overrides:
        `unassigned` in class `RoomConstraint`

    - #### getName

          public String getName()

      Description copied from class: `RoomConstraint`
      Room name
      Overrides:
        `getName` in class `RoomConstraint`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `RoomConstraint`

    - #### setEnabled

          public void setEnabled(boolean enabled)

    - #### isEnabled

          public boolean isEnabled()

    - #### weaken

          public void weaken()

      Description copied from interface: `WeakeningConstraint`
      Weaken the constraint. This method is called if the constraint participates in an unassigned of a variable.
      Specified by:
        `weaken` in interface `WeakeningConstraint<Lecture,Placement>`

    - #### weaken

          public void weaken(Placement value)

      Description copied from interface: `WeakeningConstraint`
      Weaken the constraint enough so that it can assign the given value.
      Specified by:
        `weaken` in interface `WeakeningConstraint<Lecture,Placement>`