jmarkov.basic
Class ValueFunction<S extends State>

java.lang.Object
  extended by jmarkov.basic.ValueFunction<S>
Type Parameters:
S - States set.
All Implemented Interfaces:
JMarkovElement

public class ValueFunction<S extends State>
extends java.lang.Object
implements JMarkovElement

This structure matches each state with a double number representing its value function, or in some cases the steady state probabilities.

Author:
Andres Sarmiento and Germán Riaño - Universidad de Los Andes

Constructor Summary
ValueFunction()
          Creates a new empty value function.
ValueFunction(java.lang.String name)
          Creates a new empty value function.
ValueFunction(ValueFunction<S> vf)
          Creates a value function from another given value function
ValueFunction(ValueFunction<S> vf, java.lang.String name)
          Creates a value function from another given value function
 
Method Summary
 java.lang.String description()
          This method return a complete verbal describtion of this element.
 double[] get()
          Gets an array with all the values represented in this value function.
 double get(S s)
          Gets the Value associted with this State.
 java.util.Iterator<java.util.Map.Entry<S,java.lang.Double>> iterator()
          Return an iterator used to wakl through the Value Function.
 java.lang.String label()
          This method returns a short String used in the user interface to describe this element.
 void print(java.io.PrintWriter pw)
          Prints the Value Function.
 void print(java.io.PrintWriter pw, java.lang.String statesFormat, java.lang.String valuesFormat)
          Prints the Value function with the given state format , and values format according to the Format String Syntax.
 void set(S s, double val)
          Associates a state and a double value
 java.lang.String toString()
          This method returns a short String used in the user interface to describe this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmarkov.basic.JMarkovElement
equals
 

Constructor Detail

ValueFunction

public ValueFunction()
Creates a new empty value function.


ValueFunction

public ValueFunction(ValueFunction<S> vf)
Creates a value function from another given value function

Parameters:
vf - value function

ValueFunction

public ValueFunction(java.lang.String name)
Creates a new empty value function.

Parameters:
name - The name for thei value function

ValueFunction

public ValueFunction(ValueFunction<S> vf,
                     java.lang.String name)
Creates a value function from another given value function

Parameters:
vf - value function
name - The name for this value function.
Method Detail

set

public void set(S s,
                double val)
Associates a state and a double value

Parameters:
s - state
val - value

iterator

public java.util.Iterator<java.util.Map.Entry<S,java.lang.Double>> iterator()
Return an iterator used to wakl through the Value Function.

Returns:
iterator over the entries of the map

get

public double get(S s)
Gets the Value associted with this State.

Parameters:
s - given state
Returns:
the double value corresponding to the state

get

public double[] get()
Gets an array with all the values represented in this value function.

Returns:
an array with the values

print

public void print(java.io.PrintWriter pw,
                  java.lang.String statesFormat,
                  java.lang.String valuesFormat)
Prints the Value function with the given state format , and values format according to the Format String Syntax.

Parameters:
pw -
statesFormat - format for the states , for example "%-10S" to have 10 width left aligned states.
valuesFormat - format to use for values. For example us "%6.2" to have 6 width and 2 decimals.
See Also:
Formatter

print

public void print(java.io.PrintWriter pw)
Prints the Value Function. It uses default states and values format.

Parameters:
pw -

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()

label

public java.lang.String label()
Description copied from interface: JMarkovElement
This method returns a short String used in the user interface to describe this element.

Specified by:
label in interface JMarkovElement
Returns:
A String label.
See Also:
JMarkovElement.description()

description

public java.lang.String description()
Description copied from interface: JMarkovElement
This method return a complete verbal describtion of this element. This description may contain multiple text rows.

Specified by:
description in interface JMarkovElement
Returns:
A String describing this element.
See Also:
JMarkovElement.label()