jmarkov
Class MarkovProcess<S extends State,E extends Event>

java.lang.Object
  extended by jmarkov.MarkovProcess<S,E>
Type Parameters:
S - The State class for the model.
E - The Event class for the model.
All Implemented Interfaces:
JMarkovElement
Direct Known Subclasses:
SimpleMarkovProcess

public abstract class MarkovProcess<S extends State,E extends Event>
extends java.lang.Object
implements JMarkovElement

The abstract class SimpleMarkovProcess represents a Continuous or Discrete Time Markov Chain. In order to model a particular problem the user has to extend this class. The class can generate the model through the buildRS algorithm. This enables it to generate all states and the transition matrix, from behavior rule given by the user. These rules are determined by implementing the methods, active,dests and rate. The user should also determine how to code the space state. This is accomplished by implementing the State class. A particular implementation of State is provided where each state is coded with k integer properties. Examples are included in this release.

Version:
1.0a
Author:
German Riaņo. Universidad de los Andes.
See Also:
SimpleMarkovProcess.dests(State, Event), SimpleMarkovProcess.active(State, Event), SimpleMarkovProcess.rate(State, State, Event), State, Event, PropertiesState

Nested Class Summary
static class MarkovProcess.Status
          Status variables
 
Field Summary
protected  int cnt
          Number of completed states.
protected  SteadyStateSolver defaultSteadyStateSolver
          Default Transient Solver
protected  TransientSolver defaultTransientSolver
          Deafualt Transient solver
protected  java.lang.String name
          The name of the model.
protected  StatesSet<S> theStates
          Set of fully analyzed States
 
Constructor Summary
protected MarkovProcess()
          If a constructor calls this constructor then it MUST call setEvents and setInitialState afterwards.
  MarkovProcess(S i0, EventsSet<E> eSet)
          Builds a SimpleMarkovProcess that contains all states reachable from i0, and with E being the set of all possible events.
  MarkovProcess(S i0, EventsSet<E> eSet, java.lang.String name)
          Builds a SimpleMarkovProcess that contains all states reachable from i0, and with E being the set of all possible events.
 
Method Summary
abstract  Transitions<S> activeTransitions(S i, E e)
          The user MUST implement this Function in order to describe the dynamics of the model.
 boolean addMOP(java.lang.String mopName)
          This method declares the existance of a measure of performance (MOP).
 java.lang.String allToString()
          Retuns a String description of the model and solution.
 boolean canGo()
          Allos to stop model execution by graphica user interface.
 void clearMOPs()
          Clear all MOPs defined in the system.
 void debug(int level, java.lang.String s)
          Prints debug information with this importance level
 void debug(int level, java.lang.String s, boolean newline)
          Prints debug information with this importance level
 void debug(int level, java.lang.String s, boolean newline, boolean indent)
          Prints debug information with this importance level
 java.lang.String denseMatrixToString()
          Returns a String with a description of the Model: the States and the Transition Matrix.
 java.lang.String denseMatrixToString(int width, int rateDecimals, boolean printZeros, boolean useGenerator)
          Returns the Transition Matrix as a String.
abstract  java.lang.String description()
          This method should be implemented by the subclass to give word description of the model.
 java.lang.String eventRatesToString(int width, int decimals)
          Return a String as printed by printEventsrates
 java.lang.String eventsRatesToString()
          Return a string as eventsRatesToString, with width 8 and 4 decimals
protected  void finalize()
           
 void generate()
          generate() builds the space state and rate matrix using the algorithm BuildsSR.
 int getDebugLevel()
           
 DebugReporter getDebugReporter()
          Gets the DebugReporter currently in use.
protected  SteadyStateSolver getDefaultSteadyStateSolver()
          Returns the default SteadyStateSolver.
protected  TransientSolver getDefaultTransientSolver()
          The default solver for transient state.
 java.lang.Class getEventClass()
          The Class for the Events in the system.
 java.lang.String[] getEventNames()
          Returns the defined events
 double getEventRate(int eNum)
          Return the steadystate rate of occurrance of the Events number eNum.
 E[] getEvents()
          Returns all The events defined in the model.
 double[] getEventsRates()
          Return an array with the steadystate rate of occurrance of all the Events.
 double getFinalRate(S i, S j)
          Gets the total rate form State number i to j.
 double[][] getGenerator()
          Returns the infinitesimal generator matrix Q , in dense format.
