org.cpsolver.coursett.constraint

## Class SoftInstructorConstraint

- java.lang.Object
- - org.cpsolver.ifs.model.Constraint<V,T>
  - - org.cpsolver.ifs.assignment.context.ConstraintWithContext<Lecture,Placement,InstructorConstraint.InstructorConstraintContext>
    - - org.cpsolver.coursett.constraint.InstructorConstraint
      - - org.cpsolver.coursett.constraint.SoftInstructorConstraint

- All Implemented Interfaces:
    Comparable<Constraint<Lecture,Placement>>, CanHoldContext, HasAssignmentContext<Lecture,Placement,InstructorConstraint.InstructorConstraintContext>

      public class SoftInstructorConstraint
      extends InstructorConstraint

  Soft version of the instructor constraint.
  Version:
    CourseTT 1.3 (University Course Timetabling)
    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

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `SoftInstructorConstraint.SoftInstructorConstraintContext`

    - ### Nested classes/interfaces inherited from class org.cpsolver.coursett.constraint.InstructorConstraint

      `InstructorConstraint.InstructorConstraintContext`

  - ### Field Summary

    - ### 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
    `SoftInstructorConstraint(Long id, String puid, String name, boolean ignDist)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `computeConflicts(Assignment<Lecture,Placement> assignment, Placement placement, Set<Placement> conflicts)` The only method which has to be implemented by any constraint.
    `InstructorConstraint.InstructorConstraintContext` | `createAssignmentContext(Assignment<Lecture,Placement> assignment)` Create a new assignment context for the given assignment.
    `int` | `getConflicts(Assignment<Lecture,Placement> assignment)`
    `int` | `getConflicts(Assignment<Lecture,Placement> assignment, Placement placement)`
    `int` | `getWorstConflicts()`
    `boolean` | `inConflict(Assignment<Lecture,Placement> assignment, Placement placement)` Returns true if the given assignment is inconsistent with the existing assignments respecting this constraint.
    `boolean` | `isConsistent(Placement p1, Placement p2)` Returns true if the given assignments are consistent respecting this constraint.
    `boolean` | `isHard()` Returns true if the constraint is hard.

    - ### Methods inherited from class org.cpsolver.coursett.constraint.InstructorConstraint

      `getAvailableArray, getDistanceMetric, getDistancePreference, getName, getPreference, getPreference, getPreferenceCombination, getPuid, getResourceId, getType, getUnavailabilities, getWorstPreference, isAvailable, isAvailable, isIgnoreDistances, setIgnoreDistances, setNotAvailable, setType, toString`

    - ### 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, removeConstraintListener, removeVariable, variables`

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

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

- - ### Constructor Detail

    - #### SoftInstructorConstraint

          public SoftInstructorConstraint(Long id,
                                          String puid,
                                          String name,
                                          boolean ignDist)

  - ### Method Detail

    - #### computeConflicts

          public void computeConflicts(Assignment<Lecture,Placement> assignment,
                                       Placement placement,
                                       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 `InstructorConstraint`
      Parameters:
        `assignment` - current assignment
        `placement` - value to be assigned to its variable
        `conflicts` - resultant set of conflicting values

    - #### inConflict

          public boolean inConflict(Assignment<Lecture,Placement> assignment,
                                    Placement placement)

      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 `InstructorConstraint`
      Parameters:
        `assignment` - current assignment
        `placement` - given value
      Returns:
        true if there is a conflict with other assigned variables of the constraint

    - #### isConsistent

          public boolean isConsistent(Placement p1,
                                      Placement p2)

      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 `InstructorConstraint`
      Parameters:
        `p1` - a value
        `p2` - a value
      Returns:
        true if the constraint is ok with the assignment

    - #### isHard

          public boolean isHard()

      Description copied from class: `Constraint`
      Returns true if the constraint is hard. Only hard constraints are allowed to unassign a variable when there is a conflict with a value that is being assigned
      Overrides:
        `isHard` in class `Constraint<Lecture,Placement>`
      Returns:
        true if the constraint is hard

    - #### createAssignmentContext

          public InstructorConstraint.InstructorConstraintContext createAssignmentContext(Assignment<Lecture,Placement> 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.
      Specified by:
        `createAssignmentContext` in interface `HasAssignmentContext<Lecture,Placement,InstructorConstraint.InstructorConstraintContext>`
      Overrides:
        `createAssignmentContext` in class `InstructorConstraint`
      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

    - #### getConflicts

          public int getConflicts(Assignment<Lecture,Placement> assignment)

    - #### getConflicts

          public int getConflicts(Assignment<Lecture,Placement> assignment,
                                  Placement placement)

    - #### getWorstConflicts

          public int getWorstConflicts()