org.cpsolver.studentsct.extension

## Class DistanceConflict.DistanceConflictContext

- java.lang.Object
- - org.cpsolver.studentsct.extension.DistanceConflict.DistanceConflictContext

- All Implemented Interfaces:
    AssignmentConstraintContext<Request,Enrollment>, AssignmentContext
  Enclosing class:
    DistanceConflict

      public class DistanceConflict.DistanceConflictContext
      extends Object
      implements AssignmentConstraintContext<Request,Enrollment>

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistanceConflictContext(Assignment<Request,Enrollment> assignment)`
    `DistanceConflictContext(DistanceConflict.DistanceConflictContext parent)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterAssigned(Assignment<Request,Enrollment> assignment, long iteration, Enrollment value)` Called after a value is assigned to a variable.
    `void` | `afterUnassigned(Assignment<Request,Enrollment> assignment, long iteration, Enrollment value)` Called after a value is unassigned from a variable.
    `void` | `assigned(Assignment<Request,Enrollment> assignment, Enrollment value)` Called when a value is assigned to a variable.
    `void` | `beforeAssigned(Assignment<Request,Enrollment> assignment, long iteration, Enrollment value)` Called before a value is assigned to a variable.
    `Set<DistanceConflict.Conflict>` | `getAllConflicts()` Return a set of all distance conflicts (`DistanceConflict.Conflict` objects).
    `int` | `getTotalNrConflicts()` Actual number of all distance conflicts
    `int` | `getTotalNrShortConflicts()` Actual number of all distance conflicts of students that need short distances
    `void` | `checkAllConflicts(Assignment<Request,Enrollment> assignment)` Checks the counter counting all conflicts
    `int` | `nrAllConflicts(Assignment<Request,Enrollment> assignment, Enrollment enrollment)` Total sum of all conflict of the given enrollment and other enrollments that are assigned to the same student.
    `void` | `unassigned(Assignment<Request,Enrollment> assignment, Enrollment value)` Called when a value is unassigned from a variable.

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

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

- - ### Constructor Detail

    - #### DistanceConflictContext

          public DistanceConflictContext(Assignment<Request,Enrollment> assignment)

    - #### DistanceConflictContext

          public DistanceConflictContext(DistanceConflict.DistanceConflictContext parent)

  - ### Method Detail

    - #### beforeAssigned

          public void beforeAssigned(Assignment<Request,Enrollment> assignment,
                                     long iteration,
                                     Enrollment value)

      Called before a value is assigned to a variable.
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be assigned

    - #### afterAssigned

          public void afterAssigned(Assignment<Request,Enrollment> assignment,
                                    long iteration,
                                    Enrollment value)

      Called after a value is assigned to a variable.
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value that was assigned

    - #### afterUnassigned

          public void afterUnassigned(Assignment<Request,Enrollment> assignment,
                                      long iteration,
                                      Enrollment value)

      Called after a value is unassigned from a variable.
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be unassigned

    - #### assigned

          public void assigned(Assignment<Request,Enrollment> assignment,
                               Enrollment value)

      Called when a value is assigned to a variable. Internal number of distance conflicts is updated, see `DistanceConflict.getTotalNrConflicts(Assignment)`.
      Specified by:
        `assigned` in interface `AssignmentConstraintContext<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment (with which this context is associated)
        `value` - assigned value

    - #### unassigned

          public void unassigned(Assignment<Request,Enrollment> assignment,
                                 Enrollment value)

      Called when a value is unassigned from a variable. Internal number of distance conflicts is updated, see `DistanceConflict.getTotalNrConflicts(Assignment)`.
      Specified by:
        `unassigned` in interface `AssignmentConstraintContext<Request,Enrollment>`
      Parameters:
        `assignment` - current assignment (with which this context is associated)
        `value` - unassigned value

    - #### checkAllConflicts

          public void checkAllConflicts(Assignment<Request,Enrollment> assignment)

      Checks the counter counting all conflicts
      Parameters:
        `assignment` - current assignment

    - #### getTotalNrConflicts

          public int getTotalNrConflicts()

      Actual number of all distance conflicts
      Returns:
        number of all distance conflicts

    - #### getTotalNrShortConflicts

          public int getTotalNrShortConflicts()

      Actual number of all distance conflicts of students that need short distances
      Returns:
        number of all distance conflicts

    - #### getAllConflicts

          public Set<DistanceConflict.Conflict> getAllConflicts()

      Return a set of all distance conflicts (`DistanceConflict.Conflict` objects).
      Returns:
        all distance conflicts

    - #### nrAllConflicts

          public int nrAllConflicts(Assignment<Request,Enrollment> assignment,
                                    Enrollment enrollment)

      Total sum of all conflict of the given enrollment and other enrollments that are assigned to the same student.
      Parameters:
        `assignment` - current assignment
        `enrollment` - given enrollment
      Returns:
        number of all conflict of the given enrollment