examples.jmdp.solvers

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

- java.lang.Object
- - jmarkov.jmdp.solvers.Solver<S,A>
  - - jmarkov.jmdp.solvers.AbstractInfiniteSolver<S,A>
    - - jmarkov.jmdp.solvers.AbstractDiscountedSolver<S,A>
      - - jmarkov.jmdp.solvers.MpsLpDiscountedSolver<S,A>
        - - examples.jmdp.solvers.MPSXpressDiscounted<S,A>

- Type Parameters:
    `S` -
    `A` -
  All Implemented Interfaces:
    JMarkovElement, LPSolver<S,A>, MpsLpSolver<S,A>

      public class MPSXpressDiscounted<S extends State,A extends Action>
      extends MpsLpDiscountedSolver<S,A>

  This solver solves a discounted infinite horizon MDP by building and solving a linear problem using as interface Xpress-Optimizer. It requires the professional version of XpressMP.
  Author:
    Diego Bello, Germán Riaño - Universidad de Los Andes (C) 2005

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MPSXpressDiscounted(DTMDP<S,A> problem, double interestRate)` This is the default constructor for MPSXpressDiscounted class, and defines the path for the working directory equals to the MPS folder tied to the project.
    `MPSXpressDiscounted(DTMDP<S,A> problem, double interestRate, java.lang.String workingDir, java.lang.String fileName)` The constructor method receives a problem of the type infinite DTMDP, an interest rate, and the working directory and file name that the user wants as path for MPS Files and solutions from Xpress-Optimizer.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Solution<S,A>` | `buildSolution()` A solution provided for a MPS File by Xpress-Optmizer has the next framework.
    `void` | `closeFile()` Close the MPS File
    `java.io.File` | `createCommandsFile()` creates a File wit the XPress commands: readprob minim writesol quit
    `long` | `getIterations()`
    `java.lang.String` | `label()` The sub classes must return the Solver name.
    `void` | `openFile()`
    `void` | `setShowXpressOutput(boolean showXpressOutput)` St this to true if you want to capture Xpress output.
    `boolean` | `showXpressOutput()` Returns true if the solver the captures the Xpress o
    `void` | `solveLP()` This is where the actual solving takes place.

    - ### Methods inherited from class jmarkov.jmdp.solvers.MpsLpDiscountedSolver

      `getBuildTime, getLpSolveTime, getMpsFile, getMpsFileName, getProcessTime, getSolBuildTime, getWorkingDir, isAvg, solve`

    - ### Methods inherited from class jmarkov.jmdp.solvers.AbstractDiscountedSolver

      `getInterestRate, setInterestRate`

    - ### Methods inherited from class jmarkov.jmdp.solvers.AbstractInfiniteSolver

      `getProblem, printSolution`

    - ### Methods inherited from class jmarkov.jmdp.solvers.Solver

      `description, getOptimalPolicy, getOptimalValueFunction, getValueFunction, isSolved, printSolution, setPrintProcessTime, setPrintValueFunction, toString`

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

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

    - ### Methods inherited from interface jmarkov.basic.JMarkovElement

      `equals`

- - ### Constructor Detail

    - #### MPSXpressDiscounted

          public MPSXpressDiscounted(DTMDP<S,A> problem,
                             double interestRate,
                             java.lang.String workingDir,
                             java.lang.String fileName)

      The constructor method receives a problem of the type infinite DTMDP, an interest rate, and the working directory and file name that the user wants as path for MPS Files and solutions from Xpress-Optimizer.
      Parameters:
        `problem` - the structure of the problem of type infinite DTMDP.
        `interestRate` - A rate which is paid for the use of a resource.
        `workingDir` - The path where will be saved and read the MPS file.
        `fileName` - The MPS file name to create.

    - #### MPSXpressDiscounted

          public MPSXpressDiscounted(DTMDP<S,A> problem,
                             double interestRate)

      This is the default constructor for MPSXpressDiscounted class, and defines the path for the working directory equals to the MPS folder tied to the project. The constructor method exclusively receives a problem of the type infinite DTMDP , an interest rate that is modified for being used as discount factor.
      Parameters:
        `problem` - the structure of the problem of type infinite DTMDP.
        `interestRate` - A rate which is paid for the use of a resource.

  - ### Method Detail

    - #### getIterations

          public long getIterations()

      Specified by:
        `getIterations` in class `AbstractInfiniteSolver<S extends State,A extends Action>`
      Returns:
        Returns the iterations in the last solve.

    - #### solveLP

          public void solveLP()
                       throws SolverException

      This is where the actual solving takes place. The builder is used to manipulate the MPS file. A reader is returned thah can be use to build the solution.
      Specified by:
        `solveLP` in interface `LPSolver<S extends State,A extends Action>`
      Specified by:
        `solveLP` in class `MpsLpDiscountedSolver<S extends State,A extends Action>`
      Throws:
        `SolverException`

    - #### createCommandsFile

          public java.io.File createCommandsFile()
                                          throws java.io.IOException

      creates a File wit the XPress commands:

           readprob
           minim
           writesol
           quit

      Returns:
        a File with the commands to be read by XPress
      Throws:
        `java.io.IOException`

    - #### label

          public java.lang.String label()

      Description copied from class: `Solver`
      The sub classes must return the Solver name.
      Specified by:
        `label` in interface `JMarkovElement`
      Specified by:
        `label` in class `Solver<S extends State,A extends Action>`
      Returns:
        A String label.
      See Also:
        `Solver.toString()`

    - #### showXpressOutput

          public boolean showXpressOutput()

      Returns true if the solver the captures the Xpress o
      Returns:
        Returns true if the solver the captures the Xpress output.

    - #### setShowXpressOutput

          public void setShowXpressOutput(boolean showXpressOutput)

      St this to true if you want to capture Xpress output.
      Parameters:
        `showXpressOutput` - true if Xpress output is to be captured.

    - #### openFile

          public void openFile()
                        throws SolverException

      Throws:
        `SolverException`
      See Also:
        `MpsLpDiscountedSolver`

    - #### closeFile

          public void closeFile()

      Close the MPS File

    - #### buildSolution

          public Solution<S,A> buildSolution()
                                                                   throws SolverException

      A solution provided for a MPS File by Xpress-Optmizer has the next framework. The columns are separated by commas, the names are enclosed in inverted commas. For the Rows the most important information is the name that is located in field 2 and the dual value, field 9. For the columns the most important informations is given in field 2, Name and in field 5, the value.
      Specified by:
        `buildSolution` in interface `LPSolver<S extends State,A extends Action>`
      Specified by:
        `buildSolution` in class `MpsLpDiscountedSolver<S extends State,A extends Action>`
      Returns:
        The solution to the problem.
      Throws:
        `SolverException`