examples.jmdp

## Class CowHerd

- java.lang.Object
- - jmarkov.jmdp.MDP<S,A>
  - - jmarkov.jmdp.FiniteMDP<S,A>
    - - jmarkov.jmdp.FiniteDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>
      - - examples.jmdp.CowHerd

-     public class CowHerd
      extends FiniteDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>

  The cow herd problem. Given the prices on a horizon decide whether keep or sell the cow herd. There is a max number of cows per period. If you keep the cows there will be about 1.5 times the current number of cows in the next period.
  Author:
    Germán Riaño

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CowHerd(int initialQuantity, int horizon, double[] price, int[] mxCows)` Builds a cow Herd problem with the given initial cows.
    `CowHerd(States<examples.jmdp.CowQuantity> initial, int horizon, double[] price, int[] mxCows)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `examples.jmdp.CowQuantity` | `destination(examples.jmdp.CowQuantity i, examples.jmdp.CowActions a, int t)` State where the system will end up if action a is taken from state i at time t.
    `Actions<examples.jmdp.CowActions>` | `feasibleActions(examples.jmdp.CowQuantity st, int t)` Returns the actions available at this state i and at this stage t .
    `double` | `finalCost(examples.jmdp.CowQuantity i)` This method returns the cost incurred if the last stage ends with the system at state i.
    `double` | `getValue(int initQ)`
    `double` | `immediateCost(examples.jmdp.CowQuantity i, examples.jmdp.CowActions a, int t)` This function must return the Immediate cost incurred when taking action a from state i
    `static void` | `main(java.lang.String[] a)` Small test program

    - ### Methods inherited from class jmarkov.jmdp.FiniteDP

      `prob, reachable`

    - ### Methods inherited from class jmarkov.jmdp.FiniteMDP

      `defaultFinalCost, getHorizon, getStates`

    - ### Methods inherited from class jmarkov.jmdp.MDP

      `debug, debug, debug, getDebugLevel, getOptimalPolicy, getOptimalValueFunction, getReporter, getSolver, isFinite, isSolved, operation, printSolution, printSolution, setDebugLevel, setReporter, setSolver, solve`

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

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

- - ### Constructor Detail

    - #### CowHerd

          public CowHerd(States<examples.jmdp.CowQuantity> initial,
                 int horizon,
                 double[] price,
                 int[] mxCows)

      Parameters:
        `initial` -
        `horizon` -
        `price` -
        `mxCows` -

    - #### CowHerd

          public CowHerd(int initialQuantity,
                 int horizon,
                 double[] price,
                 int[] mxCows)

      Builds a cow Herd problem with the given initial cows.
      Parameters:
        `initialQuantity` -
        `horizon` -
        `price` -
        `mxCows` -

  - ### Method Detail

    - #### getValue

          public double getValue(int initQ)
                          throws SolverException

      Parameters:
        `initQ` -
      Returns:
        The optimal value fir this initial quantity
      Throws:
        `SolverException`

    - #### immediateCost

          public double immediateCost(examples.jmdp.CowQuantity i,
                             examples.jmdp.CowActions a,
                             int t)

      Description copied from class: `FiniteMDP`
      This function must return the Immediate cost incurred when taking action a from state i
      Specified by:
        `immediateCost` in class `FiniteMDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>`
      Parameters:
        `i` - Current state
        `a` - Action
        `t` - Current time stage
      Returns:
        Cost value

    - #### finalCost

          public double finalCost(examples.jmdp.CowQuantity i)

      Description copied from class: `FiniteMDP`
      This method returns the cost incurred if the last stage ends with the system at state i. The user must extend this method.
      Specified by:
        `finalCost` in class `FiniteMDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>`
      Parameters:
        `i` - Ending state
      Returns:
        Cost.

    - #### destination

          public examples.jmdp.CowQuantity destination(examples.jmdp.CowQuantity i,
                                              examples.jmdp.CowActions a,
                                              int t)

      Description copied from class: `FiniteDP`
      State where the system will end up if action a is taken from state i at time t. The user must implement this method.
      Specified by:
        `destination` in class `FiniteDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>`
      Parameters:
        `i` - Current state
        `a` - Current action
        `t` - Time stage.
      Returns:
        Destination states
      See Also:
        `FiniteDP.destination(State , Action , int)`

    - #### feasibleActions

          public Actions<examples.jmdp.CowActions> feasibleActions(examples.jmdp.CowQuantity st,
                                                          int t)

      Description copied from class: `FiniteMDP`
      Returns the actions available at this state i and at this stage t . The user must implement this method.
      Specified by:
        `feasibleActions` in class `FiniteMDP<examples.jmdp.CowQuantity,examples.jmdp.CowActions>`
      Parameters:
        `st` - Current State
        `t` - Time stage
      Returns:
        Set of feasible actions.

    - #### main

          public static void main(java.lang.String[] a)
                           throws SolverException

      Small test program
      Parameters:
        `a` - Not used
      Throws:
        `SolverException`