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, internalPolicy
actions, containsParameterizedActions, debugCode, domain, gamma, hashingFactory, mapToStateIndex, rf, tf
Constructor and Description |
---|
DFS(Domain domain,
StateConditionTest gc,
StateHashFactory hashingFactory)
Basic constructor for standard DFS without a depth limit
|
DFS(Domain domain,
StateConditionTest gc,
StateHashFactory hashingFactory,
int maxDepth)
Basic constructor for standard DFS with a depth limit
|
DFS(Domain domain,
StateConditionTest gc,
StateHashFactory 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,
StateHashFactory 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<StateHashTuple> statesOnPath)
Runs DFS from a given search node, keeping track of its current depth.
|
protected void |
DFSInit(Domain domain,
TerminalFunction tf,
StateConditionTest gc,
StateHashFactory 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.
|
void |
planFromState(State initialState)
This method will cause the planner to begin planning from the specified initial state
|
void |
resetPlannerResults()
Use this method to reset all planner results so that planning can be started fresh with a call to
OOMDPPlanner.planFromState(State)
as if no planning had ever been performed before. |
void |
setOptionsFirst()
Sets the planner 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, querySelectedActionForState
addNonDomainReferencedAction, getActions, getAllGroundedActions, getDebugCode, getDomain, getGamma, getHashingFactory, getRf, getRF, getTf, getTF, plannerInit, setActions, setDebugCode, setDomain, setGamma, setRf, setTf, stateHash, toggleDebugPrinting, translateAction
protected int maxDepth
protected boolean maintainClosed
protected boolean optionsFirst
protected java.util.Random rand
protected int numVisted
public DFS(Domain domain, StateConditionTest gc, StateHashFactory hashingFactory)
domain
- the domain in which to plangc
- indicates the goal stateshashingFactory
- the state hashing factory to usepublic DFS(Domain domain, StateConditionTest gc, StateHashFactory 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, StateHashFactory 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, StateHashFactory 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, StateHashFactory 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 void planFromState(State initialState)
OOMDPPlanner
planFromState
in class OOMDPPlanner
initialState
- the initial state of the planning problempublic void resetPlannerResults()
OOMDPPlanner
OOMDPPlanner.planFromState(State)
as if no planning had ever been performed before. Specifically, data produced from calls to the
OOMDPPlanner.planFromState(State)
will be cleared, but all other planner settings should remain the same.
This is useful if the reward function or transition dynamics have changed, thereby
requiring new results to be computed. If there were other objects this planner was provided that may have changed
and need to be reset, you will need to reset them yourself. For instance, if you told a planner to follow a policy
that had a temperature parameter decrease with time, you will need to reset the policy's temperature yourself.resetPlannerResults
in class DeterministicPlanner
protected SearchNode dfs(SearchNode n, int depth, java.util.Set<StateHashTuple> 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()