protected  S getInitialState()
          returns the initial state.
 long getMaxStates()
           
 int getMOPIndex(java.lang.String name)
          Gets the index that correspond to this MOP.
 java.lang.String[] getMOPNames()
          Return all the names of defined MOPs.
 java.lang.String getMOPNames(int mopNum)
          Return the names of the i-th MOP.
 double[] getMOPsAvg()
          Returns an array with the average of all the steady state measures of performance.
 double getMOPsAvg(int mopNum)
          Returns the steady state measures average of the MOP numbre mopNum.
 double getMOPsAvg(java.lang.String mopName)
          Returns the steady state measures average of the MOP with name mopName.
 double[] getMOPsMoment(int m)
          Returns an array with the m-th moment of all the steady state measures of performance.
 double getMOPsMoment(int mopNum, int m)
          Returns the steady state measures m-th moment of the MOP number mopNum.
 double getMOPsMoment(java.lang.String mopName, int m)
          Returns the steady state measures m-th moment of the MOP with name mopName.
 no.uib.cipr.matrix.Matrix getMtjGenerator()
          The generator Q as an MTJ Matrix
 no.uib.cipr.matrix.Matrix getMtjRates()
          Returns the transition rates matrix R in MTJ format.
 int getNumStates()
          Return the number of States in the model.
 long getProgress()
          Return the number of states processed so far in the current process.
 double getRate(S i, S j)
          Gets the current total rate form i to j.
 double[][] getRates()
          Returns the transition rates matrix R in dense format.
 Transitions<S> getRates(S i)
          This method returns a dynamic data structure with the rate from State i to all reachable states.
 java.lang.Class getStateClass()
          The Class for the states in this model.
 StatesSet<S> getStates()
          Returns an array with all the States in the model.
 StatesSet<S> getStates(boolean causesGeneration)
          Returns an array with the States in the model that have been checked so far.
 MarkovProcess.Status getStatus()
          Returns the current status of the model.
 java.lang.String getStatusMsg()
          Returns a String describing the current status of the model.
 double[] getSteadyState()
          Returns the steady state probabilities for this model.
 SteadyStateSolver getSteadyStateSolver()
          The currently defined solver.
 TransientSolver getTransientSolver()
          The currently defined solver for transient state.
 void go()
          Runs the model, or resumes execution if it had been suspended.
 void goStep()
          Runs the model for a single step.
 void hideGUI()
          Hides the Graphic User Interface (GUI) that represent this Markov Chain if one is defined.
protected  java.lang.String hLine(int length)
          Retuns an horizontal text line of the given length.
 boolean isGenerated()
           
 void killGUI()
          Destroys the Graphic User Interface (GUI) that represent this Markov Chain if one is defined.
 java.lang.String label()
          Returns the name of the model.
 void loadGUI()
          Loads the Graphic User Interface (GUI) that represent this Markov Chain.
 java.lang.String MOPsToString()
          Return a String description of all MOPs in steady state (it reports mean and standard deviation).
 java.lang.String MOPsToString(int width, int decimals)
          Return a String description of all MOPs in steady state (it reports mean and standard deviation).
 int numMOPs()
          Returns the number of defined Measures of performance (MOPs).
protected  java.lang.String pad(double v, int w)
          pad generates a string representing the double v, padded with spaces up to width w.
protected  java.lang.String pad(double v, int w, boolean right)
          pad generates a string representing the double v, padded with spaces up to width w.
protected  java.lang.String pad(double v, int w, int d)
          pad fills with blanks up to width w.
protected  java.lang.String pad(double v, int w, int d, boolean right)
          pad fills with blanks up to width w
protected  java.lang.String pad(java.lang.String s, int w)
          pad fills with blanks up to width w
protected  java.lang.String pad(java.lang.String s, int w, boolean right)
          pad fills with blanks up to width w
 void pause()
          Pauses the current execution of the model.
 void printAll()
          Prints a description of the Model: the States and the Transition Matrix.
 void printAll(java.io.PrintWriter out)
          Prints to the given PrintWriter a summary of the information related to this MarkovChain.
 void printDenseMatrix(java.io.PrintWriter out)
          Prints a the Transition Matrix.
 void printDenseMatrix(java.io.PrintWriter out, int width, int rateDecimals, boolean printZeros, boolean useGenerator)
          Prints a description of the Model using the given PrintWriter: the States and the Transition Matrix.
