public abstract class MDPSolver extends java.lang.Object implements MDPSolverInterface
MDPSolverInterface
and provides
the common data members and method implementations that most all algorithms will need to use
and provides methods for manipulating them that are common.Modifier and Type | Field and Description |
---|---|
protected java.util.List<ActionType> |
actionTypes
The list of actions this solver can use.
|
protected int |
debugCode
The debug code use for calls to
DPrint |
protected SADomain |
domain
The domain to solve
|
protected double |
gamma
The MDP discount factor
|
protected HashableStateFactory |
hashingFactory
The hashing factory to use for hashing states in tabular solvers
|
protected SampleModel |
model |
protected boolean |
usingOptionModel |
Constructor and Description |
---|
MDPSolver() |
Modifier and Type | Method and Description |
---|---|
void |
addActionType(ActionType a)
Adds an additional action the solver that is not included in the domain definition.
|
protected java.util.List<Action> |
applicableActions(State s)
Returns all applicable actions in the provided state for all the actions that this MDP Solver can use.
|
java.util.List<ActionType> |
getActionTypes()
Returns a copy of all actions this solver uses for reasoning; including added actions that are not part of the
domain specification (e.g.,
Option s). |
int |
getDebugCode()
Returns the debug code used by this solver for calls to
DPrint |
Domain |
getDomain()
Returns the
Domain this solver solves. |
double |
getGamma()
Returns gamma, the discount factor used by this solver
|
HashableStateFactory |
getHashingFactory()
Returns the
HashableStateFactory this solver uses. |
SampleModel |
getModel()
Returns the model being used by this solver
|
abstract void |
resetSolver()
This method resets all solver results so that a solver can be restarted fresh
as if had never solved the MDP.
|
void |
setActionTypes(java.util.List<ActionType> actionTypes)
Sets the action set the solver should use.
|
void |
setDebugCode(int code)
Sets the debug code to be used by calls to
DPrint |
void |
setDomain(SADomain domain)
Sets the domain of this solver.
|
void |
setGamma(double gamma)
Sets gamma, the discount factor used by this solver
|
void |
setHashingFactory(HashableStateFactory hashingFactory)
Sets the
HashableStateFactory used to hash states for tabular solvers. |
void |
setModel(SampleModel model)
Sets the model to use for this solver
|
void |
solverInit(SADomain domain,
double gamma,
HashableStateFactory hashingFactory)
Initializes the solver with the common elements.
|
HashableState |
stateHash(State s)
A shorthand method for hashing a state.
|
void |
toggleDebugPrinting(boolean toggle)
Toggles whether the solver's calls to
DPrint should be printed. |
protected SADomain domain
protected SampleModel model
protected HashableStateFactory hashingFactory
protected double gamma
protected java.util.List<ActionType> actionTypes
Option
s.protected int debugCode
DPrint
protected boolean usingOptionModel
public abstract void resetSolver()
MDPSolverInterface
resetSolver
in interface MDPSolverInterface
public void solverInit(SADomain domain, double gamma, HashableStateFactory hashingFactory)
MDPSolverInterface
solverInit
in interface MDPSolverInterface
domain
- the domain to be solved.gamma
- the MDP discount factorhashingFactory
- the hashing factory used to store states (may be set to null if the solver is not tabular)public void addActionType(ActionType a)
MDPSolverInterface
Option
should be added using this method.addActionType
in interface MDPSolverInterface
a
- the action to add to the solverpublic void setModel(SampleModel model)
MDPSolverInterface
setModel
in interface MDPSolverInterface
model
- the model to usepublic SampleModel getModel()
MDPSolverInterface
getModel
in interface MDPSolverInterface
SampleModel
public void setActionTypes(java.util.List<ActionType> actionTypes)
MDPSolverInterface
setActionTypes
in interface MDPSolverInterface
actionTypes
- the actions the solver should use.public java.util.List<ActionType> getActionTypes()
MDPSolverInterface
Option
s). Modifying
the returned list will not modify the action list this solver uses.getActionTypes
in interface MDPSolverInterface
List
of all actions this solver uses.public void setHashingFactory(HashableStateFactory hashingFactory)
MDPSolverInterface
HashableStateFactory
used to hash states for tabular solvers.setHashingFactory
in interface MDPSolverInterface
hashingFactory
- the HashableStateFactory
used to hash states for tabular solvers.public HashableStateFactory getHashingFactory()
MDPSolverInterface
HashableStateFactory
this solver uses.getHashingFactory
in interface MDPSolverInterface
HashableStateFactory
this solver uses.public double getGamma()
MDPSolverInterface
getGamma
in interface MDPSolverInterface
public void setGamma(double gamma)
MDPSolverInterface
setGamma
in interface MDPSolverInterface
gamma
- the discount factor used by this solverpublic void setDebugCode(int code)
MDPSolverInterface
DPrint
setDebugCode
in interface MDPSolverInterface
code
- the code to be used by DPrint
public int getDebugCode()
MDPSolverInterface
DPrint
getDebugCode
in interface MDPSolverInterface
DPrint
public void toggleDebugPrinting(boolean toggle)
MDPSolverInterface
DPrint
should be printed.toggleDebugPrinting
in interface MDPSolverInterface
toggle
- whether to print the calls to DPrint
public void setDomain(SADomain domain)
MDPSolverInterface
MDPSolverInterface.addActionType(ActionType)
method, you will have to do so again.setDomain
in interface MDPSolverInterface
domain
- the domain this solver should use.public Domain getDomain()
MDPSolverInterface
Domain
this solver solves.getDomain
in interface MDPSolverInterface
Domain
this solver solves.public HashableState stateHash(State s)
s
- the state to hashprotected java.util.List<Action> applicableActions(State s)
ActionType
s not included in the domain added (e.g., types for Option
s),
this method will include those as well.s
- the source state for which to get all GroundedActions.