examples.jmdp

## Class CattleGrowth

- java.lang.Object
- - jmarkov.jmdp.MDP<S,A>
  - - jmarkov.jmdp.FiniteMDP<examples.jmdp.AnimalWeight,examples.jmdp.AnimalActions>
    - - examples.jmdp.CattleGrowth

-     public class CattleGrowth
      extends FiniteMDP<examples.jmdp.AnimalWeight,examples.jmdp.AnimalActions>

  The Cattle Growth problem represent a male cattle, the states represent the weight at different ages. This problem decide whether keep, sell or give forage to the animal in order to maximize the profit of his future sell, by minimizing the cost of feeding it. The weight of each animal in the next state depends on the transition probabilities matrix (one for each action taken at each stage).
  Author:
    Ana Karina Maroso, Germán Riaño

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CattleGrowth(int[] initialWeight, int horizon, double[][][] keep, double[][][] forage, double[] preciomx, double forageCost)` Builds a cattle Weight problem with the given initial weight.
    `CattleGrowth(int[] initialWeight, int horizon, java.lang.String keepFile, java.lang.String forageFile, double[] preciomx, double forageCost)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Actions<examples.jmdp.AnimalActions>` | `feasibleActions(examples.jmdp.AnimalWeight st, int t)` Returns the actions available at this state i and at this stage t .
    `double` | `finalCost(examples.jmdp.AnimalWeight i)` This method returns the cost incurred if the last stage ends with the system at state i.
    `double` | `getValue(int initWeight)`
    `double` | `immediateCost(examples.jmdp.AnimalWeight i, examples.jmdp.AnimalActions a, int t)` This function must return the Immediate cost incurred when taking action a from state i
    `static Jama.Matrix` | `loadJamaMatrix(java.lang.String fileName)`
    `static void` | `main(java.lang.String[] a)` Small test program
    `double` | `prob(examples.jmdp.AnimalWeight pesoactual, examples.jmdp.AnimalWeight pesofuturo, examples.jmdp.AnimalActions a, int t)` This is the probability of going from state i to state j by taking the action a at stage t.
    `States<examples.jmdp.AnimalWeight>` | `reachable(examples.jmdp.AnimalWeight arg0, examples.jmdp.AnimalActions arg1, int t)` Set of States that can be reached from this state i, at this stage t, after taking the acton a.

    - ### 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

    - #### CattleGrowth

          public CattleGrowth(int[] initialWeight,
                      int horizon,
                      double[][][] keep,
                      double[][][] forage,
                      double[] preciomx,
                      double forageCost)

      Builds a cattle Weight problem with the given initial weight.
      Parameters:
        `initialWeight` -
        `horizon` -
        `keep` -
        `forage` -
        `preciomx` -
        `forageCost` -

    - #### CattleGrowth

          public CattleGrowth(int[] initialWeight,
                      int horizon,
                      java.lang.String keepFile,
                      java.lang.String forageFile,
                      double[] preciomx,
                      double forageCost)
                       throws java.io.FileNotFoundException,
                              java.io.IOException

      Parameters:
        `initialWeight` -
        `horizon` -
        `keepFile` -
        `forageFile` -
        `preciomx` -
        `forageCost` -
      Throws:
        `java.io.IOException`
        `java.net.URISyntaxException`
        `java.io.FileNotFoundException`

  - ### Method Detail

    - #### finalCost

          public double finalCost(examples.jmdp.AnimalWeight 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.AnimalWeight,examples.jmdp.AnimalActions>`
      Parameters:
        `i` - Ending state
      Returns:
        Cost.
      See Also:
        `FiniteMDP.finalCost(jmarkov.basic.State)`

    - #### getValue

          public double getValue(int initWeight)
                          throws SolverException

      Parameters:
        `initWeight` -
      Returns:
        The optimal value for this initial weight
      Throws:
        `SolverException`

    - #### immediateCost

          public double immediateCost(examples.jmdp.AnimalWeight i,
                             examples.jmdp.AnimalActions 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.AnimalWeight,examples.jmdp.AnimalActions>`
      Parameters:
        `i` - Current state
        `a` - Action
        `t` - Current time stage
      Returns:
        Cost value

    - #### feasibleActions

          public Actions<examples.jmdp.AnimalActions> feasibleActions(examples.jmdp.AnimalWeight 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.AnimalWeight,examples.jmdp.AnimalActions>`
      Parameters:
        `st` - Current State
        `t` - Time stage
      Returns:
        Set of feasible actions.

    - #### prob

          public double prob(examples.jmdp.AnimalWeight pesoactual,
                    examples.jmdp.AnimalWeight pesofuturo,
                    examples.jmdp.AnimalActions a,
                    int t)

      Description copied from class: `FiniteMDP`
      This is the probability of going from state i to state j by taking the action a at stage t.
      Specified by:
        `prob` in class `FiniteMDP<examples.jmdp.AnimalWeight,examples.jmdp.AnimalActions>`
      Parameters:
        `pesoactual` - Current state
        `pesofuturo` - Destination state
        `a` - Action taken
        `t` - Current time stage
      Returns:
        Probability

    - #### reachable

          public States<examples.jmdp.AnimalWeight> reachable(examples.jmdp.AnimalWeight arg0,
                                                     examples.jmdp.AnimalActions arg1,
                                                     int t)

      Description copied from class: `FiniteMDP`
      Set of States that can be reached from this state i, at this stage t, after taking the acton a. The user must implement this method.
      Specified by:
        `reachable` in class `FiniteMDP<examples.jmdp.AnimalWeight,examples.jmdp.AnimalActions>`
      Parameters:
        `arg0` - Current state
        `arg1` - Action taken
        `t` - Time stage
      Returns:
        Set of reachable states.

    - #### loadJamaMatrix

          public static Jama.Matrix loadJamaMatrix(java.lang.String fileName)
                                            throws java.io.IOException

      Parameters:
        `fileName` - Name of the text file with the data
      Returns:
        A jama Matrix with the data
      Throws:
        `java.io.IOException`
        `java.net.URISyntaxException`
        `java.io.IOException`

    - #### main

          public static void main(java.lang.String[] a)
                           throws SolverException,
                                  java.io.FileNotFoundException,
                                  java.net.URISyntaxException,
                                  java.io.IOException

      Small test program
      Parameters:
        `a` - Not used
      Throws:
        `SolverException`
        `java.io.IOException`
        `java.net.URISyntaxException`
        `java.io.FileNotFoundException`