jopt.csp.search
Class RandomizedNeighborhood

java.lang.Object
  extended byjopt.csp.search.RandomizedNeighborhood
All Implemented Interfaces:
Neighborhood

public class RandomizedNeighborhood
extends java.lang.Object
implements Neighborhood

A simple wrapper to other neighborhoods that randomizes the order in which neighbors are obtained.

Author:
James Boerkoel

Constructor Summary
RandomizedNeighborhood(Neighborhood hood)
          Creates a random neighborhood based on another neighborhood
RandomizedNeighborhood(Neighborhood[] hoods)
          Creates a random, unified neighborhood based on a collection of other neighborhoods
 
Method Summary
 SolverSolution getNeighbor(int index)
          Returns the neighboring solution at index i
 Neighborhood getSelectedNeighborhood()
          Returns the Neighborhood represented by the latest selected Neighborhood
 int getSelectedNeighborhoodOffset()
          Returns the offset into Neighborhood represented by the latest selected Neighborhood
 void neighborSelected(int i)
          Indicates that a neighbor has been selected from this neighborhood and is about to be used to update the initial solution.
 void setInitialSolution(SolverSolution initial)
          Sets the initial solution to which this neighborhood is related
 int size()
          Returns the number of potential solutions contained in the neighborhood
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomizedNeighborhood

public RandomizedNeighborhood(Neighborhood hood)
Creates a random neighborhood based on another neighborhood


RandomizedNeighborhood

public RandomizedNeighborhood(Neighborhood[] hoods)
Creates a random, unified neighborhood based on a collection of other neighborhoods

Method Detail

setInitialSolution

public void setInitialSolution(SolverSolution initial)
Description copied from interface: Neighborhood
Sets the initial solution to which this neighborhood is related

Specified by:
setInitialSolution in interface Neighborhood

size

public int size()
Description copied from interface: Neighborhood
Returns the number of potential solutions contained in the neighborhood

Specified by:
size in interface Neighborhood

getNeighbor

public SolverSolution getNeighbor(int index)
Description copied from interface: Neighborhood
Returns the neighboring solution at index i

Specified by:
getNeighbor in interface Neighborhood
Parameters:
index - Index of neighbor within neighborhood
Returns:
Solution given by the neighbor or null if some pre-propagation checks show that the neighbor is invalid (and will fail constraint satisfaction).

getSelectedNeighborhood

public Neighborhood getSelectedNeighborhood()
Description copied from interface: Neighborhood
Returns the Neighborhood represented by the latest selected Neighborhood

Specified by:
getSelectedNeighborhood in interface Neighborhood
Returns:
Neighborhood represented by the latest selected Neighborhood null if no such neighbor has been selected

getSelectedNeighborhoodOffset

public int getSelectedNeighborhoodOffset()
Description copied from interface: Neighborhood
Returns the offset into Neighborhood represented by the latest selected Neighborhood

Specified by:
getSelectedNeighborhoodOffset in interface Neighborhood
Returns:
the offset into Neighborhood represented by the latest selected Neighborhood -1 if no such neighbor has been selected

neighborSelected

public void neighborSelected(int i)
Description copied from interface: Neighborhood
Indicates that a neighbor has been selected from this neighborhood and is about to be used to update the initial solution. This is useful if the neighborhood will adjust the order in which neighbors are produced.

Specified by:
neighborSelected in interface Neighborhood