protected  void printDenseMatrix(java.io.PrintWriter out, int width, int rateDecimals, boolean printZeros, boolean useGenerator, int[] idx)
          Prints a description of the Model using the given PrintWriter: the States and the Transition Matrix.
 void printEventsRates(java.io.PrintWriter out)
          Prints a table reporting the steadystate occurrance of all events.
 void printEventsRates(java.io.PrintWriter out, int width, int decimals)
          Prints a table reporting the steadystate occurrance of all events.
 void printMOPs()
          Prints the Measures of performance (MOPS) on standard output.
 void printMOPs(java.io.PrintWriter out)
          Prints a String description of all MOPs in steady state (it reports mean and standard deviation), with a width of 10 and 5 decimal figures.
 int printMOPs(java.io.PrintWriter out, int width, int decimals)
          Prints a String description of all MOPs in steady state (it reports mean and standard deviation).
 void printStates(java.io.PrintWriter out)
          Prints a description of the States and the Equilibrium Probabilities.
 void printStates(java.io.PrintWriter out, int width, int probDecimals)
          Prints a description of the States and the Equilibrium Probabilities.
 void reset()
          Resets the Model.
protected  void reset(boolean resetEvents)
          Resets the Model.
 void resetResults()
          Resets the result of the model.
 void setDebugLevel(int level)
          Sets the debug level, where level=0 means no debug info, level = 5 verbose info.
 void setDebugReporter(DebugReporter reporter)
          Sets the DebugReporter to use.
protected  void setEventSet(EventsSet<E> eSet)
          Sets the Events set.
protected  void setInitialState(S i0)
          Sets the initial state.
 void setMaxStates(long num)
          Sets the maximum number of states to generate.
 void setMOPs(java.lang.String[] mopNames)
          Sets the names of all MOPs (measures of performance).
 void setSteadyStateSolver(SteadyStateSolver steadyStateSolver)
          Allows the user to set an alternate solver.
 void setTransientSolver(TransientSolver transientSolver)
          Allows the user to set an alternate solver.
 void showGUI()
          Shows the Graphic User Interface (GUI) that represent this Markov Chain.
 int statesLableMaxWidth(int width)
          Computes the maximum used by the state's labels.
 java.lang.String statesToString()
          Prints a description of the States and the Equilibrium Probabilities.
 java.lang.String toString()
          This method returns a short String used in the user interface to describe this element.
protected  java.lang.String vLine()
          Returns a text vertical line.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmarkov.basic.JMarkovElement
equals
 

Field Detail

cnt

protected int cnt
Number of completed states. Use this counter so that GUI updates correctly.


theStates

protected StatesSet<S extends State> theStates
Set of fully analyzed States


name

protected java.lang.String name
The name of the model. For a long description override description().

See Also:
description()

defaultSteadyStateSolver

protected SteadyStateSolver defaultSteadyStateSolver
Default Transient Solver


defaultTransientSolver

protected TransientSolver defaultTransientSolver
Deafualt Transient solver

Constructor Detail

MarkovProcess

public MarkovProcess(S i0,
                     EventsSet<E> eSet,
                     java.lang.String name)
Builds a SimpleMarkovProcess that contains all states reachable from i0, and with E being the set of all possible events.

Parameters:
i0 - The initial State.
eSet - The set of all Events.
name - The name of the Model.

MarkovProcess

public MarkovProcess(S i0,
                     EventsSet<E> eSet)
Builds a SimpleMarkovProcess that contains all states reachable from i0, and with E being the set of all possible events.

Parameters:
i0 - The initial State.
eSet - The set of all Events.

MarkovProcess

protected MarkovProcess()
If a constructor calls this constructor then it MUST call setEvents and setInitialState afterwards.

Method Detail

setEventSet

protected void setEventSet(EventsSet<E> eSet)
Sets the Events set. It causes the model to be reset. This method should be called only in a constructor.

Parameters:
eSet - the Events set.

setInitialState

protected void setInitialState(S i0)
Sets the initial state. It casues the model to be reset. This method should be called only in a constructor.

Parameters:
i0 - The initial state.

