data
Class ProbSystemHash

java.lang.Object
  extended by data.ProbSystemHash
All Implemented Interfaces:
ProbSystem, java.io.Serializable

public class ProbSystemHash
extends java.lang.Object
implements ProbSystem, java.io.Serializable

ProbSystem Hash

This class represents a probabilistic system constructed using hash table structures. A probabilistic system must respect the following constraints :

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

Version:
1.0
Author:
Nicolas Richard
See Also:
Serialized Form

Constructor Summary
ProbSystemHash(double initialState, IntervalList statesList, int nbAct)
          Initialize a new system from its starting state and its state space
 
Method Summary
 void addAction(java.lang.String action)
          Adds the specified action to the action list.
 void addLabelToStates(java.util.HashMap map)
          Associate several labels to states using an association table
 void addLabelToStates(java.lang.String ap, IntervalList l)
          Adds a label associated to certain states of the system.
 void addTransition(Transition t)
          Adds a transition to the system and the associations if the transition is not already present in the system.
 void addTransition(Transition t, boolean verify)
          Adds a transition to the system and the associations if the transition is not already present in the system.
 java.util.HashMap computeProbabilities(IntervalList list, java.lang.String act, Variable v, Parser p)
          This function returns the intervals and their respective repartition function which are reachable using the states in the list of starting states using the action act.
 java.util.ArrayList getActions()
          Returns all the action that can be applied in the system.
 java.util.TreeSet getAP()
          Returns the atomic propositions set
 java.util.ArrayList getEnd()
          Returns the ending state sets
 Interval[] getEndingStates(java.lang.String act, Interval init)
          Returns all the ending intervals that can be reached by the specified action from the specified starting interval.
 java.util.ArrayList getExp()
          Returns the list of repartition functions
 double getInitialState()
          Returns the initial state of the system
 Mtbdd getM()
          Returns an integer associated with the CUDD manager used by this system.
 int getNbAction()
          Returns the maximum number of actions in the system
 java.util.ArrayList getStart()
          Returns the starting state set
 Interval[] getStartingStates(java.lang.String act)
          Returns all the starting sets x from X for which the specified action may produce some result.
 IntervalList getStates()
          Returns the entire state space of the system
 IntervalList getStatesForLabel(java.lang.String ap)
          Returns the states set associated with the atomic proposition.
 int getTrans()
          Returns an integer associated with the transition list in the CUDD library.
 Transition getTransition(java.lang.String act, Interval init, Interval end)
          Returns the transition associated with the specified triplet.
 Transition[] getTransitions()
          Returns all the transitions of the system into a simple array
 java.util.Vector getTransitionsVector()
          Returns all the transitions of the system into a vector.
 void removeLabelFromStates(java.lang.String ap, IntervalList l)
          Dissociate an atomic proposition from the states
 void removeTransition(Transition t)
          Removes the transition from the system
 void setInitialState(double newInitialState)
          Modifies the initial state of the system
 void setStates(IntervalList newStateSpace)
          Sets all the possible states of the system.
 java.lang.String toString()
          Implements the serailzable method toString that returns a string representing the entire probabilistic system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProbSystemHash

public ProbSystemHash(double initialState,
                      IntervalList statesList,
                      int nbAct)
Initialize a new system from its starting state and its state space

Parameters:
initialState - the initial state of the system
statesList - the entire state space
nbAct - maximum number of actions
Method Detail

getNbAction

public int getNbAction()
Returns the maximum number of actions in the system

Specified by:
getNbAction in interface ProbSystem
Returns:
the maximum number of actions in the system

getM

public Mtbdd getM()
Returns an integer associated with the CUDD manager used by this system. Since Hash tables are used, a null value is returned.

Specified by:
getM in interface ProbSystem
Returns:
null value

getTrans

public int getTrans()
Returns an integer associated with the transition list in the CUDD library. Since we are using Hash tables, zero is returned.

Specified by:
getTrans in interface ProbSystem
Returns:
zero

getExp

public java.util.ArrayList getExp()
Returns the list of repartition functions

Specified by:
getExp in interface ProbSystem
Returns:
a list containing all the repartition functions

addAction

public void addAction(java.lang.String action)
Adds the specified action to the action list. Should the action be already registered, nothing will be done.

Parameters:
action - the action to register.

addTransition

public void addTransition(Transition t)
                   throws ProbSystemException
Adds a transition to the system and the associations if the transition is not already present in the system.

Specified by:
addTransition in interface ProbSystem
Parameters:
t - the transition to add.
Throws:
ProbSystemException - if one of the constraints has been violated.

addTransition

public void addTransition(Transition t,
                          boolean verify)
                   throws ProbSystemException
Adds a transition to the system and the associations if the transition is not already present in the system. This version of the constructor allows to add a transition WITHOUT verifying the system's integrity. This is useful for optimization in system's loading. NEVER USE THIS FUNCTION DURING ANY OTHER OPERATION !!!

Specified by:
addTransition in interface ProbSystem
Parameters:
t - the transition to add.
verify - true if the system's integrity should be verified
Throws:
ProbSystemException - if one of the constraints has been violated.

removeTransition

public void removeTransition(Transition t)
Removes the transition from the system

Specified by:
removeTransition in interface ProbSystem
Parameters:
t - the transition to remove

