org.cpsolver.ifs.util

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

- java.lang.Object
- - org.cpsolver.ifs.util.ProblemSaver<V,T,M>

- All Implemented Interfaces:
    Runnable
  Direct Known Subclasses:
    StudentSectioningSaver, TimetableSaver

      public abstract class ProblemSaver<V extends Variable<V,T>,T extends Value<V,T>,M extends Model<V,T>>
      extends Object
      implements Runnable

  Abstract problem saver class.
  Version:
    IFS 1.3 (Iterative Forward Search)
    Copyright (C) 2006 - 2016 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/.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProblemSaver(Solver<V,T> solver)` Constructor

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Assignment<V,T>` | `getAssignment()` Current assignment
    `M` | `getModel()` Model of the solution
    `protected Solution<V,T>` | `getSolution()` Solution to be saved
    `Solver<V,T>` | `getSolver()` Solver
    `TerminationCondition<V,T>` | `getTerminationCondition()` Return termination condition so that the save process can be stopped if needed.
    `void` | `run()`
    `abstract void` | `save()` Save the solution
    `void` | `setCallback(Callback callback)` Sets callback class
    `void` | `setTerminationCondition(TerminationCondition<V,T> termination)` Provide termination condition so that the save process can be stopped if needed (optional).

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

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

- - ### Constructor Detail

    - #### ProblemSaver

          public ProblemSaver(Solver<V,T> solver)

      Constructor
      Parameters:
        `solver` - current solver

  - ### Method Detail

    - #### getSolver

          public Solver<V,T> getSolver()

      Solver
      Returns:
        current solver

    - #### getSolution

          protected Solution<V,T> getSolution()

      Solution to be saved
      Returns:
        current solution

    - #### getModel

          public M getModel()

      Model of the solution
      Returns:
        problem model

    - #### getAssignment

          public Assignment<V,T> getAssignment()

      Current assignment
      Returns:
        current assignment

    - #### save

          public abstract void save()
                             throws Exception

      Save the solution
      Throws:
        `Exception` - thrown when save fails

    - #### setCallback

          public void setCallback(Callback callback)

      Sets callback class
      Parameters:
        `callback` - method `Callback.execute()` is executed when save is done

    - #### setTerminationCondition

          public void setTerminationCondition(TerminationCondition<V,T> termination)

      Provide termination condition so that the save process can be stopped if needed (optional).

    - #### getTerminationCondition

          public TerminationCondition<V,T> getTerminationCondition()

      Return termination condition so that the save process can be stopped if needed.

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`