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.,
Option s). |
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
Option
s.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
DPrint
public abstract void resetSolver()
MDPSolverInterface
resetSolver
in interface MDPSolverInterface
public void solverInit(Domain domain, RewardFunction rf, TerminalFunction tf, double gamma, HashableStateFactory hashingFactory)
MDPSolverInterface
solverInit
in interface MDPSolverInterface
domain
- 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)
MDPSolverInterface
Option
should be added using this method.addNonDomainReferencedAction
in interface MDPSolverInterface
a
- the action to add to the solverpublic void setActions(java.util.List<Action> actions)
MDPSolverInterface
setActions
in interface MDPSolverInterface
actions
- the actions the solver should use.public java.util.List<Action> getActions()
MDPSolverInterface
Option
s). Modifying
the returned list will not modify the action list this solver uses.getActions
in interface MDPSolverInterface
List
of all actions this solver uses.public TerminalFunction getTF()
MDPSolverInterface
TerminalFunction
this solver uses.getTF
in interface MDPSolverInterface
TerminalFunction
this solver uses.public RewardFunction getRF()
MDPSolverInterface
RewardFunction
this solver uses.getRF
in interface MDPSolverInterface
RewardFunction
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 void setRf(RewardFunction rf)
MDPSolverInterface
setRf
in interface MDPSolverInterface
rf
- the reward function to be used by this solverpublic void setTf(TerminalFunction tf)
MDPSolverInterface
setTf
in interface MDPSolverInterface
tf
- the terminal function to be used by this solverpublic 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(Domain domain)
MDPSolverInterface
MDPSolverInterface.addNonDomainReferencedAction(burlap.oomdp.singleagent.Action)
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 RewardFunction getRf()
MDPSolverInterface
RewardFunction
this solver uses.getRf
in interface MDPSolverInterface
RewardFunction
this solver uses.public TerminalFunction getTf()
MDPSolverInterface
TerminalFunction
this solver uses.getTf
in interface MDPSolverInterface
TerminalFunction
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.