extended
Interface SimulatedAnnealingProblem<T>
- Type Parameters:
T
- the specific type of all elements in the search domain
- All Superinterfaces:
- Problem<T>
public interface SimulatedAnnealingProblem<T>
- extends Problem<T>
This is the base of all problems which can be solved with the simulated annealing search.
Additional to the simple Problem a SimulatedAnnealingProblem consists of a method
which computes the difference between two states.
As described in the method documentation this operation
assumes a total ordering over the elements in the search domain,
so it is possible to find a smallest or a biggest element according to the difference.
This is exactly what the simulated annealing is trying to do.
If you implement this interface, your problem can be solved by the following search algorithms:
- extended.SimulatedAnnealing
In the following there are some important hints how to augment your simulated annealing problem:
-
It is in general a good idea to create the initial state at random.
Simply if you want to port your problem to the hill climbing algorithm
-
Make sure the SimulatedAnnealingProblem#difference() method is damn fast,
otherwise the simulated annealing will get stuck in computing the difference between two states.
-
Because this search selects one successor of a state at random,
the list of successors must not be large (But at least half of the
maxSame
property).
It is more important to provide significant improvements to the current state,
instead of a complete set of all successors.
For example if all successors of each state are 1.0 better or 1.0 worse then the current state,
the search is granted to take years and yet does not find a good example.
-
Do not assume that the core.Problem#expand(java.lang.Object) method is
called for the current state several times.
In fact the list of successors is maintained until the current state gets changed.
-
Whenever you have to deal with a large number of successor states for a given state,
think about using a proxy class which generates the successor state only if necessary.
Note: The simulated annealing will not use the core.Problem#isGoal(java.lang.Object) method,
to determine if a solution has been found.
In fact the annealing process stops when there has been no improvements to the result for some time.
The so found result may not be the optimal solution, but is granted to be a good approximation.
For compatibility with other search algorithms you should implement the isGoal method in a proper way.
- Author:
- eden06
- See Also:
SimulatedAnnealing
Method Summary |
double |
difference(T x,
T y)
Computes the difference between two states in the search domain. |
difference
double difference(T x,
T y)
- Computes the difference between two states in the search domain.
Returns a double value which indicates the difference between these states.
For example assume an evaluation function
f
which assigns a double value to each state s
.
Then the difference of two states can be computed with the difference of the function values:
function double f(T state){ ... }
function double difference(T x, T y){
return f(x) - f(y)
}
In detail the difference must obey the following rules for all states x and y:
difference(x,y) == -(difference(y,x)
( difference(x,y)>0 and difference(y,z)>0 ) implies difference(x,z) > 0
(The relation must be transitive.)
( difference(x,y)>0 and difference(y,z)>0 ) implies difference(x,z) > 0
(The relation must be transitive.)
difference(x,y) == 0 implies that difference(x,z) == difference(y,z) for all states z
- Parameters:
x
- the operand from which the difference is computedy
- the operand to which the difference is computed
- Returns:
- a negative double, zero, or a positive double which indicates the difference of state x to state y.