org.cpsolver.ifs.model

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

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

- Type Parameters:
    `V` - Variable
    `T` - Value
  Direct Known Subclasses:
    ConstantModel, CSPModel, InstructorSchedulingModel, JobShopModel, ModelWithContext, RPPModel, StructuredCSPModel, StudentSctBBTest, TimetableModel

      public class Model<V extends Variable<V,T>,T extends Value<V,T>>
      extends Object

  Generic model (definition of a problem).
  It consists of variables and constraints. It has also capability of memorizing the current and the best ever found assignment.
  Example usage:

       MyModel model = new MyModel();
       Variable a = new MyVariable("A");
       model.addVariable(a);
       Variable b = new MyVariable("B");
       model.addVariable(b);
       Variable c = new MyVariable("C");
       model.addVariable(c);
       Constraint constr = MyConstraint("all-different");
       model.addConstraint(constr);
       constr.addVariable(a);
       constr.addVariable(b);
       constr.addVariable(c);
       solver.setInitialSolution(model);

  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`, `Constraint`, `Solution`, `Solver`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static DecimalFormat` | `sDoubleFormat`
    `protected static DecimalFormat` | `sPercentageFormat`
    `protected static DecimalFormat` | `sTimeFormat`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Model()` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConstraint(Constraint<V,T> constraint)` Adds a constraint to the model
    `void` | `addCriterion(Criterion<V,T> criterion)` Register a new criterion
    `void` | `addGlobalConstraint(GlobalConstraint<V,T> constraint)` Adds a global constraint to the model
    `void` | `addModelListener(ModelListener<V,T> listener)` Adds a model listener
    `void` | `addVariable(V variable)` Adds a variable to the model
    `void` | `afterAssigned(Assignment<V,T> assignment, long iteration, T value)` Called after a value is assigned to its variable
    `void` | `afterAssigned(long iteration, T value)` Deprecated.
    `void` | `afterUnassigned(Assignment<V,T> assignment, long iteration, T value)` Called after a value is unassigned from its variable
    `void` | `afterUnassigned(long iteration, T value)` Deprecated.
    `Collection<V>` | `assignedVariables()` Deprecated.
    `Collection<V>` | `assignedVariables(Assignment<V,T> assignment)` The list of assigned variables in the model
    `void` | `beforeAssigned(Assignment<V,T> assignment, long iteration, T value)` Called before a value is assigned to its variable
    `void` | `beforeAssigned(long iteration, T value)` Deprecated.
    `void` | `beforeUnassigned(Assignment<V,T> assignment, long iteration, T value)` Called before a value is unassigned from its variable
    `void` | `beforeUnassigned(long iteration, T value)` Deprecated.
    `Collection<V>` | `bestUnassignedVariables()` Deprecated.
    `Collection<V>` | `bestUnassignedVariables(Assignment<V,T> assignment)` The list of unassigned variables in the best ever found solution
    `void` | `clearAssignmentContexts(Assignment<V,T> assignment)` Clear all assignment contexts for the given assignment
    `void` | `clearBest()` Clear the best ever found assignment
    `Map<Constraint<V,T>,Set<T>>` | `conflictConstraints(Assignment<V,T> assignment, T value)` The list of constraints which are in a conflict with the given value if it is assigned to its variable.
    `Set<T>` | `conflictValues(Assignment<V,T> assignment, T value)` Returns the set of conflicting variables with this value, if it is assigned to its variable
    `Set<T>` | `conflictValues(T value)` Deprecated.
    `List<Constraint<V,T>>` | `constraints()` The list of constraints in the model
    `int` | `countConstraints()` The number of constraints in the model
    `int` | `countGlobalConstraints()` The number of global constraints in the model
    `int` | `countVariables()` The number of variables in the model
    `void` | `createAssignmentContexts(Assignment<V,T> assignment, boolean clear)` Create all assignment contexts for the given assignment
    `InheritedAssignment<V,T>` | `createInheritedAssignment(Solution<V,T> solution, int index)` Create a new inherited assignment from the given solution
    `<C extends AssignmentContext> AssignmentContextReference<V,T,C>` | `createReference(HasAssignmentContext<V,T,C> parent)` Create a reference to an assignment context for a class that is in a need of one.
    `int` | `getBestPerturbations()` Returns the number of perturbation variables in the best ever found solution
    `int` | `getBestUnassignedVariables()` Returns the number of unassigned variables in the best ever found solution
    `double` | `getBestValue()` Total value of the best ever found solution -- sum of all assigned values (see `Value.toDouble(Assignment)`).
    `Collection<Criterion<V,T>>` | `getCriteria()` List all registered criteria
    `Criterion<V,T>` | `getCriterion(Class<? extends Criterion<V,T>> criterion)` Return a registered criterion of the given type.
    `Assignment<V,T>` | `getDefaultAssignment()` Deprecated.
    `Assignment<V,T>` | `getEmptyAssignment()` Returns an instance of an empty assignment (using `EmptyAssignment`)
    `Map<String,String>` | `getExtendedInfo()` Deprecated.
    `Map<String,String>` | `getExtendedInfo(Assignment<V,T> assignment)` Extended information about current solution.
    `Map<String,String>` | `getInfo()` Deprecated.
    `Map<String,String>` | `getInfo(Assignment<V,T> assignment)` Returns information about the current solution.
    `Map<String,String>` | `getInfo(Assignment<V,T> assignment, Collection<V> variables)` Returns information about the current solution.
    `Map<String,String>` | `getInfo(Collection<V> variables)` Deprecated.
    `protected List<InfoProvider<V,T>>` | `getInfoProviders()` Registered info providers (see `InfoProvider`)
    `List<ModelListener<V,T>>` | `getModelListeners()` The list of model listeners
    `protected String` | `getPerc(double value, double min, double max)`
    `protected String` | `getPercRev(double value, double min, double max)`
    `double` | `getTotalValue()` Deprecated.
    `double` | `getTotalValue(Assignment<V,T> assignment)` Value of the current solution.
    `double` | `getTotalValue(Assignment<V,T> assignment, Collection<V> variables)` Value of the current solution.
    `double` | `getTotalValue(Collection<V> variables)` Deprecated.
    `List<GlobalConstraint<V,T>>` | `globalConstraints()` The list of global constraints in the model
    `boolean` | `inConflict(Assignment<V,T> assignment, T value)` Return true if the given value is in conflict with a hard constraint
    `boolean` | `inConflict(T value)` Deprecated.
    `boolean` | `init(Solver<V,T> solver)` Model initialization
    `protected void` | `invalidateVariablesWithInitialValueCache()` Invalidates cache containing all variables that possess an initial value
    `ModelListener<V,T>` | `modelListenerOfType(Class<ModelListener<V,T>> type)` The list of model listeners that are of the given class
    `int` | `nrAssignedVariables()` Deprecated.
    `int` | `nrAssignedVariables(Assignment<V,T> assignment)` Number of assigned variables
    `int` | `nrUnassignedVariables()` Deprecated.
    `int` | `nrUnassignedVariables(Assignment<V,T> assignment)` Number of unassigned variables
    `Collection<V>` | `perturbVariables()` Deprecated.
    `Collection<V>` | `perturbVariables(Assignment<V,T> assignment)` The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.
    `List<V>` | `perturbVariables(Assignment<V,T> assignment, Collection<V> variables)` The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.
    `List<V>` | `perturbVariables(Assignment<V,T> assignment, Collection<V> variables, boolean includeNotAssigned)` The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.
    `List<V>` | `perturbVariables(Collection<V> variables)` Deprecated.
    `void` | `removeConstraint(Constraint<V,T> constraint)` Removes a constraint from the model
    `void` | `removeCriterion(Class<? extends Criterion<V,T>> criterion)` Unregister an existing criterion
    `void` | `removeCriterion(Criterion<V,T> criterion)` Unregister an existing criterion
    `void` | `removeGlobalConstraint(GlobalConstraint<V,T> constraint)` Removes a global constraint from the model
    `void` | `removeModelListener(ModelListener<V,T> listener)` Removes a model listener
    `<C extends AssignmentContext> AssignmentContextReference<V,T,C>` | `removeReference(HasAssignmentContext<V,T,C> parent)` Remove a reference to an assignment context for the model
    `void` | `removeVariable(V variable)` Removes a variable from the model
    `protected void` | `restoreBest()` Deprecated.
    `void` | `restoreBest(Assignment<V,T> assignment)` Restore the best ever found assignment into the current assignment
    `protected void` | `restoreBest(Assignment<V,T> assignment, Comparator<V> assignmentOrder)` Restore the best ever found assignment into the current assignment
    `void` | `saveBest()` Deprecated.
    `void` | `saveBest(Assignment<V,T> assignment)` Save the current assignment as the best ever found assignment
    `void` | `setBestValue(double bestValue)` Set total value of the best ever found solution
    `void` | `setDefaultAssignment(Assignment<V,T> assignment)` Deprecated.
    `String` | `toString()`
    `String` | `toString(Assignment<V,T> assignment)` String representation -- returns a list of values of objective criteria
    `List<Constraint<V,T>>` | `unassignedHardConstraints(Assignment<V,T> assignment)` The list of hard constraints which contain at least one variable that is not assigned.
    `Collection<V>` | `unassignedVariables()` Deprecated.
    `Collection<V>` | `unassignedVariables(Assignment<V,T> assignment)` The list of unassigned variables in the model
    `List<V>` | `variables()` The list of variables in the model
    `Collection<V>` | `variablesWithInitialValue()` The list of variables with an initial value (i.e., variables with `Variable.getInitialAssignment()` not null)
    `void` | `weaken(Assignment<V,T> assignment, T value)` Weaken all weakening constraint so that the given value can be assigned without them creating a conflict using `WeakeningConstraint.weaken(Assignment, Value)`.

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

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

