|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjmarkov.MarkovProcess<S,E>
S
- The State class for the model.E
- The Event class for the model.public abstract class MarkovProcess<S extends State,E extends Event>
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.
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 |
---|
protected int cnt
protected StatesSet<S extends State> theStates
protected java.lang.String name
description().
- See Also:
description()
protected SteadyStateSolver defaultSteadyStateSolver
protected TransientSolver defaultTransientSolver
Constructor Detail |
---|
public MarkovProcess(S i0, EventsSet<E> eSet, java.lang.String name)
i0
- The initial State.eSet
- The set of all Events.name
- The name of the Model.public MarkovProcess(S i0, EventsSet<E> eSet)
i0
- The initial State.eSet
- The set of all Events.protected MarkovProcess()
Method Detail |
---|
protected void setEventSet(EventsSet<E> eSet)
eSet
- the Events set.protected void setInitialState(S i0)
i0
- The initial state.protected S getInitialState()
public void reset()
protected void reset(boolean resetEvents)
resetEvents
- whether the Events are deleted. WARNNING! if
this is true you must call setEventSet.setInitialState(State)
,
setEventSet(EventsSet)
public void resetResults()
public abstract Transitions<S> activeTransitions(S i, E e)
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;
}
i
- The current State.e
- The ocurring event.
Transitions
,
TransitionsSet
,
Transitions
public void generate()
getRate(j)
of every state.
Alternatively the method getGenerator()
and
getRates()
access the generator matriz or rate
matrix in compact form.
public int getNumStates()
public StatesSet<S> getStates()
public StatesSet<S> getStates(boolean causesGeneration)
generate
is true it generates
the model if it has not been generated. If no states have been
generates it returns null.
causesGeneration
- whether the model should be generated.
public E[] getEvents()
public Transitions<S> getRates(S i)
i
- State
Transitions
public double getRate(S i, S j)
generate()
first.
i
- origin Statej
- destination state
generate()
public double getFinalRate(S i, S j)
i
- origin Statej
- destination state
getRate(State, State)
public double[][] getRates()
getRate(State, State)
,
getRates(State)
,
getMtjRates()
public no.uib.cipr.matrix.Matrix getMtjRates()
public boolean isGenerated()
public double[][] getGenerator()
public no.uib.cipr.matrix.Matrix getMtjGenerator()
public double[] getSteadyState() throws NotUnichainException
NotUnichainException
public java.lang.Class getStateClass()
public java.lang.Class getEventClass()
public boolean addMOP(java.lang.String mopName)
mopName
- The name of the new MOP.
public void clearMOPs()
public void setMOPs(java.lang.String[] mopNames)
mopNames
- public java.lang.String[] getMOPNames()
public double[] getMOPsAvg() throws NotUnichainException
NotUnichainException
getMOPsMoment(int)
public double[] getMOPsMoment(int m) throws NotUnichainException
m
- the order of the moment desired. m=1 is the expected
value.
NotUnichainException
public int getMOPIndex(java.lang.String name)
name
- MOP name
public int numMOPs()
public double getMOPsAvg(int mopNum) throws NotUnichainException
mopNum
- The Number of the MOP of the which the average is
to be computed.
NotUnichainException
public double getMOPsAvg(java.lang.String mopName) throws NotUnichainException
mopName
- The name whose Averga is to be computed.
NotUnichainException
public double getMOPsMoment(int mopNum, int m) throws NotUnichainException
mopNum
- The number for the MOPm
- The value of m.
NotUnichainException
public double getMOPsMoment(java.lang.String mopName, int m) throws NotUnichainException
mopName
- The name of the MOP that is to be computedm
- Valu of the moment
NotUnichainException
public java.lang.String getMOPNames(int mopNum)
mopNum
- The number i of the MOP
public java.lang.String MOPsToString()
public java.lang.String MOPsToString(int width, int decimals)
width
- the columns widthdecimals
- the number of decimals to use.
public java.lang.String eventsRatesToString()
eventRatesToString(int,int)
public java.lang.String eventRatesToString(int width, int decimals)
width
- Maximum width for each numberdecimals
- Number of decimals
printEventsRates(PrintWriter,int,int)
public void printEventsRates(java.io.PrintWriter out)
out
- where the table will be printed.public void printEventsRates(java.io.PrintWriter out, int width, int decimals)
out
- where the table will be printed.width
- The column widthdecimals
- The number of decimals to use.public java.lang.String[] getEventNames()
public double getEventRate(int eNum) throws NotUnichainException
eNum
- The even number in the event set.
NotUnichainException
public double[] getEventsRates() throws NotUnichainException
NotUnichainException
public final void printMOPs()
printMOPs(PrintWriter)
,
printMOPs(PrintWriter, int, int)
public final void printMOPs(java.io.PrintWriter out)
out
- The printer where the MOPS will be printed.printMOPs()
,
printMOPs(PrintWriter, int, int)
public int printMOPs(java.io.PrintWriter out, int width, int decimals)
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);
}
out
- The printer where the MOPS will be printed.width
- the columns widthdecimals
- the number of decimals to use.
printMOPs(PrintWriter)
,
printMOPs(PrintWriter, int, int)
public java.lang.String toString()
JMarkovElement
public final String toString() { return label(); }
toString
in interface JMarkovElement
toString
in class java.lang.Object
JMarkovElement.label()
public java.lang.String allToString()
printAll()
public void printAll()
allToString()
public void printAll(java.io.PrintWriter out)
printAll()
.
out
- toString()
,
printAll()
public java.lang.String denseMatrixToString()
public java.lang.String denseMatrixToString(int width, int rateDecimals, boolean printZeros, boolean useGenerator)
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.
public void printDenseMatrix(java.io.PrintWriter out)
out
- The writer to write to.public void printDenseMatrix(java.io.PrintWriter out, int width, int rateDecimals, boolean printZeros, boolean useGenerator)
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.protected void printDenseMatrix(java.io.PrintWriter out, int width, int rateDecimals, boolean printZeros, boolean useGenerator, int[] idx)
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.public java.lang.String statesToString()
public void printStates(java.io.PrintWriter out)
out
- The writer to write to.public void printStates(java.io.PrintWriter out, int width, int probDecimals)
out
- The writer to write to.width
- The width of each column.probDecimals
- The number of decimals for the
probabilities.public abstract java.lang.String description()
description
in interface JMarkovElement
JMarkovElement.label()
protected java.lang.String pad(java.lang.String s, int w)
s
- The String to print.w
- The width to pad up to.protected java.lang.String pad(java.lang.String s, int w, boolean right)
s
- The String to print.w
- The width to pad up to.right
- whether the string should be eligned to the right.protected java.lang.String pad(double v, int w)
v
- The double to print.w
- The width to pad up to.protected java.lang.String pad(double v, int w, boolean right)
v
- The double to print to print.w
- The width to pad up to.right
- whether the string should be eligned to the right.protected java.lang.String pad(double v, int w, int d)
v
- The number to print.w
- The width to pad up to.d
- number of decimals.protected java.lang.String pad(double v, int w, int d, boolean right)
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.public int statesLableMaxWidth(int width)
width
- minimum width acceptable.
protected java.lang.String hLine(int length)
length
-
protected java.lang.String vLine()
public void setDebugReporter(DebugReporter reporter)
reporter
- The reporter tah will capture the debug
information.DebugReporter
public DebugReporter getDebugReporter()
DebugReporter
public void debug(int level, java.lang.String s)
level
- s
- The message to send.public void debug(int level, java.lang.String s, boolean newline)
level
- The level of importance (0=show always, 5= show on
debug level is 5).s
- The messagenewline
- Whether a new line should be written.public void debug(int level, java.lang.String s, boolean newline, boolean indent)
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.public int getDebugLevel()
public void setDebugLevel(int level)
level
- New debug levelpublic void loadGUI()
public void showGUI()
public void hideGUI()
public void killGUI()
public boolean canGo()
public void pause()
public void go()
generate()
instead.
generate()
public void goStep()
generate()
instead.
generate()
,
go()
public MarkovProcess.Status getStatus()
public long getProgress()
public java.lang.String getStatusMsg()
public long getMaxStates()
public void setMaxStates(long num)
num
- Maximum Number of States to generate.protected final SteadyStateSolver getDefaultSteadyStateSolver()
public SteadyStateSolver getSteadyStateSolver()
SteadyStateSolver
public void setSteadyStateSolver(SteadyStateSolver steadyStateSolver)
steadyStateSolver
- The steadyStateSolver to set.SteadyStateSolver
protected TransientSolver getDefaultTransientSolver()
TransientSolver
public TransientSolver getTransientSolver()
TransientSolver
public void setTransientSolver(TransientSolver transientSolver)
transientSolver
- The transientSolver to set.TransientSolver
public java.lang.String label()
label
in interface JMarkovElement
JMarkovElement.description()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |