jopt.csp.search
Class SimpleNeighborhood

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

public class SimpleNeighborhood
extends java.lang.Object
implements Neighborhood

A simple collection of neighboring solutions that are predefined and capable of being browsed during a search. Like a friendly suburb where Mr. Rodgers might live.

Version:
$Revision: 1.5 $
Author:
Nick Coleman

Constructor Summary
SimpleNeighborhood()
          Creates a simple neighborhood based on an initial solution
 
Method Summary
 void add(SolverSolution neighbor)
          Adds a new neighbor to the neighborhood.
 SolverSolution getNeighbor(int i)
          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

SimpleNeighborhood

public SimpleNeighborhood()
Creates a simple neighborhood based on an initial solution

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 i)
Description copied from interface: Neighborhood
Returns the neighboring solution at index i

Specified by:
getNeighbor in interface Neighborhood
Parameters:
i - 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).

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

getSelectedNeighborhood

public Neighborhood getSelectedNeighborhood()
Returns the Neighborhood represented by the latest selected Neighborhood

Specified by:
getSelectedNeighborhood in interface Neighborhood
Returns:
Neighborhood represented by the latest selected Neighborhood

getSelectedNeighborhoodOffset

public int getSelectedNeighborhoodOffset()
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

add

public void add(SolverSolution neighbor)
Adds a new neighbor to the neighborhood. Hi Neighbor!