fr.jussieu.gla.wasa.core
Class Engine

java.lang.Object
  |
  +--fr.jussieu.gla.wasa.core.Engine

public final class Engine
extends java.lang.Object

Use this class to apply the Adaptative Search Algorithm to a Problem.

Version:
$Revision: 1.15 $ $Date: 2002/04/17 15:24:05 $
Author:
Laurent Caillette, Florent Selva

Constructor Summary
Engine(Problem problem)
           
 
Method Summary
 void configure(IEngineParameters parameters)
          Configures the engine with the IEngineParameters passed in argument.
 Algorithm getAlgorithm()
          Returns the effective algorithm used by the engine.
 boolean getAllowNoConstraintApplied()
           
 Configuration getBest()
          Returns the best Configuration found by the Engine.
 ICustomizer getCustomizer()
           
 IEngineParameters getParameters()
          Returns a copy of parameters currently in use.
 Problem getProblem()
          Returns the Problem used by the engine.
 java.util.Random getRandom()
          Returns the Random instance used by the engine.
 TabuList getTabuList()
          Returns the TabuList in use, for allowing customizations.
 int getTabuListCapacity()
          Returns the capacity of the TabuList.
 void reappropriateProblem()
          Used only by Monitor GUI.
 void restoreBest()
          Use this method to retsore states of your buisness objects with the best found configuration.
 int run(float errorThreshold)
          Executes steps until the best found overall error is under errorThreshold.
 void run(int stepCount)
          Executes stepCount steps.
 int run(int guard, float errorThreshold)
          Executes at most guard times steps and returns when a configuration with an error under errorThreshold has benn found.
 int runQuiet(float errorThreshold)
          Same as run( float ) but doesn't need to be inserted in a try/catch block.
 void runQuiet(int stepCount)
          Same as run( int ) with no need to insert into a try/catch block.
 int runQuiet(int guard, float errorThreshold)
          Same as run( int, float) but doesn't need to be inserted in a try/catch block.
 void setAllowNoConstraintApplied(boolean allow)
          Allows to avoid throwing a NoConstraintAppliedException when all Explorers did not set any Var error.
 void setCustomizer(ICustomizer customizer)
          Use this method to plug your own Customizer.
 void setRandom(java.util.Random random)
          Sets the randomizer used by the engine to generate random sequences.
 void setTabuListCapacity(int tabuListCapacity)
          Sets the capacity of the TabuList.
 AlgorithmState step()
          Runs one iteration of the Adaptative Search Algorithm.
 boolean step(float errorThreshold)
          Same method as step() but returns true if a solution has been found.
 void stepQuiet()
          Same method as step(), but doesn't need to be inserted in a try/catch block.
 boolean stepQuiet(float errorThreshold)
          Same as stepQuiet().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine(Problem problem)
Method Detail

getAlgorithm

public Algorithm getAlgorithm()
Returns the effective algorithm used by the engine.
Returns:
The effective algorithm used by the engine.

getProblem

public Problem getProblem()
Returns the Problem used by the engine.
Returns:
The Problem used by the engine

reappropriateProblem

public void reappropriateProblem()
Used only by Monitor GUI. Sets problem's engine to this.

configure

public void configure(IEngineParameters parameters)
Configures the engine with the IEngineParameters passed in argument.

getParameters

public IEngineParameters getParameters()
Returns a copy of parameters currently in use.
Returns:
An instance of IEngineParameters representing current parameters.

getRandom

public java.util.Random getRandom()
Returns the Random instance used by the engine.
Returns:
The Random instance used by the engine

setRandom

public void setRandom(java.util.Random random)
Sets the randomizer used by the engine to generate random sequences. Plug your own instrumented random to obtain always the same random sequence for the tests.

getTabuListCapacity

public int getTabuListCapacity()
Returns the capacity of the TabuList.

setTabuListCapacity

public void setTabuListCapacity(int tabuListCapacity)
Sets the capacity of the TabuList. The default value is 1.

getTabuList

public TabuList getTabuList()
Returns the TabuList in use, for allowing customizations.
Returns:
The TabuList in use.

setAllowNoConstraintApplied

public void setAllowNoConstraintApplied(boolean allow)
Allows to avoid throwing a NoConstraintAppliedException when all Explorers did not set any Var error. Set to true by default.
Parameters:
allow - true by default.

getAllowNoConstraintApplied

public boolean getAllowNoConstraintApplied()

step

public AlgorithmState step()
                    throws EngineException,
                           java.lang.CloneNotSupportedException
Runs one iteration of the Adaptative Search Algorithm.

Error handling
Any error occuring during this method execution will set the state of the Engine to CRASHED.

Returns:
true if total number of runs is < than current maximum number of moves.
Throws:
EngineException -  
java.lang.CloneNotSupportedException - When a Buisness Object had a problem with cloning. This exception is not wrapped into the EngineException because it is useful for debugging to get the entire stack trace.

stepQuiet

public void stepQuiet()
Same method as step(), but doesn't need to be inserted in a try/catch block.
Throws:
CascadingRuntimeException -  

step

public boolean step(float errorThreshold)
             throws EngineException,
                    java.lang.CloneNotSupportedException
Same method as step() but returns true if a solution has been found.
Returns:
True if an overall error below the errorThreshold parameter has been found.
See Also:
step()

stepQuiet

public boolean stepQuiet(float errorThreshold)
Same as stepQuiet().
Throws:
CascadingRuntimeException -  

run

public void run(int stepCount)
         throws EngineException,
                java.lang.CloneNotSupportedException
Executes stepCount steps.
See Also:
step()

runQuiet

public void runQuiet(int stepCount)
Same as run( int ) with no need to insert into a try/catch block.
Throws:
CascadingRuntimeException -  

run

public int run(float errorThreshold)
        throws EngineException,
               java.lang.CloneNotSupportedException
Executes steps until the best found overall error is under errorThreshold.

runQuiet

public int runQuiet(float errorThreshold)
Same as run( float ) but doesn't need to be inserted in a try/catch block.
Throws:
CascadingRuntimeException -  

run

public int run(int guard,
               float errorThreshold)
        throws EngineException,
               java.lang.CloneNotSupportedException
Executes at most guard times steps and returns when a configuration with an error under errorThreshold has benn found.

runQuiet

public int runQuiet(int guard,
                    float errorThreshold)
Same as run( int, float) but doesn't need to be inserted in a try/catch block.
Throws:
CascadingRuntimeException -  

getBest

public Configuration getBest()
Returns the best Configuration found by the Engine.
Returns:
the best Configuration found by the Engine.

restoreBest

public void restoreBest()
Use this method to retsore states of your buisness objects with the best found configuration.

setCustomizer

public void setCustomizer(ICustomizer customizer)
Use this method to plug your own Customizer.

getCustomizer

public ICustomizer getCustomizer()