jmarkov.basic

## Class Policy<S extends State,A extends Action>

- java.lang.Object
- - jmarkov.basic.Policy<S,A>

- Type Parameters:
    `S` - The states class
    `A` - Tha Action class

      public final class Policy<S extends State,A extends Action>
      extends java.lang.Object

  Policy is a set of "Decision Rules". It contains the Decision Rule for every stage t. When the problem has infinite horizon, only one decision rule is stored.
  Author:
    Andres Sarmiento, Germán Riaño

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Policy(DecisionRule d)` Creates a stationary policy with the given decition rule
    `Policy(int stages)` Creates a set with the given horizon.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `A` | `getAction(S i, int t)` Gets the action to be taken in state i at this stage t
    `DecisionRule<S,A>` | `getDecisionRule()`
    `DecisionRule<S,A>` | `getDecisionRule(int t)` Returns the decision rule for statge t
    `int` | `getHorizon()` Return the time horizon for this Ploicy.
    `void` | `print()` Prints the policy to the standard output
    `void` | `print(java.io.PrintWriter pw)` Prints the policy to the given PrintWriter.
    `void` | `setDecisionRule(DecisionRule<S,A> pol)` Sets a unique decision rule for the policy, for infinite horizon problems.
    `void` | `setDecisionRule(DecisionRule<S,A> dr, int t)` Sets a decision rule for stage t in the policy
    `java.lang.String` | `toString()` Gives the sting representation of this Policy

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Policy

          public Policy(int stages)

      Creates a set with the given horizon.
      Parameters:
        `stages` - The number of stages

    - #### Policy

          public Policy(DecisionRule d)

      Creates a stationary policy with the given decition rule
      Parameters:
        `d` - The rule

  - ### Method Detail

    - #### getHorizon

          public int getHorizon()

      Return the time horizon for this Ploicy.
      Returns:
        last stage where actions can be taken

    - #### setDecisionRule

          public void setDecisionRule(DecisionRule<S,A> dr,
                             int t)

      Sets a decision rule for stage t in the policy
      Parameters:
        `dr` - decision rule
        `t` - stage

    - #### setDecisionRule

          public void setDecisionRule(DecisionRule<S,A> pol)

      Sets a unique decision rule for the policy, for infinite horizon problems.
      Parameters:
        `pol` -

    - #### getDecisionRule

          public DecisionRule<S,A> getDecisionRule()

      Returns:
        the unique decision rule, for infinite horizon problems.

    - #### getDecisionRule

          public DecisionRule<S,A> getDecisionRule(int t)

      Returns the decision rule for statge t
      Parameters:
        `t` - stage.
      Returns:
        The decision rule for stage t.

    - #### getAction

          public A getAction(S i,
                    int t)

      Gets the action to be taken in state i at this stage t
      Parameters:
        `i` - The state
        `t` - The stage (time) at which action is to be taken.
      Returns:
        The action.

    - #### toString

          public java.lang.String toString()

      Gives the sting representation of this Policy
      Overrides:
        `toString` in class `java.lang.Object`

    - #### print

          public void print()

      Prints the policy to the standard output

    - #### print

          public void print(java.io.PrintWriter pw)

      Prints the policy to the given PrintWriter.
      Parameters:
        `pw` - print writer