org.cpsolver.ifs.model

## Class GlobalConstraint<V extends Variable<V,T>,T extends Value<V,T>>

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<V,T>
  - - org.cpsolver.ifs.model.GlobalConstraint<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    Comparable<Constraint<V,T>>
  Direct Known Subclasses:
    CancelledSections, ConfigLimit, CourseLimit, DependentCourses, DisabledSections, ExtendedStudentConflicts, FixedAssignments, FixInitialAssignments, FreeTimeConflicts, GroupConstraint, HardDistanceConflicts, InstructorConstraint, MaxOverExpectedConstraint, NoStudentOnlineConflicts, RequiredReservation, RequiredRestrictions, RequiredSections, ReservationLimit, SectionLimit, StudentNotAvailable

      public abstract class GlobalConstraint<V extends Variable<V,T>,T extends Value<V,T>>
      extends Constraint<V,T>

  Generic global constraint.
  Global constraint is a `Constraint` that applies to all variables.
  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/.
  Author:
    Tomáš Müller
  See Also:
    `Variable`, `Model`, `Constraint`, `Solver`

- - ### Field Summary

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

      `iConstraintListeners, iId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GlobalConstraint()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addVariable(V variable)` Add a variable to this constraint
    `void` | `assigned(Assignment<V,T> assignment, long iteration, T value)` Given value is to be assigned to its variable.
    `Collection<V>` | `assignedVariables(Assignment<V,T> assignment)` The list of variables of this constraint that are assigned
    `int` | `countAssignedVariables(Assignment<V,T> assignment)` The number of variables of this constraint that are assigned
    `String` | `getName()` Constraint's name -- for printing purposes
    `void` | `removeVariable(V variable)` Remove a variable from this constraint
    `String` | `toString()`
    `void` | `unassigned(Assignment<V,T> assignment, long iteration, T value)` Given value is unassigned from its varable.
    `List<V>` | `variables()` The list of variables of this constraint

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

      `addConstraintListener, compareTo, computeConflicts, computeConflictsNoForwardCheck, constraintListeners, countVariables, equals, getDescription, getId, getModel, hashCode, inConflict, isConsistent, isHard, removeConstraintListener, setModel`

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

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

- - ### Constructor Detail

    - #### GlobalConstraint

          public GlobalConstraint()

  - ### Method Detail

    - #### variables

          public List<V> variables()

      The list of variables of this constraint
      Overrides:
        `variables` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        variables of this constraint

    - #### assignedVariables

          public Collection<V> assignedVariables(Assignment<V,T> assignment)

      The list of variables of this constraint that are assigned
      Overrides:
        `assignedVariables` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
      Returns:
        assigned variables of this constraint

    - #### countAssignedVariables

          public int countAssignedVariables(Assignment<V,T> assignment)

      The number of variables of this constraint that are assigned
      Overrides:
        `countAssignedVariables` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
      Returns:
        number of variables of this constraint that are assigned

    - #### addVariable

          public void addVariable(V variable)

      Add a variable to this constraint
      Overrides:
        `addVariable` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - a variable

    - #### removeVariable

          public void removeVariable(V variable)

      Remove a variable from this constraint
      Overrides:
        `removeVariable` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - a variable

    - #### assigned

          public void assigned(Assignment<V,T> assignment,
                               long iteration,
                               T value)

      Given value is to be assigned to its variable. In this method, the constraint should unassigns all variables which are in conflict with the given assignment because of this constraint.
      Overrides:
        `assigned` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - assigned value

    - #### unassigned

          public void unassigned(Assignment<V,T> assignment,
                                 long iteration,
                                 T value)

      Given value is unassigned from its varable.
      Overrides:
        `unassigned` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - unassigned value

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getName

          public String getName()

      Description copied from class: `Constraint`
      Constraint's name -- for printing purposes
      Overrides:
        `getName` in class `Constraint<V extends Variable<V,T>,T extends Value<V,T>>`
      Returns:
        constraint name