jmarkov.basic
Class PropertiesState

java.lang.Object
  extended by jmarkov.basic.State
      extended by jmarkov.basic.PropertiesState
All Implemented Interfaces:
java.lang.Comparable<State>, JMarkovElement, PropertiesElement

public class PropertiesState
extends State
implements PropertiesElement

The states are characterized by an array of integer-valued properties, whose meaning will change from implementation to implementation. The class must be extended.

Version:
1.0a
Author:
German Riaņo, Andres Sarmiento. Universidad de los Andes.

Field Summary
protected  int[] prop
          This array contains the properties that characterize the state.
 
Constructor Summary
PropertiesState(int K)
          Constructs a State charcterized by K properties.
PropertiesState(int[] properties)
          This creates a PropertiesState with the given array.
PropertiesState(int[] properties, boolean deepCopy)
          This creates a PropertiesState with the given array.
PropertiesState(PropertiesState s)
          Constructs a new State by cloning the given State.
 
Method Summary
 PropertiesElement clone()
           
 int compareTo(PropertiesState ps)
          Compares according to the internal properties in lexicographic order.
 int compareTo(State s)
          The method compareTo should be implemented in order to establish a total ordering among the States.
 void computeMOPs(MarkovProcess mp)
          By default it computes the long run average for each property.
 int getNumProps()
          Returns the number of properties in the array that characterize this element.
 int[] getProperties()
          Crates a copy of the properties array.
 int getProperty(int index)
          Gets the value of this property at this index.
 boolean isConsistent()
          It is strongly recommended that the user implements this method.
 java.lang.String label()
          Returns a string representation of this state in vector form.
protected  void setProperty(int index, int value)
          Sets the value of the property at the given index
 
Methods inherited from class jmarkov.basic.State
description, equals, getIndex, getMOP, getMOP, setMOP, setMOP, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmarkov.basic.JMarkovElement
description, equals, toString
 

Field Detail

prop

protected final int[] prop
This array contains the properties that characterize the state.

Constructor Detail

PropertiesState

public PropertiesState(int K)
Constructs a State charcterized by K properties. The original values of all the properties is 0.

Parameters:
K - Number of Properties

PropertiesState

public PropertiesState(int[] properties)
This creates a PropertiesState with the given array. WARNNING: the array is NOT internally copied, so it is assumed then NO changes are made to this array after it is given to the constructor.

Parameters:
properties - An integer valued array with the proerties that characterize this state.

PropertiesState

public PropertiesState(int[] properties,
                       boolean deepCopy)
This creates a PropertiesState with the given array.

Parameters:
properties - An integer valued array with the proerties that characterize this state.
deepCopy - true if the constructor should make a deep copy of the array. This causes some overhead but increased security.

PropertiesState

public PropertiesState(PropertiesState s)
Constructs a new State by cloning the given State. If you are extending PropertiesState you may want to include a code like:
 public YourState clone() {
     return new PropertiesState(this);
 }
 

Parameters:
s - A given State.
Method Detail

computeMOPs

public void computeMOPs(MarkovProcess mp)
By default it computes the long run average for each property. the user should override this method in order to compute more meaningful measures of performance.

Specified by:
computeMOPs in class State
Parameters:
mp - The model being solved.
See Also:
State.computeMOPs(MarkovProcess)

compareTo

public final int compareTo(State s)
Description copied from class: State
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>
Specified by:
compareTo in class State
Returns:
A positive integer if this is grater then j, negative if this is less then j and 0 if this == j.
See Also:
Comparable.compareTo(Object)

compareTo

public final int compareTo(PropertiesState ps)
Compares according to the internal properties in lexicographic order.

Parameters:
ps - The state to compare to
Returns:
+1,-1,0 depending on relative ordering.
See Also:
State.compareTo(State)

label

public java.lang.String label()
Returns a string representation of this state in vector form. The String will be in the form (p1,p2,..,pK). A Class implementing this Class could give a more meaningful description.

Specified by:
label in interface JMarkovElement
Specified by:
label in class State
Returns:
A shor String label that identifies the state.
See Also:
JMarkovElement.description()

getNumProps

public int getNumProps()
Description copied from interface: PropertiesElement
Returns the number of properties in the array that characterize this element.

Specified by:
getNumProps in interface PropertiesElement
Returns:
The number of properties.
See Also:
PropertiesElement.getNumProps()

getProperties

public final int[] getProperties()
Crates a copy of the properties array.

Specified by:
getProperties in interface PropertiesElement
Returns:
Returns the properties array.
See Also:
PropertiesElement.getProperties()

getProperty

public int getProperty(int index)
Description copied from interface: PropertiesElement
Gets the value of this property at this index.

Specified by:
getProperty in interface PropertiesElement
Returns:
the property at the given index
See Also:
PropertiesElement.getProperty(int)

setProperty

protected void setProperty(int index,
                           int value)
Sets the value of the property at the given index

Parameters:
index -
value -

clone

public PropertiesElement clone()
Specified by:
clone in interface PropertiesElement
Overrides:
clone in class java.lang.Object
See Also:
PropertiesElement.clone()

isConsistent

public boolean isConsistent()
It is strongly recommended that the user implements this method. If left unimplemented this method returns true.

Specified by:
isConsistent in class State
Returns:
true if the state is consistent.
See Also:
State.isConsistent()