getInitialState

protected S getInitialState()
returns the initial state.

Returns:
The initial state.

reset

public void reset()
Resets the Model. It erases all found states and transition rates. Keeps the initial state and Events set.


reset

protected void reset(boolean resetEvents)
Resets the Model. It erases all found states and transition rates.

Parameters:
resetEvents - whether the Events are deleted. WARNNING! if this is true you must call setEventSet.
See Also:
setInitialState(State), setEventSet(EventsSet)

resetResults

public void resetResults()
Resets the result of the model. If it has been generated this method keeps the Graph, but erases steady state, and transient probabilities.


activeTransitions

public abstract Transitions<S> activeTransitions(S i,
                                                 E e)
The user MUST implement this Function in order to describe the dynamics of the model. For the current state i, and on action e, the user has to describe the transtions that can occur. This implies finding all destination states and the rate at which the transtions occur. There is no guarantee that the event is active, so the user should check for this. If the event is not active an empty Transition element should be returned. A typical code for a queuing system should look like this: public abstract Transitions activeTransitions(MyState i, MyEvent e){ TransitionsSet trans = new TransitionsSet(); case (ARRIVAL) if (i.size() < capacity) trans.add(i.doArrival(), arrRate); break; case(DEPARTURE) if (i.size() >=1) trans.add(i.doDeparture, serviceRate); break; } return trans; }

Parameters:
i - The current State.
e - The ocurring event.
Returns:
The transitions that occur at this state when (and if) this events occurs.
See Also:
Transitions, TransitionsSet, Transitions

generate

public void generate()
generate() builds the space state and rate matrix using the algorithm BuildsSR. (See Ciardo, G. "Tools for formulating Markov Processes", chapter 2 in Grassman W. "Computational Probability". Kluwer). The states can be collected later with getStates and the rates can be accessed in disperse form with the method getRate(j) of every state. Alternatively the method getGenerator() and getRates() access the generator matriz or rate matrix in compact form.


getNumStates

public int getNumStates()
Return the number of States in the model. If the model has not been generated, then it will be automatically generated.

Returns:
the number of States in the model.

getStates

public StatesSet<S> getStates()
Returns an array with all the States in the model. It generates the model if it has not been generated.

Returns:
The States

getStates

public StatesSet<S> getStates(boolean causesGeneration)
Returns an array with the States in the model that have been checked so far. If generate is true it generates the model if it has not been generated. If no states have been generates it returns null.

Parameters:
causesGeneration - whether the model should be generated.
Returns:
ann array with the states found and checked so far.

getEvents

public E[] getEvents()
Returns all The events defined in the model.

Returns:
Events array

getRates

public Transitions<S> getRates(S i)
This method returns a dynamic data structure with the rate from State i to all reachable states.

Parameters:
i - State
Returns:
Rates to reachable states
See Also:
Transitions

getRate

public double getRate(S i,
                      S j)
Gets the current total rate form i to j. Warnning: If the model has not been generated id returns the current total rate, it does not causes the generation of the model. Run generate() first.

Parameters:
i - origin State
j - destination state
Returns:
total rate
See Also:
generate()

getFinalRate

public double getFinalRate(S i,
                           S j)
Gets the total rate form State number i to j. The number is relative to the ordered set of all states, therefore this method causes the model to be generated if it has not been generated.

Parameters:
i - origin State
j - destination state
Returns:
total rate
See Also:
getRate(State, State)

getRates

public double[][] getRates()
Returns the transition rates matrix R in dense format. It generates the model if it has not been generated.

Returns:
an array with the matrix.
See Also:
getRate(State, State), getRates(State), getMtjRates()

getMtjRates

public no.uib.cipr.matrix.Matrix getMtjRates()
Returns the transition rates matrix R in MTJ format. It generates the model if it has not been generated.

Returns:
an mt.Matrix with the matrix.

isGenerated

public boolean isGenerated()
Returns:
true if the model has been completely generated

getGenerator

public double[][] getGenerator()
Returns the infinitesimal generator matrix Q , in dense format. It generates the model if it has not been generated.

Returns:
The generator Matrix.

getMtjGenerator

public no.uib.cipr.matrix.Matrix getMtjGenerator()
The generator Q as an MTJ Matrix

Returns:
The matrix Q.

getSteadyState

