fr.jussieu.gla.wasa.core
Class Problem

java.lang.Object
  |
  +--fr.jussieu.gla.wasa.core.Problem
Direct Known Subclasses:
MagicSquareProblem, ProgressivePartyProblem

public class Problem
extends java.lang.Object

Represents a Problem, as a set of Vars, Constraints, etc.

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

Constructor Summary
Problem()
           
 
Method Summary
 void add(Explorer explorer)
          Adds an Explorer to the Problem.
 int add(Var var)
          Adds a Var to the Problem.
 boolean contains(Constraint constraint)
           
 Constraint getConstraint(int index)
           
 int getConstraintCount()
           
 Constraint[] getConstraints()
           
 Engine getEngine()
           
 ErrorMixer getErrorMixer()
           
 Explorer getExplorer(int index)
           
 int getExplorerCount()
           
 Explorer[] getExplorers()
           
 RandomConfigurator getRandomConfigurator()
           
 Var getVar(int index)
          Returns the Var with an instanciation rank equal to index.
 int getVarCount()
          Returns the number of the problem Vars.
 Var[] getVars()
          Returns all the Vars of the Problem in an array.
 void restore(Configuration configuration)
           
 void setErrorMixer(ErrorMixer mixer)
           
 void setRandomConfigurator(RandomConfigurator configurator)
          Use this method to set the problem specific RandomConfigurator used to initialize the buisness object and escape from a dead end.
 Configuration snapshot()
          Creates a Configuration representing the current state of Buisness Objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Problem

public Problem()
Method Detail

getEngine

public final Engine getEngine()

getErrorMixer

public ErrorMixer getErrorMixer()

setErrorMixer

public void setErrorMixer(ErrorMixer mixer)

add

public final int add(Var var)
Adds a Var to the Problem. Once added, a Var can never be removed.
Parameters:
var - The Var to add.
Returns:
the rank of the added Var.
Throws:
NullPointerException - If var is null.
ProblemStateException - If Problem already initialized.

getVars

public final Var[] getVars()
Returns all the Vars of the Problem in an array.
Returns:
An array of all the problem Vars.

getVarCount

public final int getVarCount()
Returns the number of the problem Vars.
Returns:
The number of the problem Vars.

getVar

public final Var getVar(int index)
Returns the Var with an instanciation rank equal to index.
Returns:
The Var with an instanciation rank equal to index.

add

public final void add(Explorer explorer)
Adds an Explorer to the Problem. Once added, an Explorer can never be removed.
Parameters:
explorer - The Explorer to add.
Throws:
NullPointerException - If explorer is null.
ProblemStateException - If Problem already initialized.

getExplorers

public final Explorer[] getExplorers()

getExplorerCount

public final int getExplorerCount()

getExplorer

public final Explorer getExplorer(int index)

contains

public final boolean contains(Constraint constraint)

getConstraints

public final Constraint[] getConstraints()

getConstraintCount

public final int getConstraintCount()

getConstraint

public final Constraint getConstraint(int index)

snapshot

public final Configuration snapshot()
Creates a Configuration representing the current state of Buisness Objects. This method makes the Problem the "author" in this modified Memento pattern, the Configuration being the Memento.

This method is declared public for test purposes, but should never be called from outside of this package.

Returns:
A Configuration object representing current Problem's configuration.
Throws:
IllegalProblemStateException - If the Problem is not initialized.

restore

public final void restore(Configuration configuration)

getRandomConfigurator

public final RandomConfigurator getRandomConfigurator()
                                               throws EngineException

setRandomConfigurator

public final void setRandomConfigurator(RandomConfigurator configurator)
Use this method to set the problem specific RandomConfigurator used to initialize the buisness object and escape from a dead end.