public Neighbour selectNeighbour(Solution solution) {
Model model = solution.getModel();
if (iVarEn==null) {
iVarEn = new RandomEnumeration(model.variables(), iRandomOrder);
iVariable = (Variable)iVarEn.nextElement();
Vector v2 = new Vector(iVariable.values().size()+model.variables().size());
if (iAllowSwaps && iVariable instanceof Swapable)
v2.addAll(model.variables());
v2.addAll(iVariable.values());
iValEn = new RandomEnumeration(v2, iRandomOrder);
}
SimpleNeighbour n = null;
if (!iValEn.hasMoreElements()) {
if (!iVarEn.hasMoreElements()) {
iVarEn = new RandomEnumeration(model.variables(), iRandomOrder);
}
iVariable = (Variable)iVarEn.nextElement();
Vector v2 = new Vector(iVariable.values().size()+model.variables().size());
if (iAllowSwaps && iVariable instanceof Swapable)
v2.addAll(model.variables());
v2.addAll(iVariable.values());
iValEn = new RandomEnumeration(v2, iRandomOrder);
}
Object object = iValEn.nextElement();
if (object instanceof Variable) {
Variable anotherVariable = (Variable)ToolBox.random(model.variables());