org.cpsolver.ifs.extension

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

- java.lang.Object
- - org.cpsolver.ifs.extension.Extension<V,T>

- Type Parameters:
    `V` - Variable
    `T` - Value
  All Implemented Interfaces:
    ModelListener<V,T>
  Direct Known Subclasses:
    ConflictStatistics, ExtensionWithContext, ViolatedInitials

      public class Extension<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object
      implements ModelListener<V,T>

  Generic extension of IFS solver.
  All extensions should extend this class.
  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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Extension(Solver<V,T> solver, DataProperties properties)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterAssigned(Assignment<V,T> assignment, long iteration, T value)` Called after a value is assigned to a variable
    `void` | `afterUnassigned(Assignment<V,T> assignment, long iteration, T value)` Called after a value is unassigned from a variable
    `void` | `beforeAssigned(Assignment<V,T> assignment, long iteration, T value)` Called before a value is assigned to a variable
    `void` | `beforeUnassigned(Assignment<V,T> assignment, long iteration, T value)` Called after a value is unassigned from a variable
    `void` | `constraintAdded(Constraint<V,T> constraint)` Called when a constraint is added to the model
    `void` | `constraintRemoved(Constraint<V,T> constraint)` Called when a constraint is removed from the model
    `Model<V,T>` | `getModel()` Returns the model
    `DataProperties` | `getProperties()` Returns input configuration
    `Solver<V,T>` | `getSolver()` Returns the solver
    `boolean` | `init(Solver<V,T> solver)` Initialization -- called before the solver is started
    `boolean` | `isRegistered()` Returns true if there is a model registered to this extension, i.e., when extension is registered.
    `void` | `register(Model<V,T> model)` Registration of a model.
    `void` | `unregister(Model<V,T> model)` Unregistration of a model.
    `void` | `variableAdded(V variable)` Called when a variable is added to the model
    `void` | `variableRemoved(V variable)` Called when a variable is removed from the model

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

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

- - ### Constructor Detail

    - #### Extension

          public Extension(Solver<V,T> solver,
                           DataProperties properties)

      Constructor
      Parameters:
        `solver` - IFS solver
        `properties` - input configuration

  - ### Method Detail

    - #### register

          public void register(Model<V,T> model)

      Registration of a model. This is called by the solver before start.
      Parameters:
        `model` - problem model

    - #### unregister

          public void unregister(Model<V,T> model)

      Unregistration of a model. This is called by the solver when extension is removed.
      Parameters:
        `model` - problem model

    - #### isRegistered

          public boolean isRegistered()

      Returns true if there is a model registered to this extension, i.e., when extension is registered.
      Returns:
        true if registered with a solver

    - #### getModel

          public Model<V,T> getModel()

      Returns the model
      Returns:
        problem model

    - #### getSolver

          public Solver<V,T> getSolver()

      Returns the solver
      Returns:
        current solver

    - #### getProperties

          public DataProperties getProperties()

      Returns input configuration
      Returns:
        solver configuration

    - #### afterAssigned

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

      Called after a value is assigned to a variable
      Specified by:
        `afterAssigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be assigned

    - #### afterUnassigned

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

      Called after a value is unassigned from a variable
      Specified by:
        `afterUnassigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be unassigned

    - #### beforeAssigned

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

      Called before a value is assigned to a variable
      Specified by:
        `beforeAssigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be assigned

    - #### beforeUnassigned

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

      Called after a value is unassigned from a variable
      Specified by:
        `beforeUnassigned` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - value to be unassigned

    - #### constraintAdded

          public void constraintAdded(Constraint<V,T> constraint)

      Called when a constraint is added to the model
      Specified by:
        `constraintAdded` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `constraint` - added constraint

    - #### constraintRemoved

          public void constraintRemoved(Constraint<V,T> constraint)

      Called when a constraint is removed from the model
      Specified by:
        `constraintRemoved` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `constraint` - removed constraint

    - #### variableAdded

          public void variableAdded(V variable)

      Called when a variable is added to the model
      Specified by:
        `variableAdded` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - added variable

    - #### variableRemoved

          public void variableRemoved(V variable)

      Called when a variable is removed from the model
      Specified by:
        `variableRemoved` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `variable` - removed variable

    - #### init

          public boolean init(Solver<V,T> solver)

      Initialization -- called before the solver is started
      Specified by:
        `init` in interface `ModelListener<V extends Variable<V,T>,T extends Value<V,T>>`
      Parameters:
        `solver` - IFS solver
      Returns:
        true if successfully initialized