public double[] getSteadyState()
                        throws NotUnichainException
Returns the steady state probabilities for this model. Theat is, it solves the balance equations. It returns an array of zeros if there is no unique solution.

Returns:
An array with the steady-state probabilities.
Throws:
NotUnichainException

getStateClass

public java.lang.Class getStateClass()
The Class for the states in this model.

Returns:
The class for the states

getEventClass

public java.lang.Class getEventClass()
The Class for the Events in the system.

Returns:
The event Class in the model

addMOP

public boolean addMOP(java.lang.String mopName)
This method declares the existance of a measure of performance (MOP). The MOP for every state is calculated in the class that extends the State class.

Parameters:
mopName - The name of the new MOP.
Returns:
true if the name already existed.

clearMOPs

public void clearMOPs()
Clear all MOPs defined in the system.


setMOPs

public void setMOPs(java.lang.String[] mopNames)
Sets the names of all MOPs (measures of performance).

Parameters:
mopNames -

getMOPNames

public java.lang.String[] getMOPNames()
Return all the names of defined MOPs.

Returns:
an array with all the MOP's defined.

getMOPsAvg

public double[] getMOPsAvg()
                    throws NotUnichainException
Returns an array with the average of all the steady state measures of performance. The order is the same as in getMOPNames.

Returns:
An array containing the values of all MOPs averages.
Throws:
NotUnichainException
See Also:
getMOPsMoment(int)

getMOPsMoment

public double[] getMOPsMoment(int m)
                       throws NotUnichainException
Returns an array with the m-th moment of all the steady state measures of performance. The order is the same as in getMOPNames.

Parameters:
m - the order of the moment desired. m=1 is the expected value.
Returns:
An array containing the values of all MOPs m-th moments.
Throws:
NotUnichainException

getMOPIndex

public int getMOPIndex(java.lang.String name)
Gets the index that correspond to this MOP.

Parameters:
name - MOP name
Returns:
The index of the MOP with this name

numMOPs

public int numMOPs()
Returns the number of defined Measures of performance (MOPs).

Returns:
the number of MOPs defined so far.

getMOPsAvg

public double getMOPsAvg(int mopNum)
                  throws NotUnichainException
Returns the steady state measures average of the MOP numbre mopNum.

Parameters:
mopNum - The Number of the MOP of the which the average is to be computed.
Returns:
The long run averagefor this MOP.
Throws:
NotUnichainException

getMOPsAvg

public double getMOPsAvg(java.lang.String mopName)
                  throws NotUnichainException
Returns the steady state measures average of the MOP with name mopName.

Parameters:
mopName - The name whose Averga is to be computed.
Returns:
The long run averagefor this MOP.
Throws:
NotUnichainException

getMOPsMoment

public double getMOPsMoment(int mopNum,
                            int m)
                     throws NotUnichainException
Returns the steady state measures m-th moment of the MOP number mopNum. m=1 is the long-run expected value, m=2 expected value of the square, etc.

Parameters:
mopNum - The number for the MOP
m - The value of m.
Returns:
The m-th moments for this MOP.
Throws:
NotUnichainException

getMOPsMoment

public double getMOPsMoment(java.lang.String mopName,
                            int m)
                     throws NotUnichainException
Returns the steady state measures m-th moment of the MOP with name mopName. m=1 is the long-run expected value.

Parameters:
mopName - The name of the MOP that is to be computed
m - Valu of the moment
Returns:
The m-th moments for this MOP.
Throws:
NotUnichainException

getMOPNames

public java.lang.String getMOPNames(int mopNum)
Return the names of the i-th MOP.

Parameters:
mopNum - The number i of the MOP
Returns:
The name of the i-th MOP.

MOPsToString

public java.lang.String MOPsToString()
Return a String description of all MOPs in steady state (it reports mean and standard deviation).

Returns:
A String description of all MOPs.

MOPsToString

public java.lang.String MOPsToString(int width,
                                     int decimals)
Return a String description of all MOPs in steady state (it reports mean and standard deviation).

Parameters:
width - the columns width
decimals - the number of decimals to use.
Returns:
String with a table representing MOPs names, means and standard deviations.

eventsRatesToString

public java.lang.String eventsRatesToString()
Return a string as eventsRatesToString, with width 8 and 4 decimals

