plugins.big.bigsnakeutils.icy.snake3D
Class Snake3DOptimizer

java.lang.Object
  extended by java.util.Observable
      extended by plugins.big.bigsnakeutils.icy.snake3D.Snake3DOptimizer
Direct Known Subclasses:
Snake3DPowellOptimizer

public abstract class Snake3DOptimizer
extends java.util.Observable

This class encapsulates the optimization aspects of snakes. It handles objects that implement the Snake3D interface.

Version:
May 3, 2014
Author:
Philippe Thévenaz (philippe.thevenaz@epfl.ch), Ricard Delgado-Gonzalo (ricard.delgado@gmail.com), Nicolas Chenouard (nicolas.chenouard@gmail.com)

Field Summary
 boolean isCurrentBest
          The state of the snake being optimized.
 
Constructor Summary
Snake3DOptimizer()
           
 
Method Summary
abstract  void optimize(Snake3D snake, Snake3DNode[] configuration)
          This method should perform the optimization of the Snake3DNode[] object configuration which drives the Snake3D object snake.
abstract  java.lang.Double reportSnakeBestObservedEnergy()
          After the optimization completes, this method will be called by the keeper to debrief the optimizer.
abstract  boolean reportSnakeDeath()
          After the optimization completes, this method will be called by the keeper to debrief the optimizer.
abstract  boolean reportSnakeOptimality()
          After the optimization completes, this method will be called by the keeper to debrief the optimizer.
abstract  void stopOptimizing()
          A call to this method should result in the optimization being currently performed by this object to be interrupted.
 void wasSuccessfulProbing(Snake3D snake)
          Notifies the keeper that the optimizer was successful in its previous attempt to improve the configuration of the snake snake.
 void willProbe(Snake3D snake)
          Notifies the keeper that the optimizer is about to measure either the energy of the snake snake or its gradient.
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isCurrentBest

public boolean isCurrentBest
The state of the snake being optimized. Set to false before issuing the statement notifyObservers(snake); that should precede a measurement of the energy of the snake. Set to true before issuing the statement notifyObservers(snake); to notify the Snake2D.Snake2DKeeper keeper object that the snake did indeed improve.

Constructor Detail

Snake3DOptimizer

public Snake3DOptimizer()
Method Detail

optimize

public abstract void optimize(Snake3D snake,
                              Snake3DNode[] configuration)
This method should perform the optimization of the Snake3DNode[] object configuration which drives the Snake3D object snake. The initial configuration should be retrieved from configuration. When the optimization is iterative, the iteration loop should contain the following elements: IMPORTANT: Every time it is desired to access either one of the energy() or getEnergyGradient() methods of the snake, a call to its isAlive() method ought to be made to ensure that it is admissible to carry on with the optimization. In case the snake died, the optimization should be made to terminate immediately.


reportSnakeBestObservedEnergy

public abstract java.lang.Double reportSnakeBestObservedEnergy()
After the optimization completes, this method will be called by the keeper to debrief the optimizer.

Returns:
Return null if the energy could not be computed even once. Else, return the best energy that could be observed during optimization.

reportSnakeDeath

public abstract boolean reportSnakeDeath()
After the optimization completes, this method will be called by the keeper to debrief the optimizer.

Returns:
Return false if the snake was still alive when the optimizer did terminate, or possibly if an eventual death of the snake was unrelated to the termination decision. Return true if the optimizer did indeed terminate because the snake died.

reportSnakeOptimality

public abstract boolean reportSnakeOptimality()
After the optimization completes, this method will be called by the keeper to debrief the optimizer.

Returns:
Return false if the optimizer abandoned its task before the optimization was complete, whatever the reason may have been. Return true if the optimizer could bring its task to completion and found a snake that was deemed to be optimal.

stopOptimizing

public abstract void stopOptimizing()
A call to this method should result in the optimization being currently performed by this object to be interrupted. The method optimize should then be made to return as early as possible. It is not necessary to restore the optimized snake in any particular configuration, because the best configuration will have been recorded by the keeper for each call to the method notifyObservers(snake).


wasSuccessfulProbing

public void wasSuccessfulProbing(Snake3D snake)
Notifies the keeper that the optimizer was successful in its previous attempt to improve the configuration of the snake snake. It is assumed that snake.getNodes(); is going to return unchanged configuration values.


willProbe

public void willProbe(Snake3D snake)
Notifies the keeper that the optimizer is about to measure either the energy of the snake snake or its gradient.