net.sf.cpsolver.ifs.model
Class LazyNeighbour<V extends Variable<V,T>,T extends Value<V,T>>

java.lang.Object
  extended by net.sf.cpsolver.ifs.model.Neighbour<V,T>
      extended by net.sf.cpsolver.ifs.model.LazyNeighbour<V,T>
Direct Known Subclasses:
LazySwap

public abstract class LazyNeighbour<V extends Variable<V,T>,T extends Value<V,T>>
extends Neighbour<V,T>

Lazy neigbour (a change of the overall solution value is unknown before the neighbour is assigned, it is possible to undo the neighbour instead). This neighbour is useful when it is two expensive to compute change of overall solution value before the variable is reassigned. It is possible to undo the neighbour instead. Search strategy has to implement LazyNeighbour.LazyNeighbourAcceptanceCriterion.

Version:
IFS 1.2 (Iterative Forward Search)
Copyright (C) 2013 Tomas Muller
muller@unitime.org
http://muller.unitime.org

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.

Nested Class Summary
static interface LazyNeighbour.LazyNeighbourAcceptanceCriterion<V extends Variable<V,T>,T extends Value<V,T>>
          Neighbour acceptance criterion interface (to be implemented by search strategies that are using LazyNeighbour.
 
Constructor Summary
LazyNeighbour()
           
 
Method Summary
 void assign(long iteration)
          Assign neighbour, check given acceptance criterion, and undo assignment if the change is not accepted.
protected abstract  void doAssign(long iteration)
          Perform assignment
abstract  Model<V,T> getModel()
          Return problem model (it is needed in order to be able to get overall solution value before and after the assignment of this neighbour)
 void setAcceptanceCriterion(LazyNeighbour.LazyNeighbourAcceptanceCriterion<V,T> criterion)
          Set acceptance criterion (to be used by a search strategy before the neighbour is accepted, so that it can be undone if desired)
protected abstract  void undoAssign(long iteration)
          Undo assignment
 double value()
          Return -1 (neighbour is always accepted).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyNeighbour

public LazyNeighbour()
Method Detail

setAcceptanceCriterion

public void setAcceptanceCriterion(LazyNeighbour.LazyNeighbourAcceptanceCriterion<V,T> criterion)
Set acceptance criterion (to be used by a search strategy before the neighbour is accepted, so that it can be undone if desired)


assign

public void assign(long iteration)
Assign neighbour, check given acceptance criterion, and undo assignment if the change is not accepted.

Specified by:
assign in class Neighbour<V extends Variable<V,T>,T extends Value<V,T>>

value

public double value()
Return -1 (neighbour is always accepted). The search strategy that is using this neighbour must implement LazyNeighbour.LazyNeighbourAcceptanceCriterion.

Specified by:
value in class Neighbour<V extends Variable<V,T>,T extends Value<V,T>>

doAssign

protected abstract void doAssign(long iteration)
Perform assignment


undoAssign

protected abstract void undoAssign(long iteration)
Undo assignment


getModel

public abstract Model<V,T> getModel()
Return problem model (it is needed in order to be able to get overall solution value before and after the assignment of this neighbour)



Copyright © 2014 UniTime LLC. All Rights Reserved.