extended
Class FirstChoiceStrategy<T>

java.lang.Object
  extended by extended.FirstChoiceStrategy<T>
Type Parameters:
T - the specific type of all elements in the search domain.
All Implemented Interfaces:
HillClimbingStrategy<T>

public class FirstChoiceStrategy<T>
extends java.lang.Object
implements HillClimbingStrategy<T>

A hill climbing strategy which selects the first successor which is better then the current state. It is one of the standard HillClimbingStrategy implementations usable in the hill climbing search.

It obeys all constraints from the interface definition, and is able to return equal states whenever no better state can be found.
This strategy is faster then the other because it does not look at all the successors. On the other hand the hill climbing itself will need more steps to find an optimum.

Author:
eden06
See Also:
HillClimbing, HillClimbingStrategy, BestChoiceStrategy

Constructor Summary
FirstChoiceStrategy()
          Creates a new FirstChoiceStrategy which can be employed in the hill climbing search.
 
Method Summary
 T select(HillClimbing<T> hc, java.util.List<T> list, T current)
          This method selects the first state in the extension list which is better then the current state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FirstChoiceStrategy

public FirstChoiceStrategy()
Creates a new FirstChoiceStrategy which can be employed in the hill climbing search.

Method Detail

select

public T select(HillClimbing<T> hc,
                java.util.List<T> list,
                T current)
This method selects the first state in the extension list which is better then the current state.
It starts at a random position and looks for a state which is better then the current state (hillclimbing.compare(current,state) > 0). If there is a state which is equal (in fact hillclimbing.compare(current,state) = 0) to the current state it is remembered, for the case that no better state can be found.

Specified by:
select in interface HillClimbingStrategy<T>
Parameters:
hc - the hill climbing search itself (which must be used as a comparator)
list - the list of successors of the current state
current - the current state of the hill climbing search
Returns:
the selected best state if any exists or a random successor.
See Also:
HillClimbingStrategy.select(extended.HillClimbing, java.util.List, java.lang.Object)