net.sf.cpsolver.ifs.solution
Class Solution<V extends Variable<V,T>,T extends Value<V,T>>

java.lang.Object
  extended by net.sf.cpsolver.ifs.solution.Solution<V,T>

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

Generic solution.

It consist from the model and information about current iteration and solution time.

Version:
IFS 1.2 (Iterative Forward Search)
Copyright (C) 2006 - 2010 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/.
See Also:
Model, Solver

Constructor Summary
Solution(Model<V,T> model)
          Constructor
Solution(Model<V,T> model, long iteration, double time)
          Constructor
 
Method Summary
 void addSolutionListener(SolutionListener<V,T> listener)
          Adds solution listner
 void clearBest()
          Clear the best ever found solution
 Map<String,String> getBestInfo()
          Info of the best ever found solution
 long getBestIteration()
          Iteration when the best ever found solution was found
 double getBestPerturbationsPenalty()
          Perturbation penalty of the best ever found solution (see PerturbationsCounter)
 double getBestTime()
          Solution time when the best ever found solution was found
 double getBestValue()
          Total value of the best ever found solution -- sum of all assigned values (see Value.toDouble()).
 Map<String,String> getExtendedInfo()
          Extended solution information.
 Map<String,String> getInfo()
          Solution information.
 Map<String,String> getInfo(Collection<V> variables)
          Solution information.
 long getIteration()
          Current iteration
 Model<V,T> getModel()
          The model associated with the solution
 PerturbationsCounter<V,T> getPerturbationsCounter()
          Returns perturbation counter
 double getTime()
          Current solution time (time in seconds from the start of the solver)
 void init(Solver<V,T> solver)
          Initialization
 boolean isBestComplete()
          Returns true, if all variables of the best ever solution found are assigned
 void removeSolutionListener(SolutionListener<V,T> listener)
          Removes solution listener
 void restoreBest()
          Restore the best ever found solution into the current solution (it also calls Model.restoreBest())
 void saveBest()
          Save the current solution as the best ever found solution (it also calls Model.saveBest())
 void setBestValue(double bestValue)
          Set total value of the best ever found solution
 String toString()
           
 void update(double time)
          Update time, increment current iteration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Solution

public Solution(Model<V,T> model)
Constructor


Solution

public Solution(Model<V,T> model,
                long iteration,
                double time)
Constructor

Method Detail

getIteration

public long getIteration()
Current iteration


getModel

public Model<V,T> getModel()
The model associated with the solution


getTime

public double getTime()
Current solution time (time in seconds from the start of the solver)


update

public void update(double time)
Update time, increment current iteration


init

public void init(Solver<V,T> solver)
Initialization


toString

public String toString()
Overrides:
toString in class Object

getInfo

public Map<String,String> getInfo()
Solution information. It consits from info from the model which is associated with the solution, time, iteration, speed and infos from all solution listeners.


getExtendedInfo

public Map<String,String> getExtendedInfo()
Extended solution information. Similar to getInfo(), but some more information (that is more expensive to compute) might be added. Also extended model information is added (see Model.getExtendedInfo()) into the resultant table.


getInfo

public Map<String,String> getInfo(Collection<V> variables)
Solution information. It consists from info from the model which is associated with the solution, time, iteration, speed and infos from all solution listeners. Only variables from the given set are included.


getBestInfo

public Map<String,String> getBestInfo()
Info of the best ever found solution


getBestIteration

public long getBestIteration()
Iteration when the best ever found solution was found


getBestTime

public double getBestTime()
Solution time when the best ever found solution was found


isBestComplete

public boolean isBestComplete()
Returns true, if all variables of the best ever solution found are assigned


getBestValue

public double getBestValue()
Total value of the best ever found solution -- sum of all assigned values (see Value.toDouble()).


setBestValue

public void setBestValue(double bestValue)
Set total value of the best ever found solution


getBestPerturbationsPenalty

public double getBestPerturbationsPenalty()
Perturbation penalty of the best ever found solution (see PerturbationsCounter)


getPerturbationsCounter

public PerturbationsCounter<V,T> getPerturbationsCounter()
Returns perturbation counter


clearBest

public void clearBest()
Clear the best ever found solution


saveBest

public void saveBest()
Save the current solution as the best ever found solution (it also calls Model.saveBest())


restoreBest

public void restoreBest()
Restore the best ever found solution into the current solution (it also calls Model.restoreBest())


addSolutionListener

public void addSolutionListener(SolutionListener<V,T> listener)
Adds solution listner


removeSolutionListener

public void removeSolutionListener(SolutionListener<V,T> listener)
Removes solution listener