jmarkov.basic
Class DecisionRule<S extends State,A extends Action>

java.lang.Object
  extended by jmarkov.basic.DecisionRule<S,A>
Type Parameters:
S - The states class
A - Tha Action class
All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<S,A>>, JMarkovElement

public final class DecisionRule<S extends State,A extends Action>
extends java.lang.Object
implements JMarkovElement, java.lang.Iterable<java.util.Map.Entry<S,A>>

This class represents a deterministic decision rule which assigns an action to every state.

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

Constructor Summary
DecisionRule()
          Creates a new empty decision rule
DecisionRule(DecisionRule<S,A> dr)
          Creates a decision rule from a given one
 
Method Summary
 java.lang.String description()
          Gives the sting representation of this Rule
 boolean equals(java.lang.Object o)
          Determines if the given decision rules are equal.
 A getAction(S s)
          Gets the prescribed action for the given State.
 java.util.Iterator<java.util.Map.Entry<S,A>> iterator()
          Return an iterator over the State-Action pairs.
 java.lang.String label()
          This method returns a short String used in the user interface to describe this element.
 void print()
          Prints the Rule to the sandard output
 void print(java.io.PrintWriter pw)
          Prints the policiy to the given PrintWriter.
 void print(java.io.PrintWriter pw, java.lang.String statesFormat, java.lang.String actionFormat)
          Prints the policiy to the given PrintWriter.
 void set(S s, A a)
          Maps a given action to a given state
 int size()
          Returns the amount of states linked to actions in the decision rule.
 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DecisionRule

public DecisionRule()
Creates a new empty decision rule


DecisionRule

public DecisionRule(DecisionRule<S,A> dr)
Creates a decision rule from a given one

Parameters:
dr - decision rule
Method Detail

set

public void set(S s,
                A a)
Maps a given action to a given state

Parameters:
s - state
a - action

getAction

public A getAction(S s)
Gets the prescribed action for the given State.

Parameters:
s - state
Returns:
the action corresponding to the given state

size

public int size()
Returns the amount of states linked to actions in the decision rule.

Returns:
Amount of states linked to actions in the decision rule.

iterator

public java.util.Iterator<java.util.Map.Entry<S,A>> iterator()
Return an iterator over the State-Action pairs.

Specified by:
iterator in interface java.lang.Iterable<java.util.Map.Entry<S extends State,A extends Action>>
Returns:
iterator over the entries

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

equals

public boolean equals(java.lang.Object o)
Determines if the given decision rules are equal.

Specified by:
equals in interface JMarkovElement
Overrides:
equals in class java.lang.Object
Parameters:
o -
Returns:
True, if the decision rules are equal.
See Also:
Object.equals(java.lang.Object)

description

public java.lang.String description()
Gives the sting representation of this Rule

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

print

public void print()
Prints the Rule to the sandard output


print

public void print(java.io.PrintWriter pw)
Prints the policiy to the given PrintWriter.

Parameters:
pw - PrintWriter to use

print

public void print(java.io.PrintWriter pw,
                  java.lang.String statesFormat,
                  java.lang.String actionFormat)
Prints the policiy to the given PrintWriter.

Parameters:
pw - PrintWriter to use
statesFormat - format for the states , for example "%-10S" to have 10 width left aligned states.
actionFormat - format for the actions , for example "%-10S" to have 10 width left aligned actions.