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<Action> |
actions
The list of actions this solver can use.
|
protected int |
debugCode
The debug code use for calls to
DPrint |
protected Domain |
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 java.util.Map<HashableState,HashableState> |
mapToStateIndex
A mapping to internal stored hashed states (
HashableState) that are stored. |
protected RewardFunction |
rf
The task reward function
|
protected TerminalFunction |
tf
The terminal function for identifying terminal states
|
| Constructor and Description |
|---|
MDPSolver() |
| Modifier and Type | Method and Description |
|---|---|
void |
addNonDomainReferencedAction(Action a)
Adds an additional action the solver that is not included in the domain definition.
|
java.util.List<Action> |
getActions()
Returns a copy of all actions this solver uses for reasoning; including added actions that are not part of the
domain specification (e.g.,
Options). |
protected java.util.List<GroundedAction> |
getAllGroundedActions(State s)
Returns all grounded actions in the provided state for all the actions that this valueFunction can use.
|
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. |
RewardFunction |
getRf()
Returns the
RewardFunction this solver uses. |
RewardFunction |
getRF()
Returns the
RewardFunction this solver uses. |
TerminalFunction |
getTf()
Returns the
TerminalFunction this solver uses. |
TerminalFunction |
getTF()
Returns the
TerminalFunction this solver uses. |
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 |
setActions(java.util.List<Action> actions)
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(Domain 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 |
setRf(RewardFunction rf)
Sets the reward function used by this solver
|
void |
setTf(TerminalFunction tf)
Sets the terminal state function used by this solver
|
void |
solverInit(Domain domain,
RewardFunction rf,
TerminalFunction tf,
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 GroundedAction |
translateAction(GroundedAction a,
java.util.Map<java.lang.String,java.lang.String> matching)
Takes a source GroundedAction and a matching between object instances of two different states and returns a GroundedAction
with parameters using the matched parameters if the GroundedAction is an instance of
AbstractObjectParameterizedGroundedAction. |
protected Domain domain
protected HashableStateFactory hashingFactory
protected RewardFunction rf
protected TerminalFunction tf
protected double gamma
protected java.util.List<Action> actions
Options.protected java.util.Map<HashableState,HashableState> mapToStateIndex
HashableState) that are stored.
Useful since two identical states may have different object instance name identifiers
that can affect the parameters in GroundedActions.protected int debugCode
DPrintpublic abstract void resetSolver()
MDPSolverInterfaceresetSolver in interface MDPSolverInterfacepublic void solverInit(Domain domain, RewardFunction rf, TerminalFunction tf, double gamma, HashableStateFactory hashingFactory)
MDPSolverInterfacesolverInit in interface MDPSolverInterfacedomain - the domain to be solved.rf - the reward functiontf - the terminal state functiongamma - the MDP discount factorhashingFactory - the hashing factory used to store states (may be set to null if the solver is not tabular)public void addNonDomainReferencedAction(Action a)
MDPSolverInterfaceOption
should be added using this method.addNonDomainReferencedAction in interface MDPSolverInterfacea - the action to add to the solverpublic void setActions(java.util.List<Action> actions)
MDPSolverInterfacesetActions in interface MDPSolverInterfaceactions - the actions the solver should use.public java.util.List<Action> getActions()
MDPSolverInterfaceOptions). Modifying
the returned list will not modify the action list this solver uses.getActions in interface MDPSolverInterfaceList of all actions this solver uses.public TerminalFunction getTF()
MDPSolverInterfaceTerminalFunction this solver uses.getTF in interface MDPSolverInterfaceTerminalFunction this solver uses.public RewardFunction getRF()
MDPSolverInterfaceRewardFunction this solver uses.getRF in interface MDPSolverInterfaceRewardFunction this solver uses.public void setHashingFactory(HashableStateFactory hashingFactory)
MDPSolverInterfaceHashableStateFactory used to hash states for tabular solvers.setHashingFactory in interface MDPSolverInterfacehashingFactory - the HashableStateFactory used to hash states for tabular solvers.public HashableStateFactory getHashingFactory()
MDPSolverInterfaceHashableStateFactory this solver uses.getHashingFactory in interface MDPSolverInterfaceHashableStateFactory this solver uses.public void setRf(RewardFunction rf)
MDPSolverInterfacesetRf in interface MDPSolverInterfacerf - the reward function to be used by this solverpublic void setTf(TerminalFunction tf)
MDPSolverInterfacesetTf in interface MDPSolverInterfacetf - the terminal function to be used by this solverpublic double getGamma()
MDPSolverInterfacegetGamma in interface MDPSolverInterfacepublic void setGamma(double gamma)
MDPSolverInterfacesetGamma in interface MDPSolverInterfacegamma - the discount factor used by this solverpublic void setDebugCode(int code)
MDPSolverInterfaceDPrintsetDebugCode in interface MDPSolverInterfacecode - the code to be used by DPrintpublic int getDebugCode()
MDPSolverInterfaceDPrintgetDebugCode in interface MDPSolverInterfaceDPrintpublic void toggleDebugPrinting(boolean toggle)
MDPSolverInterfaceDPrint should be printed.toggleDebugPrinting in interface MDPSolverInterfacetoggle - whether to print the calls to DPrintpublic void setDomain(Domain domain)
MDPSolverInterfaceMDPSolverInterface.addNonDomainReferencedAction(burlap.oomdp.singleagent.Action)
method, you will have to do so again.setDomain in interface MDPSolverInterfacedomain - the domain this solver should use.public Domain getDomain()
MDPSolverInterfaceDomain this solver solves.getDomain in interface MDPSolverInterfaceDomain this solver solves.public RewardFunction getRf()
MDPSolverInterfaceRewardFunction this solver uses.getRf in interface MDPSolverInterfaceRewardFunction this solver uses.public TerminalFunction getTf()
MDPSolverInterfaceTerminalFunction this solver uses.getTf in interface MDPSolverInterfaceTerminalFunction this solver uses.protected GroundedAction translateAction(GroundedAction a, java.util.Map<java.lang.String,java.lang.String> matching)
AbstractObjectParameterizedGroundedAction.
This method is useful a stored state and action pair in the valueFunction data structure has different
object name identifiers than a query state that is otherwise identical. The matching is from the state in which the source action is applied
to some target state that is not provided to this method.a - the source action that needs to be translatedmatching - a map from object instance names to other object instance names.public HashableState stateHash(State s)
s - the state to hashprotected java.util.List<GroundedAction> getAllGroundedActions(State s)
s - the source state for which to get all GroundedActions.