extended
Interface HillClimbingStrategy<T>
- Type Parameters:
T
- the specific type of all elements in the search domain.
- All Known Implementing Classes:
- BestChoiceStrategy, FirstChoiceStrategy
public interface HillClimbingStrategy<T>
This is the base of all strategies for the hill climbing search.
If you want to make your hill climbing more efficient you can
implement your own strategy by implementing this interface.
The only thing you must implement is the select method,
which chooses the best state from a list of successor states according
to the comparator.
The state returned must obey the following rules:
-
In general it must be better then the current state
according to the HillClimbing#compare method.
Formally: There exists result
in extension
with hillclimbing.compare(current,result) > 0
-
It must be equal to the current state according to the the HillClimbing#compare method
only if there is no state better then the current state in the list of the successors.
Formaly: If there is no x
in extension
with hillclimbing.compare(current,x) > 0
then there is a result
in extension
with hillclimbing.compare(current,result) >= 0
-
It should only be worse then the current state
if there is absolutely no better or equal state in the list of successors.
Formally: If there is no x
in extension
with hillclimbing.compare(current,result) >= 0
then select a random result
in extension
-
It should never be null or the current state itself.
-
The way a state will be selected must always be nondeterministic.
For example by starting at a random position of the list looking for a better state.
Every implementation of this interface should rely solely on the comparison method
shipped with the HillClimbing class, to allow proper minimum and maximum searches
with this strategy.
Note: For further information on how to create a HillClimbing search
which uses a custom HillClimbingStrategy see the description of the HillClimbing class.
.
- Author:
- eden06
Method Summary |
T |
select(HillClimbing<T> hillclimbing,
java.util.List<T> extension,
T current)
This method selects the best state from the given list of successors
according to the current state and a comparator. |
select
T select(HillClimbing<T> hillclimbing,
java.util.List<T> extension,
T current)
- This method selects the best state from the given list of successors
according to the current state and a comparator.
This method will only be called with non null and non empty arguments and
should obey the following constraints:
-
In general state returned must be better then the current state
according to the HillClimbing#compare method.
hillclimbing.compare(current,result) > 0
-
If no better state can be found then an equal state according to
the HillClimbing#compare method should be returned.
hillclimbing.compare(current,result) >= 0
-
Only in the case when there is no better or equal state then a random
state should be returned.
-
The way a state will be selected must always be nondeterministic.
For example by starting at a random position of the list looking for a better state.
-
This method should never return null or the current state itself.
Hint: This method is the template for all hill climbing strategies.
- Parameters:
hillclimbing
- the hill climbing search itself (which must be used as a comparator)extension
- the list of successors of the current statecurrent
- the current state of the hill climbing search
- Returns:
- the selected best state if any exists or a random successor.