generator.engin
Class GeneratorEngine

java.lang.Object
  extended by java.lang.Thread
      extended by generator.engin.GeneratorEngine
All Implemented Interfaces:
java.lang.Runnable

public class GeneratorEngine
extends java.lang.Thread

Generator Engine

The engine performs the random system generation. Two types of system can be created : finite state space or continuous state space (LMP). The system is directly created into the file to save memory.

Copyright(c) 2005 Université Laval, LSFM research group.

Version:
1.1
Author:
Frédérick Lemay

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int FINITE_STATES
          Defines a finite states generation
static int LMP
          Defines a LMP generation mode
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GeneratorEngine(RandomizedModel randomizedModel, java.io.File outputFile, ProgressDialog progress)
          Creates a generic generation engine.
 
Method Summary
 void addListener(GeneratorEngineListener listener)
          This method attaches a listener to the engine
 java.util.ArrayList bagOfActions(int numberOfElements)
          Returns a subset of A containing numberOfElements elements
 void generateActions()
          This function generates the labels for the actions
 void generateIntervals()
          This method generates the X and Y interval set from a supplied randomizedModel.
 void generateTransitions()
          This function generates the transitions of the system
 void generateTransitionsForX(Interval x, int tNumber)
          This method generates all transitions for an interval x from X.
 java.io.File getLastGeneratedFile()
          This method returns the last succesfully generated file
 Interval getStates()
          Returns the state set of the system.
 IntervalListNoUnion getX()
          Returns the domain of the transitions (also known as the X set).
 IntervalListNoUnion getY()
          Returns the image of the transitions (also known as the Y set).
 void removeListener(GeneratorEngineListener listener)
          This method removes a listener from the engine
 void run()
          This where the generation occurs.
 void setMode(int generationMode)
          This function sets the generator mode.
 void writeHeader()
          This method write the file header
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LMP

public static final int LMP
Defines a LMP generation mode

See Also:
Constant Field Values

FINITE_STATES

public static final int FINITE_STATES
Defines a finite states generation

See Also:
Constant Field Values
Constructor Detail

GeneratorEngine

public GeneratorEngine(RandomizedModel randomizedModel,
                       java.io.File outputFile,
                       ProgressDialog progress)
                throws ParameterException
Creates a generic generation engine. Valid parameters must be provided. The default model type to generate is a LMP model but you can change this selection.

Parameters:
randomizedModel - The parameters set for the system to generate
outputFile - The file onto which the model will be written
progress - the progress dialog to update
Throws:
ParameterException - should no model of file have been provided
Method Detail

setMode

public void setMode(int generationMode)
This function sets the generator mode.

Parameters:
generationMode - mode of generation (finite or continuous state space)

getLastGeneratedFile

public java.io.File getLastGeneratedFile()
This method returns the last succesfully generated file

Returns:
the last succesfully generated file

addListener

public void addListener(GeneratorEngineListener listener)
This method attaches a listener to the engine

Parameters:
listener - the listener to add

removeListener

public void removeListener(GeneratorEngineListener listener)
This method removes a listener from the engine

Parameters:
listener - the listener to remove

run

public void run()
This where the generation occurs. This method is a thread, because the generation can take a long time. At the end of process, the file will be closed, and the lastGeneratedFile will modified if the generation wasn't cancelled and was successful. Otherwise, the file will be deleted.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

generateIntervals

public void generateIntervals()
This method generates the X and Y interval set from a supplied randomizedModel. Both X and Y must be included in the system's state space.


generateActions

public void generateActions()
This function generates the labels for the actions


writeHeader

public void writeHeader()
This method write the file header


generateTransitions

public void generateTransitions()
This function generates the transitions of the system


generateTransitionsForX

public void generateTransitionsForX(Interval x,
                                    int tNumber)
This method generates all transitions for an interval x from X.

Parameters:
x - : The interval x for which to generate transitions.
tNumber - : The number of transitions to generate.

getX

public IntervalListNoUnion getX()
Returns the domain of the transitions (also known as the X set).

Returns:
the X set.

getY

public IntervalListNoUnion getY()
Returns the image of the transitions (also known as the Y set).

Returns:
the Y set.

getStates

public Interval getStates()
Returns the state set of the system.

Returns:
the state set of the system.

bagOfActions

public java.util.ArrayList bagOfActions(int numberOfElements)
                                 throws ParameterException
Returns a subset of A containing numberOfElements elements

Parameters:
numberOfElements - the number of elements to choose from A.
Returns:
a subset with numberOfElements in it chosen from A.
Throws:
ParameterException - if numberOfElements is greater than the number of elements inside A.
ParameterException - if numberOfElements is negative.