- - ### Field Detail

    - #### sTimeFormat

          protected static DecimalFormat sTimeFormat

    - #### sDoubleFormat

          protected static DecimalFormat sDoubleFormat

    - #### sPercentageFormat

          protected static DecimalFormat sPercentageFormat

  - ### Constructor Detail

    - #### Model

          public Model()

      Constructor

  - ### Method Detail

    - #### variables

          public List<V> variables()

      The list of variables in the model
      Returns:
        list of variables in the model

    - #### countVariables

          public int countVariables()

      The number of variables in the model
      Returns:
        number of variables in the model

    - #### addVariable

          public void addVariable(V variable)

      Adds a variable to the model
      Parameters:
        `variable` - a variable

    - #### removeVariable

          public void removeVariable(V variable)

      Removes a variable from the model
      Parameters:
        `variable` - a variable

    - #### constraints

          public List<Constraint<V,T>> constraints()

      The list of constraints in the model
      Returns:
        list of constraints in the model

    - #### countConstraints

          public int countConstraints()

      The number of constraints in the model
      Returns:
        number of constraints in the model

    - #### addConstraint

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

      Adds a constraint to the model
      Parameters:
        `constraint` - a constraint

    - #### removeConstraint

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

      Removes a constraint from the model
      Parameters:
        `constraint` - a constraint

    - #### globalConstraints

          public List<GlobalConstraint<V,T>> globalConstraints()

      The list of global constraints in the model
      Returns:
        list of global constraints in the model

    - #### countGlobalConstraints

          public int countGlobalConstraints()

      The number of global constraints in the model
      Returns:
        number of global constraints in the model

    - #### addGlobalConstraint

          public void addGlobalConstraint(GlobalConstraint<V,T> constraint)

      Adds a global constraint to the model
      Parameters:
        `constraint` - a global constraint

    - #### removeGlobalConstraint

          public void removeGlobalConstraint(GlobalConstraint<V,T> constraint)

      Removes a global constraint from the model
      Parameters:
        `constraint` - a global constraint

    - #### unassignedVariables

          @Deprecated
          public Collection<V> unassignedVariables()

      Deprecated.
      The list of unassigned variables in the model. Use `unassignedVariables(Assignment)` or `Assignment.unassignedVariables(Model)` instead.
      Returns:
        list of unassigned variables in the model

    - #### unassignedVariables

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

      The list of unassigned variables in the model
      Parameters:
        `assignment` - current assignment
      Returns:
        list of unassigned variables in the model

    - #### nrUnassignedVariables

          @Deprecated
          public int nrUnassignedVariables()

      Deprecated.
      Number of unassigned variables. Use `nrUnassignedVariables(Assignment)` or `Assignment.nrUnassignedVariables(Model)` instead.
      Returns:
        number of unassigned variables in the model

    - #### nrUnassignedVariables

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

      Number of unassigned variables
      Parameters:
        `assignment` - current assignment
      Returns:
        number of unassigned variables in the model

    - #### assignedVariables

          @Deprecated
          public Collection<V> assignedVariables()

      Deprecated.
      The list of assigned variables in the model. Use `assignedVariables(Assignment)` or `Assignment.assignedVariables()` instead.
      Returns:
        list of assigned variables in the model

    - #### assignedVariables

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

      The list of assigned variables in the model
      Parameters:
        `assignment` - current assignment
      Returns:
        list of assigned variables in the model

    - #### nrAssignedVariables

          @Deprecated
          public int nrAssignedVariables()

      Deprecated.
      Number of assigned variables. Use `nrAssignedVariables(Assignment)` or `Assignment.nrAssignedVariables()` instead.
      Returns:
        number of assigned variables in the model

    - #### nrAssignedVariables

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

      Number of assigned variables
      Parameters:
        `assignment` - current assignment
      Returns:
        number of assigned variables in the model

    - #### perturbVariables

          @Deprecated
          public Collection<V> perturbVariables()

      Deprecated.
      The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value. Use `perturbVariables(Assignment)` instead.
      Returns:
        list of perturbation variables in the model

    - #### perturbVariables

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

      The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value.
      Parameters:
        `assignment` - current assignment
      Returns:
        list of perturbation variables in the model

    - #### perturbVariables

          @Deprecated
          public List<V> perturbVariables(Collection<V> variables)

      Deprecated.
      The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value. Only variables from the given set are considered. Use `perturbVariables(Assignment, Collection)` instead.
      Parameters:
        `variables` - sub-problem
      Returns:
        list of perturbation variables in the sub-problem

    - #### perturbVariables

          public List<V> perturbVariables(Assignment<V,T> assignment,
                                          Collection<V> variables)

      The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value. Only variables from the given set are considered.
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
      Returns:
        list of perturbation variables in the sub-problem

    - #### perturbVariables

          public List<V> perturbVariables(Assignment<V,T> assignment,
                                          Collection<V> variables,
                                          boolean includeNotAssigned)

      The list of perturbation variables in the model, i.e., the variables which has an initial value but which are not assigned with this value. Only variables from the given set are considered.
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
        `includeNotAssigned` - when true, include not assigned variables with a hard conflict (that cannot be assigned)
      Returns:
        list of perturbation variables in the sub-problem

    - #### conflictValues

          @Deprecated
          public Set<T> conflictValues(T value)

      Deprecated.
      Returns the set of conflicting variables with this value, if it is assigned to its variable Use `conflictValues(Assignment, Value)` instead.
      Parameters:
        `value` - a value to be assigned
      Returns:
        a set of conflicting values, i.e., values that would have to be unassigned if the given value is assigned to its variable

    - #### conflictValues

          public Set<T> conflictValues(Assignment<V,T> assignment,
                                       T value)

      Returns the set of conflicting variables with this value, if it is assigned to its variable
      Parameters:
        `assignment` - current assignment
        `value` - a value to be assigned
      Returns:
        a set of conflicting values, i.e., values that would have to be unassigned if the given value is assigned to its variable

    - #### inConflict

          @Deprecated
          public boolean inConflict(T value)

      Deprecated.
      Return true if the given value is in conflict with a hard constraint Use `inConflict(Assignment, Value)` instead.
      Parameters:
        `value` - a value in question
      Returns:
        true if there is a conflict, i.e., there is at least one value that would have to be unassigned if the given value is assigned to its variable

    - #### inConflict

          public boolean inConflict(Assignment<V,T> assignment,
                                    T value)

      Return true if the given value is in conflict with a hard constraint
      Parameters:
        `assignment` - current assignment
        `value` - a value in question
      Returns:
        true if there is a conflict, i.e., there is at least one value that would have to be unassigned if the given value is assigned to its variable

    - #### variablesWithInitialValue

          public Collection<V> variablesWithInitialValue()

      The list of variables with an initial value (i.e., variables with `Variable.getInitialAssignment()` not null)
      Returns:
        list of variables with an initial value

    - #### invalidateVariablesWithInitialValueCache

          protected void invalidateVariablesWithInitialValueCache()

      Invalidates cache containing all variables that possess an initial value

    - #### beforeAssigned

          @Deprecated
          public void beforeAssigned(long iteration,
                                                 T value)

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

    - #### beforeAssigned

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

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

    - #### beforeUnassigned

          @Deprecated
          public void beforeUnassigned(long iteration,
                                                   T value)

      Deprecated.
      Called before a value is unassigned from its variable
      Parameters:
        `iteration` - current iteration
        `value` - a value to be unassigned

    - #### beforeUnassigned

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

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

    - #### afterAssigned

          @Deprecated
          public void afterAssigned(long iteration,
                                                T value)

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

    - #### afterAssigned

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

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

    - #### afterUnassigned

          @Deprecated
          public void afterUnassigned(long iteration,
                                                  T value)

      Deprecated.
      Called after a value is unassigned from its variable
      Parameters:
        `iteration` - current iteration
        `value` - a value that was unassigned

    - #### afterUnassigned

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

      Called after a value is unassigned from its variable
      Parameters:
        `assignment` - current assignment
        `iteration` - current iteration
        `value` - a value that was unassigned

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toString

          public String toString(Assignment<V,T> assignment)

      String representation -- returns a list of values of objective criteria
      Parameters:
        `assignment` - current assignment
      Returns:
        comma separated string of `AbstractCriterion.toString(Assignment)`

    - #### getPerc

          protected String getPerc(double value,
                                   double min,
                                   double max)

    - #### getPercRev

          protected String getPercRev(double value,
                                      double min,
                                      double max)

    - #### getInfo

          @Deprecated
          public Map<String,String> getInfo()

      Deprecated.
      Returns information about the current solution. Information from all model listeners and constraints is also included. Use `getInfo(Assignment)` instead.
      Returns:
        info table

    - #### getInfo

          public Map<String,String> getInfo(Assignment<V,T> assignment)

      Returns information about the current solution. Information from all model listeners and constraints is also included.
      Parameters:
        `assignment` - current assignment
      Returns:
        info table

    - #### getExtendedInfo

          @Deprecated
          public Map<String,String> getExtendedInfo()

      Deprecated.
      Extended information about current solution. Similar to `getInfo(Assignment)`, but some more information (that is more expensive to compute) might be added. Use `getExtendedInfo(Assignment)` instead.
      Returns:
        extended info table

    - #### getExtendedInfo

          public Map<String,String> getExtendedInfo(Assignment<V,T> assignment)

      Extended information about current solution. Similar to `getInfo(Assignment)`, but some more information (that is more expensive to compute) might be added.
      Parameters:
        `assignment` - current assignment
      Returns:
        extended info table

    - #### getInfo

          @Deprecated
          public Map<String,String> getInfo(Collection<V> variables)

      Deprecated.
      Returns information about the current solution. Information from all model listeners and constraints is also included. Only variables from the given set are considered. Use `getInfo(Assignment, Collection)` instead.
      Parameters:
        `variables` - sub-problem
      Returns:
        info table

    - #### getInfo

          public Map<String,String> getInfo(Assignment<V,T> assignment,
                                            Collection<V> variables)

      Returns information about the current solution. Information from all model listeners and constraints is also included. Only variables from the given set are considered.
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
      Returns:
        info table

    - #### getBestUnassignedVariables

          public int getBestUnassignedVariables()

      Returns the number of unassigned variables in the best ever found solution
      Returns:
        number of unassigned variables in the best solution

    - #### getBestPerturbations

          public int getBestPerturbations()

      Returns the number of perturbation variables in the best ever found solution
      Returns:
        number of perturbation variables in the best solution

    - #### getBestValue

          public double getBestValue()

      Total value of the best ever found solution -- sum of all assigned values (see `Value.toDouble(Assignment)`).
      Returns:
        value of the best solution

    - #### setBestValue

          public void setBestValue(double bestValue)

      Set total value of the best ever found solution
      Parameters:
        `bestValue` - value of the best solution

    - #### saveBest

          @Deprecated
          public void saveBest()

      Deprecated.
      Save the current assignment as the best ever found assignment Use `saveBest(Assignment)` instead.

    - #### saveBest

          public void saveBest(Assignment<V,T> assignment)

      Save the current assignment as the best ever found assignment
      Parameters:
        `assignment` - current assignment

    - #### clearBest

          public void clearBest()

      Clear the best ever found assignment

    - #### restoreBest

          @Deprecated
          protected void restoreBest()

      Deprecated.
      Restore the best ever found assignment into the current assignment Use `restoreBest(Assignment)` instead.

    - #### restoreBest

          protected void restoreBest(Assignment<V,T> assignment,
                                     Comparator<V> assignmentOrder)

      Restore the best ever found assignment into the current assignment
      Parameters:
        `assignment` - current assignment
        `assignmentOrder` - assignment order of the variables

    - #### restoreBest

          public void restoreBest(Assignment<V,T> assignment)

      Restore the best ever found assignment into the current assignment
      Parameters:
        `assignment` - current assignment

    - #### bestUnassignedVariables

          @Deprecated
          public Collection<V> bestUnassignedVariables()

      Deprecated.
      The list of unassigned variables in the best ever found solution. Use `bestUnassignedVariables(Assignment)` instead.
      Returns:
        variables list of unassigned variables in the best solution

    - #### bestUnassignedVariables

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

      The list of unassigned variables in the best ever found solution
      Parameters:
        `assignment` - current assignment
      Returns:
        variables list of unassigned variables in the best solution

    - #### getTotalValue

          @Deprecated
          public double getTotalValue()

      Deprecated.
      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`. Use `getTotalValue(Assignment)` instead.
      Returns:
        solution value

    - #### getTotalValue

          public double getTotalValue(Assignment<V,T> assignment)

      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`.
      Parameters:
        `assignment` - current assignment
      Returns:
        solution value

    - #### getTotalValue

          @Deprecated
          public double getTotalValue(Collection<V> variables)

      Deprecated.
      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`. Only variables from the given set are considered. Use `getTotalValue(Assignment, Collection)` instead.
      Parameters:
        `variables` - sub-problem
      Returns:
        solution value

    - #### getTotalValue

          public double getTotalValue(Assignment<V,T> assignment,
                                      Collection<V> variables)

      Value of the current solution. It is the sum of all assigned values, i.e., `Value.toDouble(Assignment)`. Only variables from the given set are considered.
      Parameters:
        `assignment` - current assignment
        `variables` - sub-problem
      Returns:
        solution value

    - #### addModelListener

          public void addModelListener(ModelListener<V,T> listener)

      Adds a model listener
      Parameters:
        `listener` - a model listener

    - #### removeModelListener

          public void removeModelListener(ModelListener<V,T> listener)

      Removes a model listener
      Parameters:
        `listener` - a model listener

    - #### init

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

      Model initialization
      Parameters:
        `solver` - current solver
      Returns:
        true if successfully initialized

    - #### getModelListeners

          public List<ModelListener<V,T>> getModelListeners()

      The list of model listeners
      Returns:
        list of model listeners

    - #### modelListenerOfType

          public ModelListener<V,T> modelListenerOfType(Class<ModelListener<V,T>> type)

      The list of model listeners that are of the given class
      Parameters:
        `type` - model listener type
      Returns:
        list of model listeners that are of the given class

    - #### conflictConstraints

          public Map<Constraint<V,T>,Set<T>> conflictConstraints(Assignment<V,T> assignment,
                                                                 T value)

      The list of constraints which are in a conflict with the given value if it is assigned to its variable. This means the constraints, which adds a value into the set of conflicting values in `Constraint.computeConflicts(Assignment, Value, Set)`.
      Parameters:
        `assignment` - current assignment
        `value` - given value
      Returns:
        hard constraints and their conflicts that are conflicting with the given value

    - #### unassignedHardConstraints

          public List<Constraint<V,T>> unassignedHardConstraints(Assignment<V,T> assignment)

      The list of hard constraints which contain at least one variable that is not assigned.
      Parameters:
        `assignment` - current assignment
      Returns:
        list of hard constraints which contain at least one variable that is not assigned

    - #### getInfoProviders

          protected List<InfoProvider<V,T>> getInfoProviders()

      Registered info providers (see `InfoProvider`)
      Returns:
        list of registered info providers

    - #### addCriterion

          public void addCriterion(Criterion<V,T> criterion)

      Register a new criterion
      Parameters:
        `criterion` - a criterion

    - #### removeCriterion

          public void removeCriterion(Criterion<V,T> criterion)

      Unregister an existing criterion
      Parameters:
        `criterion` - a criterion

    - #### removeCriterion

          public void removeCriterion(Class<? extends Criterion<V,T>> criterion)

      Unregister an existing criterion
      Parameters:
        `criterion` - a criterion

    - #### getCriterion

          public Criterion<V,T> getCriterion(Class<? extends Criterion<V,T>> criterion)

      Return a registered criterion of the given type.
      Parameters:
        `criterion` - criterion type
      Returns:
        registered criterion of the given type

    - #### getCriteria

          public Collection<Criterion<V,T>> getCriteria()

      List all registered criteria
      Returns:
        list all registered criteria

    - #### weaken

          public void weaken(Assignment<V,T> assignment,
                             T value)

      Weaken all weakening constraint so that the given value can be assigned without them creating a conflict using `WeakeningConstraint.weaken(Assignment, Value)`. This method is handy for instance when an existing solution is being loaded into the solver.
      Parameters:
        `assignment` - current assignment
        `value` - given value

    - #### createReference

          public <C extends AssignmentContext> AssignmentContextReference<V,T,C> createReference(HasAssignmentContext<V,T,C> parent)

      Create a reference to an assignment context for a class that is in a need of one. Through this reference an assignment context (see `AssignmentContext`) can be accessed using `Assignment.getAssignmentContext(AssignmentContextReference)`.
      Type Parameters:
        `C` - assignment context type
      Parameters:
        `parent` - class needing an assignment context
      Returns:
        reference to an assignment context

    - #### clearAssignmentContexts

          public void clearAssignmentContexts(Assignment<V,T> assignment)

      Clear all assignment contexts for the given assignment
      Parameters:
        `assignment` - given `Assignment`

    - #### removeReference

          public <C extends AssignmentContext> AssignmentContextReference<V,T,C> removeReference(HasAssignmentContext<V,T,C> parent)

      Remove a reference to an assignment context for the model
      Type Parameters:
        `C` - assignment context type
      Parameters:
        `parent` - class with an assignment context
      Returns:
        reference to an assignment context that was removed from the model (if any)

    - #### createAssignmentContexts

          public void createAssignmentContexts(Assignment<V,T> assignment,
                                               boolean clear)

      Create all assignment contexts for the given assignment
      Parameters:
        `assignment` - given `Assignment`
        `clear` - if true `Assignment.clearContext(AssignmentContextReference)` is called first

    - #### getDefaultAssignment

          @Deprecated
          public Assignment<V,T> getDefaultAssignment()

      Deprecated.
      Return default assignment that is using the old `Variable.getAssignment()` assignments.
      Returns:
        as instance of `DefaultSingleAssignment`

    - #### setDefaultAssignment

          @Deprecated
          public void setDefaultAssignment(Assignment<V,T> assignment)

      Deprecated.
      Set default assignment
      Parameters:
        `assignment` - current assignment to become default

    - #### getEmptyAssignment

          public Assignment<V,T> getEmptyAssignment()

      Returns an instance of an empty assignment (using `EmptyAssignment`)
      Returns:
        an empty assignment

    - #### createInheritedAssignment

          public InheritedAssignment<V,T> createInheritedAssignment(Solution<V,T> solution,
                                                                    int index)

      Create a new inherited assignment from the given solution
      Parameters:
        `solution` - a solution that is using this model
        `index` - thread index of the new assignment
      Returns:
        a new inherited assignment