Returns:
A string with the information.
See Also:
eventRatesToString(int,int)

eventRatesToString

public java.lang.String eventRatesToString(int width,
                                           int decimals)
Return a String as printed by printEventsrates

Parameters:
width - Maximum width for each number
decimals - Number of decimals
Returns:
A string with the valus of all Rates
See Also:
printEventsRates(PrintWriter,int,int)

printEventsRates

public void printEventsRates(java.io.PrintWriter out)
Prints a table reporting the steadystate occurrance of all events.

Parameters:
out - where the table will be printed.

printEventsRates

public void printEventsRates(java.io.PrintWriter out,
                             int width,
                             int decimals)
Prints a table reporting the steadystate occurrance of all events.

Parameters:
out - where the table will be printed.
width - The column width
decimals - The number of decimals to use.

getEventNames

public java.lang.String[] getEventNames()
Returns the defined events

Returns:
aan array with the names of all Events

getEventRate

public double getEventRate(int eNum)
                    throws NotUnichainException
Return the steadystate rate of occurrance of the Events number eNum.

Parameters:
eNum - The even number in the event set.
Returns:
an array for all the steady state rates. The order is that of the events set.
Throws:
NotUnichainException

getEventsRates

public double[] getEventsRates()
                        throws NotUnichainException
Return an array with the steadystate rate of occurrance of all the Events.

Returns:
an array for all the steady state rates. The order is that of the events set.
Throws:
NotUnichainException

printMOPs

public final void printMOPs()
Prints the Measures of performance (MOPS) on standard output.

See Also:
printMOPs(PrintWriter), printMOPs(PrintWriter, int, int)

printMOPs

public final void printMOPs(java.io.PrintWriter out)
Prints a String description of all MOPs in steady state (it reports mean and standard deviation), with a width of 10 and 5 decimal figures.

Parameters:
out - The printer where the MOPS will be printed.
See Also:
printMOPs(), printMOPs(PrintWriter, int, int)

printMOPs

public int printMOPs(java.io.PrintWriter out,
                     int width,
                     int decimals)
