- Type Parameters:
T- The type of Partial object for which this ConstructiveHeuristic guides construction, which is assumed to be an object that is a sequence of integers (e.g., vector of integers, permutation, or some other indexable type that stores integers).
- All Known Implementing Classes:
public interface ConstructiveHeuristic<T extends Copyable<T>>
Classes implementing this interface are used as constructive heuristics for constructing heuristic solutions to optimization problems, as well as for certain stochastic sampling search algorithms.
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description
completeLength()Gets the required length of complete solutions to the problem instance for which this constructive heuristic is configured.
createIncrementalEvaluation()Creates an IncrementalEvaluation object corresponding to an initially empty Partial for use in incrementally constructing a solution to the problem for which this heuristic is designed.
createPartial(int n)Creates an empty Partial solution, which will be incrementally transformed into a complete solution of a specified length.
getProblem()Gets a reference to the instance of the optimization problem that is the subject of this heuristic.
h(Partial<T> p, int element, IncrementalEvaluation<T> incEval)Heuristically evaluates the possible addition of an element to the end of a Partial.
double h(Partial<T> p, int element, IncrementalEvaluation<T> incEval)Heuristically evaluates the possible addition of an element to the end of a Partial. Higher evaluations imply that the element is a better choice for the next element to add. For example, if you evaluate two elements, x and y, with h, and h returns a higher value for y than for x, then this means that y is believed to be the better choice according to the heuristic. Implementations of this interface must ensure that h always returns a positive result. This is because stochastic sampling algorithms such as HBSS and VBSS assume that the constructive heuristic returns only positive values.
p- The current state of the Partial
element- The element under consideration for adding to the Partial
incEval- An IncrementalEvaluation of p. This method assumes that incEval is of the same runtime type as the object returned by
- The heuristic evaluation of the hypothetical addition of element to the end of p. The higher the evaluation, the more important the heuristic believes that element should be added next. The intention is to compare the value returned with the heuristic evaluations of other elements. Individual results in isolation are not necessarily meaningful.
ClassCastException- if incEval is not of the same runtime type as the objects returned by the
createIncrementalEvaluation()method of the class implementing this interface
default IncrementalEvaluation<T> createIncrementalEvaluation()
Creates an IncrementalEvaluation object corresponding to an initially empty Partial for use in incrementally constructing a solution to the problem for which this heuristic is designed. The object returned incrementally computes any data associated with a Partial as needed by the
h(org.cicirello.search.ss.Partial<T>, int, org.cicirello.search.ss.IncrementalEvaluation<T>)method. The
h(org.cicirello.search.ss.Partial<T>, int, org.cicirello.search.ss.IncrementalEvaluation<T>)method will assume that it will be given an object of the specific runtime type returned by this method. It is unsafe to pass IncrementalEvaluation objects created by one heuristic to the
h(org.cicirello.search.ss.Partial<T>, int, org.cicirello.search.ss.IncrementalEvaluation<T>)method of another.
The default implementation simply returns null, which is appropriate for heuristics that won't benefit from incrementally computing heuristic information.
- An IncrementalEvaluation for an empty Partial
to be used for incrementally computing any data required by the
h(org.cicirello.search.ss.Partial<T>, int, org.cicirello.search.ss.IncrementalEvaluation<T>)method.
n- the desired length of the final complete solution.
- an empty Partial solution
- length of solutions to the problem instance for which this heuristic is configured