jmarkov
Class State

java.lang.Object
  extended by jmarkov.State
All Implemented Interfaces:
java.lang.Comparable<State>
Direct Known Subclasses:
GeomRelState, GeomState, PropertiesState

public abstract class State
extends java.lang.Object
implements java.lang.Comparable<State>

The Class State represent a state in a MarkovProcess. The user of the class should estiblish her own coding convention AND code the compareTo method. If the State can be represented with a vector of integers describing its properties, then it might be easier to implement PropertiesState rather than State.

Version:
1.0a
Author:
German Riaņo. Universidad de los Andes.
See Also:
PropertiesState class

Constructor Summary
State()
           
 
Method Summary
protected  boolean addMOPName(java.lang.String mopName)
          Define a new Measure of Performance (MOP).
 void clearMOPs()
           
abstract  int compareTo(State j)
          The method compareTo should be implemented in order to establish a total ordering among the States.
abstract  void computeMOPs()
          This method should be implemented in order to compute all the measures of performance MOPs.
 java.lang.String description()
          Returns a String that describes the State.
 boolean equals(java.lang.Object o)
           
 double getMOP(int index)
          Gets the value of this MOP.
 double getMOP(java.lang.String mopName)
          Gets the value of the MOP with this name.
protected  int getMOPIndex(java.lang.String name)
           
protected  java.lang.String[] getMOPNames()
           
protected  java.lang.String getMOPNames(int i)
           
 int getNum()
           
 java.util.SortedMap<State,java.lang.Double> getRates()
          Gets the rate from this State to all other States.
 double getRateToState(State j)
          Gets the rate from this State to State j
abstract  java.lang.String label()
          Returns a (hopefully short) label that descibes the State.
protected  java.util.ArrayList<java.lang.String> mopsNames()
          Returns the MOP names for this particular class that extends State.
protected  int numMOPNames()
           
 int setMOP(int index, double value)
          Sets the value of this MOP.
 int setMOP(java.lang.String mopName, double value)
          Sets the value of the MP with this name.
protected  void setMOPNames(java.lang.String[] mopNames)
          Sets the name of all measures of performance.
 void setRateToState(State j, double newVal)
          Sets the rate from this State to State j
 java.lang.String toString()
          Returns the label.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

State

public State()
Method Detail

getRateToState

public double getRateToState(State j)
Gets the rate from this State to State j

Parameters:
j - Destination State

getRates

public java.util.SortedMap<State,java.lang.Double> getRates()
Gets the rate from this State to all other States. The returned data structure allows you to find the rates to all rechable states through cycles like the following
         double val;
         Double valObj; 
         for (State j: i.getRates().keySet()) {
             valObj = (Double)i.getRates().get(j);
             val =  valObj.doubleValue()
             // val is the rate from i to j
             // do something 
         }
 

Returns:
Data structure with rates.

setRateToState

public void setRateToState(State j,
                           double newVal)
Sets the rate from this State to State j


compareTo

public abstract int compareTo(State j)
The method compareTo should be implemented in order to establish a total ordering among the States.

Specified by:
compareTo in interface java.lang.Comparable<State>
Returns:
A positive integer if this is grater then j, negative if this is less then j and 0 if this==j.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

mopsNames

protected java.util.ArrayList<java.lang.String> mopsNames()
Returns the MOP names for this particular class that extends State.


addMOPName

protected boolean addMOPName(java.lang.String mopName)
Define a new Measure of Performance (MOP). Examples of Measures of Performance are QueueLenghts, server status, etc.

Parameters:
mopName -
Returns:
true if the MOP was already defined.

setMOPNames

protected void setMOPNames(java.lang.String[] mopNames)
Sets the name of all measures of performance.

Parameters:
mopNames - an array with all names.

getMOPNames

protected java.lang.String[] getMOPNames()
Returns:
an array with all existing MOP names.

getMOPNames

protected java.lang.String getMOPNames(int i)
Returns:
The name of the i-th MOP

getMOPIndex

protected int getMOPIndex(java.lang.String name)
Returns:
The index of the MOP with this name

numMOPNames

protected int numMOPNames()
Returns:
the number of MOPs defined so far.

setMOP

public int setMOP(int index,
                  double value)
Sets the value of this MOP. If the index is not valid it is added at the end of the list with name "_MOP_" + index.

Parameters:
index -
value -
Returns:
the index where it was added.

setMOP

public int setMOP(java.lang.String mopName,
                  double value)
Sets the value of the MP with this name. I no MOP with this name exists a new one is declared.

Parameters:
mopName -
value -
Returns:
the index where it was added.

getMOP

public double getMOP(java.lang.String mopName)
Gets the value of the MOP with this name. The value should had been set via the setMOP methods, or you can override this method.

Parameters:
mopName -
Returns:
current mOP value

computeMOPs

public abstract void computeMOPs()
This method should be implemented in order to compute all the measures of performance MOPs. Inside it you should issue commands like setMop("Utilization server 1", x);


getMOP

public double getMOP(int index)
Gets the value of this MOP. The value should had been set via the setMOP methods, or you can override this method.

Parameters:
index -
Returns:
The value of this MOP.

clearMOPs

public void clearMOPs()

label

public abstract java.lang.String label()
Returns a (hopefully short) label that descibes the State. It is used by all print methods and in the GUI.


description

public java.lang.String description()
Returns a String that describes the State. By default it is an empty string, but you should implement it in order to get a meaningful description.


toString

public final java.lang.String toString()
Returns the label.

Overrides:
toString in class java.lang.Object
See Also:
label()

getNum

public int getNum()
Returns:
The number in the State set