V
- VariableT
- Valuepublic class NeighbourSelector<V extends Variable<V,T>,T extends Value<V,T>> extends Object implements NeighbourSelection<V,T>
NeighbourSelection
that keeps some stats about the
given neighbour selector.Modifier and Type | Field and Description |
---|---|
protected static DecimalFormat |
sDF |
Constructor and Description |
---|
NeighbourSelector(NeighbourSelection<V,T> sel,
double bonus,
boolean update)
Constructor
|
Modifier and Type | Method and Description |
---|---|
double |
getBonus()
Initial bonus
|
double |
getPoints()
Weight of the selector in the roulette wheel selection of neighbour selectors
|
void |
init(Solver<V,T> solver)
Initialization
|
int |
nrCalls()
Number of calls of
NeighbourSelection.selectNeighbour(Solution) |
int |
nrImprovingMoves()
Number of returned improving moves (i.e.,
Neighbour.value(Assignment) < 0) |
int |
nrNotNull()
Number of returned not-null moves
|
int |
nrSideMoves()
Number of returned moves with zero improvement of the solution (i.e.,
Neighbour.value(Assignment) = 0) |
NeighbourSelection<V,T> |
selection()
Given neighbour selection
|
Neighbour<V,T> |
selectNeighbour(Solution<V,T> solution)
Neighbour selection -- use
NeighbourSelection.selectNeighbour(Solution)
update stats if desired. |
double |
speed()
Average number of iterations per second (calls of
NeighbourSelection.selectNeighbour(Solution) ) |
long |
time()
Total time spend in
NeighbourSelection.selectNeighbour(Solution) (in milliseconds) |
String |
toString()
String representation
|
void |
update(Assignment<V,T> a,
Neighbour<V,T> n,
long time)
Update statistics
|
protected static DecimalFormat sDF
public NeighbourSelector(NeighbourSelection<V,T> sel, double bonus, boolean update)
sel
- neighbour selectorbonus
- initial bonus (default is 1, can be changed by @n parameter after
the name of the selector in Xxx.Neigbours, e.g., org.cpsolver.itc.tim.neighbours.TimPrecedenceMove@0.1
for initial bonus 0.1update
- update selector bonus after each iterationpublic Neighbour<V,T> selectNeighbour(Solution<V,T> solution)
NeighbourSelection.selectNeighbour(Solution)
update stats if desired.selectNeighbour
in interface NeighbourSelection<V extends Variable<V,T>,T extends Value<V,T>>
solution
- given solutionpublic void update(Assignment<V,T> a, Neighbour<V,T> n, long time)
a
- current assignmentn
- generated movetime
- time needed to generate the move (in milliseconds)public double getPoints()
public double getBonus()
public NeighbourSelection<V,T> selection()
public int nrCalls()
NeighbourSelection.selectNeighbour(Solution)
public int nrNotNull()
public int nrSideMoves()
Neighbour.value(Assignment)
= 0)public int nrImprovingMoves()
Neighbour.value(Assignment)
< 0)public long time()
NeighbourSelection.selectNeighbour(Solution)
(in milliseconds)public double speed()
NeighbourSelection.selectNeighbour(Solution)
)