Opus5
Class AbstractSolver

java.lang.Object
  |
  +--Opus5.AbstractSolver
All Implemented Interfaces:
Solver
Direct Known Subclasses:
BreadthFirstBranchAndBoundSolver, BreadthFirstSolver, DepthFirstBranchAndBoundSolver, DepthFirstSolver

public abstract class AbstractSolver
extends java.lang.Object
implements Solver

The AbstractSolver class is the base class from which all concrete solver classes are derived. This abstract class provides default implementations for various methods declared in the Solver interface.

Version:
$Id: AbstractSolver.java,v 3.2 1998/07/28 13:07:40 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
Solver

Field Summary
protected  int bestObjective
          The value of the objective function for the current "best" solution.
protected  Solution bestSolution
          The current "best" solution.
 
Fields inherited from interface Opus5.Solver
copyright
 
Constructor Summary
AbstractSolver()
           
 
Method Summary
protected abstract  void search(Solution initial)
          Searches the solution space for the optimal solution.
 Solution solve(Solution initial)
          Returns an optimal solution to a given problem by searching its solution space.
 void updateBest(Solution solution)
          Records the specified solution as the "best" solution if it is a feasible solution and if the value of its objective function is less than the current "best" solution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bestSolution

protected Solution bestSolution
The current "best" solution. I.e., of all the solutions encountered so far, the one with the smallest objective function value.

bestObjective

protected int bestObjective
The value of the objective function for the current "best" solution.
Constructor Detail

AbstractSolver

public AbstractSolver()
Method Detail

search

protected abstract void search(Solution initial)
Searches the solution space for the optimal solution. The optimal solution is a complete solution that is feasible and for which the objective function is minimized.
Parameters:
initial - The initial node in the solution space from which to begin the search.

solve

public Solution solve(Solution initial)
Returns an optimal solution to a given problem by searching its solution space. Calls the abstract search method to do the actual search.
Specified by:
solve in interface Solver
Parameters:
initial - The initial node in the solution space from which to begin the search.
Returns:
The optimal solution.
See Also:
search(Opus5.Solution)

updateBest

public void updateBest(Solution solution)
Records the specified solution as the "best" solution if it is a feasible solution and if the value of its objective function is less than the current "best" solution. This method is called by the search method for every complete solution it generates.
Parameters:
solution - The specified complete solution.
See Also:
search(Opus5.Solution)