V - VariableT - Valuepublic abstract class NeighbourSearch<V extends Variable<V,T>,T extends Value<V,T>> extends NeighbourSelectionWithContext<V,T,NeighbourSearch.NeighbourSearchContext> implements LazyNeighbour.LazyNeighbourAcceptanceCriterion<V,T>, SolutionListener<V,T>
SolutionListener and the variable neighbourhood selection.
| Modifier and Type | Class and Description |
|---|---|
class |
NeighbourSearch.NeighbourSearchContext
Search context
|
| Modifier and Type | Field and Description |
|---|---|
protected DecimalFormat |
iDF2 |
protected String |
iPhase |
iContextOverridesMaxSize| Constructor and Description |
|---|
NeighbourSearch(DataProperties properties) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Assignment<V,T> assignment,
LazyNeighbour<V,T> neighbour,
double value)
Accept lazy neighbour -- calling the acceptance criterion with lazy = true.
|
protected boolean |
accept(NeighbourSearch.NeighbourSearchContext context,
Solution<V,T> solution,
Neighbour<V,T> neighbour)
True if the generated move is to be accepted.
|
protected void |
addNeighbourSelection(NeighbourSelection<V,T> ns,
double bonus)
Add neighbour selection
|
void |
bestCleared(Solution<V,T> solution)
Called by the solution when method
Solution.clearBest() is
called. |
void |
bestRestored(Solution<V,T> solution)
Called by the solution when method
Solution.restoreBest() is
called. |
void |
bestSaved(Solution<V,T> solution)
Called by the solution when method
Solution.saveBest() is called. |
Neighbour<V,T> |
generateMove(Solution<V,T> solution)
Generate a random move
|
void |
getInfo(Solution<V,T> solution,
Map<String,String> info)
Called by the solution when it is asked to produce info table, see
Solution.getInfo(). |
void |
getInfo(Solution<V,T> solution,
Map<String,String> info,
Collection<V> variables)
Called by the solution when it is asked to produce info table, see
Solution.getInfo(). |
protected List<? extends NeighbourSelection<V,T>> |
getNeighbours()
Return list of neighbour selections
|
abstract String |
getParameterBaseName()
Parameter base name.
|
protected void |
info(String message)
Prints a message into the log
|
void |
init(Solver<V,T> solver)
Criterion initialization
|
boolean |
isMaster(Solution<V,T> solution)
In single solution multiple threads environments return true if the given solution is of the first thread
|
protected void |
logNeibourStatus()
Log some information about neigbour selections once in a while
|
protected NeighbourSelection<V,T> |
nextNeighbourSelection()
Generate and return next neighbour selection
|
Neighbour<V,T> |
selectNeighbour(Solution<V,T> solution)
select a neighbour of a given solution
|
protected void |
setHCMode(boolean hcMode)
Set HC mode for all the neighbour selections that support the
HillClimberSelection interface. |
protected void |
setProgress(long progress)
Set search progress
|
protected void |
setProgressPhase(String phase)
Set search progress phase
|
void |
solutionUpdated(Solution<V,T> solution)
Called by the solution when it is updated, see
Solution.update(double). |
getAssignmentContextReference, getContext, getContext, hasContextOverride, isSingleContextSolver, setAssignmentContextReferenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateAssignmentContextprotected DecimalFormat iDF2
public NeighbourSearch(DataProperties properties)
protected void info(String message)
message - a message to logprotected void setProgress(long progress)
progress - between 0 and 100protected void setProgressPhase(String phase)
phase - a progress phase to setprotected void addNeighbourSelection(NeighbourSelection<V,T> ns, double bonus)
ns - a selectionbonus - execution bonus (more bonus means more executions of this neighbour selection, see NeighbourSelector)protected void setHCMode(boolean hcMode)
HillClimberSelection interface.hcMode - true if the search is a hill climber (worsening moves are always rejected)protected List<? extends NeighbourSelection<V,T>> getNeighbours()
public void init(Solver<V,T> solver)
NeighbourSelectionprotected NeighbourSelection<V,T> nextNeighbourSelection()
protected void logNeibourStatus()
public Neighbour<V,T> generateMove(Solution<V,T> solution)
solution - current solutionpublic Neighbour<V,T> selectNeighbour(Solution<V,T> solution)
NeighbourSelectionselectNeighbour in interface NeighbourSelection<V extends Variable<V,T>,T extends Value<V,T>>solution - given solutionprotected boolean accept(NeighbourSearch.NeighbourSearchContext context, Solution<V,T> solution, Neighbour<V,T> neighbour)
context - search contextsolution - current solutionneighbour - a generated movepublic boolean accept(Assignment<V,T> assignment, LazyNeighbour<V,T> neighbour, double value)
accept in interface LazyNeighbour.LazyNeighbourAcceptanceCriterion<V extends Variable<V,T>,T extends Value<V,T>>assignment - current assignmentneighbour - neighbour that was assignedvalue - change in overall solution valuepublic abstract String getParameterBaseName()
public void bestSaved(Solution<V,T> solution)
SolutionListenerSolution.saveBest() is called.public void solutionUpdated(Solution<V,T> solution)
SolutionListenerSolution.update(double).solutionUpdated in interface SolutionListener<V extends Variable<V,T>,T extends Value<V,T>>solution - source solutionpublic void getInfo(Solution<V,T> solution, Map<String,String> info)
SolutionListenerSolution.getInfo(). A listener can also add some its info into
this table.public void getInfo(Solution<V,T> solution, Map<String,String> info, Collection<V> variables)
SolutionListenerSolution.getInfo(). A listener can also add some its info into
this table.public void bestCleared(Solution<V,T> solution)
SolutionListenerSolution.clearBest() is
called.bestCleared in interface SolutionListener<V extends Variable<V,T>,T extends Value<V,T>>solution - source solutionpublic void bestRestored(Solution<V,T> solution)
SolutionListenerSolution.restoreBest() is
called.bestRestored in interface SolutionListener<V extends Variable<V,T>,T extends Value<V,T>>solution - source solution