public class DFS extends DeterministicPlanner
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, internalPolicyactions, debugCode, domain, gamma, hashingFactory, mapToStateIndex, rf, tf| Constructor and Description |
|---|
DFS(Domain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory)
Basic constructor for standard DFS without a depth limit
|
DFS(Domain domain,
StateConditionTest gc,
HashableStateFactory hashingFactory,
int maxDepth)
Basic constructor for standard DFS with a depth limit
|
DFS(Domain 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(Domain 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(Domain domain,
TerminalFunction tf,
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<GroundedAction> 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<GroundedAction> 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, querySelectedActionForStateaddNonDomainReferencedAction, getActions, getAllGroundedActions, getDebugCode, getDomain, getGamma, getHashingFactory, getRf, getRF, getTf, getTF, setActions, setDebugCode, setDomain, setGamma, setHashingFactory, setRf, setTf, solverInit, stateHash, toggleDebugPrinting, translateActionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddNonDomainReferencedAction, getActions, getDebugCode, getDomain, getGamma, getHashingFactory, getRf, getRF, getTf, getTF, setActions, setDebugCode, setDomain, setGamma, setHashingFactory, setRf, setTf, solverInit, toggleDebugPrintingprotected int maxDepth
protected boolean maintainClosed
protected boolean optionsFirst
protected java.util.Random rand
protected int numVisted
public DFS(Domain domain, StateConditionTest gc, HashableStateFactory hashingFactory)
domain - the domain in which to plangc - indicates the goal stateshashingFactory - the state hashing factory to usepublic DFS(Domain 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(Domain 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(Domain 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(Domain domain, TerminalFunction tf, 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()
MDPSolverInterfaceresetSolver in interface MDPSolverInterfaceresetSolver in class DeterministicPlannerprotected 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<GroundedAction> gas)
gas - a list of possible actionsprotected void shuffleGroundedActions(java.util.List<GroundedAction> 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()