public class DFS extends DeterministicPlanner
If a terminal function is provided via the setter method defined for OO-MDPs, then the search algorithm will not expand any nodes that are terminal states, as if there were no actions that could be executed from that state. Note that terminal states are not necessarily the same as goal states, since there could be a fail condition from which the agent cannot act, but that is not explicitly represented in the transition dynamics.
DeterministicPlanner.PlanningFailedException
Modifier and Type | Field and Description |
---|---|
protected boolean |
maintainClosed
Whether to keep track of a closed list to prevent exploring already seen nodes.
|
protected int |
maxDepth
The max depth of the search tree that will be explored.
|
protected int |
numVisted
Planning statistic for keeping track of how many nodes DFS expanded.
|
protected boolean |
optionsFirst
Whether to explore paths generated by options first
|
protected java.util.Random |
rand
A random object for random walks
|
gc, internalPolicy
actionTypes, debugCode, domain, gamma, hashingFactory, model, usingOptionModel
Constructor and Description |
---|
DFS(SADomain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory)
Basic constructor for standard DFS without a depth limit
|
DFS(SADomain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory,
int maxDepth)
Basic constructor for standard DFS with a depth limit
|
DFS(SADomain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory,
int maxDepth,
boolean maintainClosed)
Constructor of DFS with specification of depth limit and whether to maintain a closed list that affects exploration.
|
DFS(SADomain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory,
int maxDepth,
boolean maintainClosed,
boolean optionsFirst)
Constructor of DFS with specification of depth limit, whether to maintain a closed list that affects exploration, and whether paths
generated by options should be explored first.
|
Modifier and Type | Method and Description |
---|---|
protected SearchNode |
dfs(SearchNode n,
int depth,
java.util.Set<HashableState> statesOnPath)
Runs DFS from a given search node, keeping track of its current depth.
|
protected void |
DFSInit(SADomain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory,
int maxDepth,
boolean maintainClosed,
boolean optionsFirst)
Constructor of DFS with specification of depth limit, whether to maintain a closed list that affects exploration, and whether paths
generated by options should be explored first.
|
int |
getNumVisited()
Returns the number of search nodes visited/expanded.
|
protected int |
numOptionsInGAs(java.util.List<Action> gas)
Returns the number of options present in a list of possible actions.
|
SDPlannerPolicy |
planFromState(State initialState)
Plans and returns a
SDPlannerPolicy . |
void |
resetSolver()
This method resets all solver results so that a solver can be restarted fresh
as if had never solved the MDP.
|
void |
setOptionsFirst()
Sets the valueFunction to explore nodes generated by options first.
|
protected void |
shuffleGroundedActions(java.util.List<Action> gas,
int s,
int e)
Shuffles the order of actions on the index range [s, e)
|
protected void |
sortActionsWithOptionsFirst()
Reorders the planners action list so that options are in the front of the list.
|
deterministicPlannerInit, encodePlanIntoPolicy, hasCachedPlanForState, planContainsOption, planHasDupilicateStates, querySelectedActionForState
addActionType, applicableActions, getActionTypes, getDebugCode, getDomain, getGamma, getHashingFactory, getModel, setActionTypes, setDebugCode, setDomain, setGamma, setHashingFactory, setModel, solverInit, stateHash, toggleDebugPrinting
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addActionType, getActionTypes, getDebugCode, getDomain, getGamma, getHashingFactory, getModel, setActionTypes, setDebugCode, setDomain, setGamma, setHashingFactory, setModel, solverInit, toggleDebugPrinting
protected int maxDepth
protected boolean maintainClosed
protected boolean optionsFirst
protected java.util.Random rand
protected int numVisted
public DFS(SADomain domain, StateConditionTest gc, HashableStateFactory hashingFactory)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usepublic DFS(SADomain domain, StateConditionTest gc, HashableStateFactory hashingFactory, int maxDepth)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usemaxDepth
- depth limit of DFS. -1 specifies no limit.public DFS(SADomain domain, StateConditionTest gc, HashableStateFactory hashingFactory, int maxDepth, boolean maintainClosed)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usemaxDepth
- depth limit of DFS. -1 specifies no limit.maintainClosed
- whether to maintain a closed list or notpublic DFS(SADomain domain, StateConditionTest gc, HashableStateFactory hashingFactory, int maxDepth, boolean maintainClosed, boolean optionsFirst)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usemaxDepth
- depth limit of DFS. -1 specifies no limit.maintainClosed
- whether to maintain a closed list or notoptionsFirst
- whether to explore paths generated by options first.protected void DFSInit(SADomain domain, StateConditionTest gc, HashableStateFactory hashingFactory, int maxDepth, boolean maintainClosed, boolean optionsFirst)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usemaxDepth
- depth limit of DFS. -1 specifies no limit.maintainClosed
- whether to maintain a closed list or notoptionsFirst
- whether to explore paths generated by options first.public int getNumVisited()
public SDPlannerPolicy planFromState(State initialState)
SDPlannerPolicy
. If
a State
is not in the solution path of this planner, then
the SDPlannerPolicy
will throw
a runtime exception. If you want a policy that will dynamically replan for unknown states,
you should create your own DDPlannerPolicy
.initialState
- the initial state of the planning problemSDPlannerPolicy
.public void resetSolver()
MDPSolverInterface
resetSolver
in interface MDPSolverInterface
resetSolver
in class DeterministicPlanner
protected SearchNode dfs(SearchNode n, int depth, java.util.Set<HashableState> statesOnPath)
n
- the current search nodedepth
- the current depth of the searchstatesOnPath
- the states that have bee explored on the current search pathpublic void setOptionsFirst()
protected int numOptionsInGAs(java.util.List<Action> gas)
gas
- a list of possible actionsprotected void shuffleGroundedActions(java.util.List<Action> gas, int s, int e)
gas
- a list of actionss
- the start index from which actions should be shufflede
- the end index of actions that should be shuffled.protected void sortActionsWithOptionsFirst()