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

java.lang.Object
  extended by jmdp.basic.DecisionRule<S,A>
All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<S,A>>

public final class DecisionRule<S extends State,A extends Action>
extends java.lang.Object
implements 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, German Riano - 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
 A getAction(S s)
           
 java.util.Map getDecisionRule()
           
 java.util.Iterator<java.util.Map.Entry<S,A>> iterator()
           
 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()
           
 java.lang.String toString()
          Gives the sting representation of this Rule
 
Methods inherited from class java.lang.Object
clone, equals, 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)
Parameters:
s - state
Returns:
the action corresponding to the given state

getDecisionRule

public java.util.Map getDecisionRule()
Returns:
the map in the decision rule

size

public int size()
Returns:
Amount of states linked to actions in the decision rule

iterator

public java.util.Iterator<java.util.Map.Entry<S,A>> iterator()
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()
Gives the sting representation of this Rule

Overrides:
toString in class java.lang.Object

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.