getStates

public IntervalList getStates()
Returns the entire state space of the system

Specified by:
getStates in interface ProbSystem
Returns:
the system's state space

setStates

public void setStates(IntervalList newStateSpace)
               throws java.lang.Exception
Sets all the possible states of the system.

Specified by:
setStates in interface ProbSystem
Throws:
java.lang.Exception - should the new state space be invalid

getAP

public java.util.TreeSet getAP()
Returns the atomic propositions set

Specified by:
getAP in interface ProbSystem
Returns:
a set containing all the atomic propositions

addLabelToStates

public void addLabelToStates(java.util.HashMap map)
                      throws ProbSystemException
Associate several labels to states using an association table

Specified by:
addLabelToStates in interface ProbSystem
Parameters:
map - an association table containg associations of label -> transitions
Throws:
ProbSystemException - should invalid associations be specified

addLabelToStates

public void addLabelToStates(java.lang.String ap,
                             IntervalList l)
                      throws ProbSystemException
Adds a label associated to certain states of the system. Should the label already be associated with states of the system, unification of the new states with the old ones shall be made.

Specified by:
addLabelToStates in interface ProbSystem
Parameters:
ap - a label to add to the states. Must be a single word beginning with a lowercase letter.
l - the states to associate with the label
Throws:
ProbSystemException - if the label does not begin with a lowercase letter

removeLabelFromStates

public void removeLabelFromStates(java.lang.String ap,
                                  IntervalList l)
Dissociate an atomic proposition from the states

Specified by:
removeLabelFromStates in interface ProbSystem
Parameters:
ap - the atomic proposition to dissociate
l - the states to be dissociated

getStatesForLabel

public IntervalList getStatesForLabel(java.lang.String ap)
Returns the states set associated with the atomic proposition. An empty set will be returned if no state accepts this label.

Specified by:
getStatesForLabel in interface ProbSystem
Parameters:
ap - the label to fetch the intervals from.
Returns:
all the states that accept this atomic proposition

getStart

public java.util.ArrayList getStart()
Returns the starting state set

Specified by:
getStart in interface ProbSystem
Returns:
the starting state set X

getEnd

public java.util.ArrayList getEnd()
Returns the ending state sets

Specified by:
getEnd in interface ProbSystem
Returns:
the ending state sets

getActions

public java.util.ArrayList getActions()
Returns all the action that can be applied in the system. No asumption can be made about the order of the actions in the array, i.e. they are not sorted. If no action can be applied, an empty set is returned.

Specified by:
getActions in interface ProbSystem
Returns:
all the possible actions appliable to transitions of the system

getStartingStates

public Interval[] getStartingStates(java.lang.String act)
Returns all the starting sets x from X for which the specified action may produce some result. If the action is not valid for the system, or no transition has the action attached, then a null set will be returned.

Parameters:
act - the action from which to list the starting state sets x
Returns:
an array of intervals for which at least one transition using the action act exists.

getEndingStates

public Interval[] getEndingStates(java.lang.String act,
                                  Interval init)
Returns all the ending intervals that can be reached by the specified action from the specified starting interval.

Parameters:
act - the action that must be applied
init - the starting interval from which the action is applied
Returns:
an array containing all the ending states reachable

getTransition

public Transition getTransition(java.lang.String act,
                                Interval init,
                                Interval end)
Returns the transition associated with the specified triplet. Since hashtable are used, it is much faster to fetch the transition this way than seeking all the transition list.

Parameters:
act - the action applied
init - the initial state set from with the action is applied.
end - the ending state set resulting from the applicaiton.
Returns:
the Transition object associated to the triplet

getTransitions

public Transition[] getTransitions()
Returns all the transitions of the system into a simple array

Specified by:
getTransitions in interface ProbSystem
Returns:
an array containing all the system's transitions

getTransitionsVector

public java.util.Vector getTransitionsVector()
Returns all the transitions of the system into a vector.

Specified by:
getTransitionsVector in interface ProbSystem
Returns:
a vector containing all of the system transitions

toString

public java.lang.String toString()
Implements the serailzable method toString that returns a string representing the entire probabilistic system. This method is useful for printing the system content, and to save the system content to a file.

Specified by:
toString in interface ProbSystem
Overrides:
toString in class java.lang.Object
Returns:
a string representing the system

getInitialState

public double getInitialState()
Returns the initial state of the system

Specified by:
getInitialState in interface ProbSystem
Returns:
a real number representing the initial state of the system

setInitialState

public void setInitialState(double newInitialState)
                     throws java.lang.Exception
Modifies the initial state of the system

Specified by:
setInitialState in interface ProbSystem
Parameters:
newInitialState - the new initial state
Throws:
java.lang.Exception - if the initial state is invalid

computeProbabilities

public java.util.HashMap computeProbabilities(IntervalList list,
                                              java.lang.String act,
                                              Variable v,
                                              Parser p)
This function returns the intervals and their respective repartition function which are reachable using the states in the list of starting states using the action act.

Specified by:
computeProbabilities in interface ProbSystem
Parameters:
list - the starting interval list
act - the action to apply
v - the variable used during computation
p - an expression parser in order to determine the reachable states
Returns:
the states reachable and their associated repartition function