Prints a String description of all MOPs in steady state (it reports mean and standard deviation). You can override this method to print your own MOPs. You can call it in the first line like this public void printMOPs(PrintWriter out, int width, int decimals) { int namesWidth = super.printMOPs(out,width, decimals); // your oun code here: out.println(pad("Another MOP", namesWidth, false) + pad(Value, width, decimals); }

Parameters:
out - The printer where the MOPS will be printed.
width - the columns width
decimals - the number of decimals to use.
Returns:
The max width among the declared MOPs. You can use this to align nicely your own MOPs.
See Also:
printMOPs(PrintWriter), printMOPs(PrintWriter, int, int)

toString

public java.lang.String toString()
Description copied from interface: JMarkovElement
This method returns a short String used in the user interface to describe this element. It is highly recommended that every class calls label(), using the following code:
 public final String toString() {
     return label();
 }
 

Specified by:
toString in interface JMarkovElement
Overrides:
toString in class java.lang.Object
Returns:
A String label.
See Also:
JMarkovElement.label()

allToString

public java.lang.String allToString()
Retuns a String description of the model and solution.

Returns:
a String wit the information of printAll.
See Also:
printAll()

printAll

public void printAll()
Prints a description of the Model: the States and the Transition Matrix. If the model has less than 100 states it shows all states and transition matrix and steady state probabilities. Otherwise only the description, measures of performance and events rates are shown.

See Also:
allToString()

printAll

public void printAll(java.io.PrintWriter out)
Prints to the given PrintWriter a summary of the information related to this MarkovChain. The information is the same as as in the method printAll().

Parameters:
out -
See Also:
toString(), printAll()

denseMatrixToString

public java.lang.String denseMatrixToString()
Returns a String with a description of the Model: the States and the Transition Matrix. Its use is not recommended for large models.

Returns:
A string with the Matrix

denseMatrixToString

public java.lang.String denseMatrixToString(int width,
                                            int rateDecimals,
                                            boolean printZeros,
                                            boolean useGenerator)
Returns the Transition Matrix as a String. Its use is not recommended for large models.

Parameters:
width - The width of each column.
rateDecimals - The number of decimals for the rates.
printZeros - Whether zeros or blanks should be printed.
useGenerator - whether the generator matrix Q, rather than the rates matrix should be printed.
Returns:
A String description of the rates or generator matrix.

printDenseMatrix

public void printDenseMatrix(java.io.PrintWriter out)
Prints a the Transition Matrix. It will use default values for width and decimals. Its use is not recommended for large models.

Parameters:
out - The writer to write to.

printDenseMatrix

public void printDenseMatrix(java.io.PrintWriter out,
                             int width,
                             int rateDecimals,
                             boolean printZeros,
                             boolean useGenerator)
Prints a description of the Model using the given PrintWriter: the States and the Transition Matrix. Its use is not recommended for large models.

Parameters:
out - The writer to write to.
width - The width of each column.
rateDecimals - The number of decimals for the rates.
printZeros - Whether zeros or blanks should be printed.
useGenerator - whether the generator matrix Q, rather than the rates matrix should be printed.

printDenseMatrix

protected void printDenseMatrix(java.io.PrintWriter out,
                                int width,
                                int rateDecimals,
                                boolean printZeros,
                                boolean useGenerator,
                                int[] idx)
Prints a description of the Model using the given PrintWriter: the States and the Transition Matrix. Its use is not recommended for large models.

Parameters:
width - The width of each column.
rateDecimals - The number of decimals for the rates.
printZeros - Whether zeros or blanks should be printed.
useGenerator - whether the generator matrix Q, rather than the rates matrix should be printed.
idx - the indices of separators.

statesToString

public java.lang.String statesToString()
Prints a description of the States and the Equilibrium Probabilities.

Returns:
A String description of the States.

printStates

public void printStates(java.io.PrintWriter out)
Prints a description of the States and the Equilibrium Probabilities.

Parameters:
out - The writer to write to.

printStates

public void printStates(java.io.PrintWriter out,
                        int width,
                        int probDecimals)
Prints a description of the States and the Equilibrium Probabilities.

Parameters:
out - The writer to write to.
width - The width of each column.
probDecimals - The number of decimals for the probabilities.

description

public abstract java.lang.String description()
This method should be implemented by the subclass to give word description of the model. For example it should say: Queueing system with 2 servers and exponential arrivals with rate 50 per hour.

Specified by:
description in interface JMarkovElement
Returns:
A description of the Model
See Also:
JMarkovElement.label()

pad

protected java.lang.String pad(java.lang.String s,
                               int w)
pad fills with blanks up to width w

Parameters:
s - The String to print.
w - The width to pad up to.

pad

protected java.lang.String pad(java.lang.String s,
                               int w,
                               boolean right)
pad fills with blanks up to width w

Parameters:
s - The String to print.
w - The width to pad up to.
right - whether the string should be eligned to the right.

pad

protected java.lang.String pad(double v,
                               int w)
pad generates a string representing the double v, padded with spaces up to width w. *

Parameters:
v - The double to print.
w - The width to pad up to.

pad

protected java.lang.String pad(double v,
                               int w,
                               boolean right)
pad generates a string representing the double v, padded with spaces up to width w.

Parameters:
v - The double to print to print.
w - The width to pad up to.
right - whether the string should be eligned to the right.

pad

protected java.lang.String pad(double v,
                               int w,
                               int d)
pad fills with blanks up to width w. Alignment is to the right.

Parameters:
v - The number to print.
w - The width to pad up to.
d - number of decimals.

pad

protected java.lang.String pad(double v,
                               int w,
                               int d,
                               boolean right)
pad fills with blanks up to width w

Parameters:
v - The number to print.
w - The width to pad up to.
d - number of decimals.
right - whether the string should be eligned to the right.

statesLableMaxWidth

public int statesLableMaxWidth(int width)
Computes the maximum used by the state's labels.

Parameters:
width - minimum width acceptable.
Returns:
Max(width, max label).

hLine

protected java.lang.String hLine(int length)
Retuns an horizontal text line of the given length.

Parameters:
length -
Returns:
a horizontal line.

vLine

protected java.lang.String vLine()
Returns a text vertical line.

Returns:
vertical line.

setDebugReporter

public void setDebugReporter(DebugReporter reporter)
Sets the DebugReporter to use.

Parameters:
reporter - The reporter tah will capture the debug information.
See Also:
DebugReporter

getDebugReporter

public DebugReporter getDebugReporter()
Gets the DebugReporter currently in use.

Returns:
a DebugReporter where debug information is sent.
See Also:
DebugReporter

debug

public void debug(int level,
                  java.lang.String s)
Prints debug information with this importance level

Parameters:
level -
s - The message to send.

debug

public void debug(int level,
                  java.lang.String s,
                  boolean newline)
Prints debug information with this importance level

Parameters:
level - The level of importance (0=show always, 5= show on debug level is 5).
s - The message
newline - Whether a new line should be written.

debug

public void debug(int level,
                  java.lang.String s,
                  boolean newline,
                  boolean indent)
Prints debug information with this importance level

Parameters:
level - The level of importance (0=show always, 5= show on debug level is 5).
s - The string to write.
newline - Whether to use a new line.
indent - Whether it should indent according to level.

getDebugLevel

public int getDebugLevel()
Returns:
current debug level, where level=0 means no debug info and level = 4 verbose info.

setDebugLevel

public void setDebugLevel(int level)
Sets the debug level, where level=0 means no debug info, level = 5 verbose info.

Parameters:
level - New debug level

loadGUI

public void loadGUI()
Loads the Graphic User Interface (GUI) that represent this Markov Chain.


showGUI

public void showGUI()
Shows the Graphic User Interface (GUI) that represent this Markov Chain. It loads one if none has been defined.


hideGUI

public void hideGUI()
Hides the Graphic User Interface (GUI) that represent this Markov Chain if one is defined.


killGUI

public void killGUI()
Destroys the Graphic User Interface (GUI) that represent this Markov Chain if one is defined.


canGo

public boolean canGo()
Allos to stop model execution by graphica user interface.

Returns:
Used to check with the GUI if the user has requested to stop.

pause

public void pause()
Pauses the current execution of the model. This is called by the GUI.


go

public void go()
Runs the model, or resumes execution if it had been suspended. Its use is intended for Graphical User Interface(GUI). A standard user should use generate() instead.

See Also:
generate()

goStep

public void goStep()
Runs the model for a single step. Its use is intended for Graphical User Interface(GUI). A standard user should use generate() instead.

See Also:
generate(), go()

getStatus

public MarkovProcess.Status getStatus()
Returns the current status of the model.

Returns:
One of the constants IDLE, RUNNING, GENERATED, SUSPENDED, ERROR

getProgress

public long getProgress()
Return the number of states processed so far in the current process.

Returns:
the number of states processed so far.

getStatusMsg

public java.lang.String getStatusMsg()
Returns a String describing the current status of the model.

Returns:
a String describing the current status of the model.

getMaxStates

public long getMaxStates()
Returns:
the Maximum number of states to generate.

setMaxStates

public void setMaxStates(long num)
Sets the maximum number of states to generate. Increase this only if you are sure that your model has a big number od states. Your current License may prevent you from setting this number.

Parameters:
num - Maximum Number of States to generate.

getDefaultSteadyStateSolver

protected final SteadyStateSolver getDefaultSteadyStateSolver()
Returns the default SteadyStateSolver.

Returns:
the default SteadyStateSolver.

getSteadyStateSolver

public SteadyStateSolver getSteadyStateSolver()
The currently defined solver.

Returns:
Returns the steadyStateSolver.
See Also:
SteadyStateSolver

setSteadyStateSolver

public void setSteadyStateSolver(SteadyStateSolver steadyStateSolver)
Allows the user to set an alternate solver.

Parameters:
steadyStateSolver - The steadyStateSolver to set.
See Also:
SteadyStateSolver

getDefaultTransientSolver

protected TransientSolver getDefaultTransientSolver()
The default solver for transient state.

Returns:
Returns the default transientSolver.
See Also:
TransientSolver

getTransientSolver

public TransientSolver getTransientSolver()
The currently defined solver for transient state.

Returns:
Returns the transientSolver.
See Also:
TransientSolver

setTransientSolver

public void setTransientSolver(TransientSolver transientSolver)
Allows the user to set an alternate solver.

Parameters:
transientSolver - The transientSolver to set.
See Also:
TransientSolver

label

public java.lang.String label()
Returns the name of the model.

Specified by:
label in interface JMarkovElement
Returns:
The Name of this model.
See Also:
JMarkovElement.description()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable