jmarkov.jmdp.solvers
Class MpsLpDiscountedSolver<S extends State,A extends Action>

java.lang.Object
  extended by jmarkov.jmdp.solvers.Solver<S,A>
      extended by jmarkov.jmdp.solvers.AbstractInfiniteSolver<S,A>
          extended by jmarkov.jmdp.solvers.AbstractDiscountedSolver<S,A>
              extended by jmarkov.jmdp.solvers.MpsLpDiscountedSolver<S,A>
Type Parameters:
S - States class.
A - Actions class.
All Implemented Interfaces:
JMarkovElement, LPSolver<S,A>, MpsLpSolver<S,A>

public abstract class MpsLpDiscountedSolver<S extends State,A extends Action>
extends AbstractDiscountedSolver<S,A>
implements MpsLpSolver<S,A>

This class builds a Linear Program for a discounted infinite horizon MDP in a MPS file. A extending class must code solveLP method in order to solve the problem.

Author:
Diego Bello, Germán Riaño - Universidad de Los Andes (C) 2005
See Also:
solveLP()

Field Summary
 
Fields inherited from class jmarkov.jmdp.solvers.AbstractDiscountedSolver
discountFactor
 
Fields inherited from class jmarkov.jmdp.solvers.Solver
policy, printProcessTime, printValueFunction, problem, solved, valueFunction
 
Constructor Summary
  MpsLpDiscountedSolver(DTMDP<S,A> problem, double interestRate)
          This is the default constructor for MpsLpDiscountedSolver class, and defines the label MDP for the MPS File.
protected MpsLpDiscountedSolver(DTMDP<S,A> problem, double interestRate, boolean isAverage)
          The constructor is used by the partner average solver.
  MpsLpDiscountedSolver(DTMDP<S,A> problem, double interestRate, java.lang.String workingDir, java.lang.String fileName)
          The constructor method exclusively receives a problem of the type infinite DTMDP , an interest rate that is modified for being used as discount factor and the name that the user wants for the MPS File.
protected MpsLpDiscountedSolver(DTMDP<S,A> problem, double interestRate, java.lang.String workingDir, java.lang.String fileName, boolean isAverage)
          The constructor is used by the partenr average solver.
 
Method Summary
abstract  Solution<S,A> buildSolution()
          The implementator classes should override this class to build the solution after the model has been solved.
 long getBuildTime()
          Returns the time taken to build and write the MPS file.
 long getLpSolveTime()
          Return the time taken to solve the LP model.
 java.io.File getMpsFile()
          Returns the MPS file name.
 java.lang.String getMpsFileName()
          Returns the MPS file name.
 long getProcessTime()
           
 long getSolBuildTime()
          Returns the time needed to build the Solution after the LP was solved.
 java.io.File getWorkingDir()
          Returns the working directory (where the MPS file is located)
 boolean isAvg()
           
 Solution<S,A> solve()
          Called to solve the problem.
abstract  void solveLP()
          The implementator classes should override this class to solve the problem using the mpsFile that has been created.
 
Methods inherited from class jmarkov.jmdp.solvers.AbstractDiscountedSolver
future, future, getInterestRate, setDiscountFactor, setInterestRate
 
Methods inherited from class jmarkov.jmdp.solvers.AbstractInfiniteSolver
getDiscreteProblem, getIterations, getProblem, printSolution
 
Methods inherited from class jmarkov.jmdp.solvers.Solver
description, getOptimalPolicy, getOptimalValueFunction, getValueFunction, isSolved, label, printSolution, setPrintProcessTime, setPrintValueFunction, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jmarkov.basic.JMarkovElement
equals
 

Constructor Detail

MpsLpDiscountedSolver

public MpsLpDiscountedSolver(DTMDP<S,A> problem,
                             double interestRate,
                             java.lang.String workingDir,
                             java.lang.String fileName)
The constructor method exclusively receives a problem of the type infinite DTMDP , an interest rate that is modified for being used as discount factor and the name that the user wants for the MPS File.

Parameters:
problem - The structure of the problem of type infinite DTMDP.
interestRate - A rate which is paid for the use of a resource.
workingDir - Where the MPS file will be created.
fileName - Name for the MPS File (with no path).

MpsLpDiscountedSolver

public MpsLpDiscountedSolver(DTMDP<S,A> problem,
                             double interestRate)
This is the default constructor for MpsLpDiscountedSolver class, and defines the label MDP for the MPS File. 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.

MpsLpDiscountedSolver

protected MpsLpDiscountedSolver(DTMDP<S,A> problem,
                                double interestRate,
                                java.lang.String workingDir,
                                java.lang.String fileName,
                                boolean isAverage)
The constructor is used by the partenr average solver.

Parameters:
problem - The structure of the problem of type infinite DTMDP.
interestRate - A rate which is paid for the use of a resource.
workingDir - Where the MPS file will be created.
fileName - Name for the MPS File (with no path).
isAverage - True if an average model is being built.

MpsLpDiscountedSolver

protected MpsLpDiscountedSolver(DTMDP<S,A> problem,
                                double interestRate,
                                boolean isAverage)
The constructor is used by the partner average solver.

Parameters:
problem - The structure of the problem of type infinite DTMDP.
interestRate - A rate which is paid for the use of a resource.
isAverage - True if an average model is being built.
Method Detail

getMpsFileName

public final java.lang.String getMpsFileName()
Description copied from interface: MpsLpSolver
Returns the MPS file name.

Specified by:
getMpsFileName in interface MpsLpSolver<S extends State,A extends Action>
Returns:
Returns the MPS File Name.

getMpsFile

public java.io.File getMpsFile()
Description copied from interface: MpsLpSolver
Returns the MPS file name.

Specified by:
getMpsFile in interface MpsLpSolver<S extends State,A extends Action>
Returns:
Returns the mpsFile.

getWorkingDir

public final java.io.File getWorkingDir()
Returns the working directory (where the MPS file is located)

Specified by:
getWorkingDir in interface MpsLpSolver<S extends State,A extends Action>
Returns:
Returns the MPS File folder.

isAvg

public final boolean isAvg()
Returns:
Returns the true if an Average problem is being solved.

solveLP

public abstract void solveLP()
                      throws SolverException
The implementator classes should override this class to solve the problem using the mpsFile that has been created.

Specified by:
solveLP in interface LPSolver<S extends State,A extends Action>
Throws:
SolverException

buildSolution

public abstract Solution<S,A> buildSolution()
                                                                  throws SolverException
The implementator classes should override this class to build the solution after the model has been solved.

Specified by:
buildSolution in interface LPSolver<S extends State,A extends Action>
Returns:
The solution to the problem.
Throws:
SolverException

solve

public final Solution<S,A> solve()
                                                       throws SolverException
Description copied from class: Solver
Called to solve the problem. This method MUST write the local variable policy and valueFunction.

Specified by:
solve in class Solver<S extends State,A extends Action>
Returns:
The solution Object taht contains the plicy and value fuenction.
Throws:
SolverException - This exception is thrown if the solver cannot find a solution for some reason.

getBuildTime

public final long getBuildTime()
Description copied from interface: LPSolver
Returns the time taken to build and write the MPS file.

Specified by:
getBuildTime in interface LPSolver<S extends State,A extends Action>
Returns:
Returns the buildTime.

getLpSolveTime

public final long getLpSolveTime()
Description copied from interface: LPSolver
Return the time taken to solve the LP model.

Specified by:
getLpSolveTime in interface LPSolver<S extends State,A extends Action>
Returns:
Returns the lpSolveTime.

getSolBuildTime

public final long getSolBuildTime()
Description copied from interface: LPSolver
Returns the time needed to build the Solution after the LP was solved.

Specified by:
getSolBuildTime in interface LPSolver<S extends State,A extends Action>
Returns:
Returns the solBuildTime.

getProcessTime

public final long getProcessTime()
Specified by:
getProcessTime in class Solver<S extends State,A extends Action>
Returns:
Returns the processTime of the last solve. Use System.currentTimeMillis() to get the current time.