SolutionType
- solution type for which this neighbourhood can be applied, required to extend Solution
public class CompositeNeighbourhood<SolutionType extends org.jamesframework.core.problems.Solution> extends Object implements org.jamesframework.core.search.neigh.Neighbourhood<SolutionType>
Constructor and Description |
---|
CompositeNeighbourhood(List<? extends org.jamesframework.core.search.neigh.Neighbourhood<? super SolutionType>> neighbourhoods,
List<Double> neighbourhoodWeights)
Creates a composite neighbourhood consisting of the list of given neighbourhoods and specified weights.
|
Modifier and Type | Method and Description |
---|---|
List<org.jamesframework.core.search.neigh.Move<? super SolutionType>> |
getAllMoves(SolutionType solution)
Creates and returns the union of all moves generated by each of the contained neighbourhoods.
|
org.jamesframework.core.search.neigh.Move<? super SolutionType> |
getRandomMove(SolutionType solution)
Produces a random move generated by one of the contained neighbourhoods based on the assigned weights.
|
public CompositeNeighbourhood(List<? extends org.jamesframework.core.search.neigh.Neighbourhood<? super SolutionType>> neighbourhoods, List<Double> neighbourhoodWeights)
null
, should be of the same size and can
not contain any null
elements. At least one neighbourhood should be given and all weights
should be strictly positive.neighbourhoods
- list of neighbourhoodsneighbourhoodWeights
- list of weights assigned to the neighbourhoods (same order as neighbourhoods)NullPointerException
- if neighbourhoods
or neighbourhoodWeights
are
null
or contain any null
elementsIllegalArgumentException
- if neighbourhoods
and neighbourhoodWeights
are
not of the same size or both empty, or if neighbourhoodWeights
contains any weight ≤ 0public org.jamesframework.core.search.neigh.Move<? super SolutionType> getRandomMove(SolutionType solution)
null
.
Else, it selects a move through roulette selection based on the weights assigned at construction.getRandomMove
in interface org.jamesframework.core.search.neigh.Neighbourhood<SolutionType extends org.jamesframework.core.problems.Solution>
solution
- solution for which a move is generatednull
if none of the
contained neighbourhoods are able to produce a random movepublic List<org.jamesframework.core.search.neigh.Move<? super SolutionType>> getAllMoves(SolutionType solution)
getAllMoves
in interface org.jamesframework.core.search.neigh.Neighbourhood<SolutionType extends org.jamesframework.core.problems.Solution>
solution
- solution for which all moves are generatedCopyright © 2015. All rights reserved.