QDpy
Loading...
Searching...
No Matches
subgoal_mcts.py File Reference

Online subgoal discovery and tree search with a hard simulation budget. More...

Go to the source code of this file.

Classes

class  qdpy.algorithms.subgoal_mcts.MCTSPlan
 A measured simulator path, with its primitive actions and rewards. More...
class  qdpy.algorithms.subgoal_mcts.MCTSResult
 A plan and its simulator transition costs, including the low-level search. More...
class  qdpy.algorithms.subgoal_mcts._Primitive
class  qdpy.algorithms.subgoal_mcts._Action
class  qdpy.algorithms.subgoal_mcts._Subgoal
class  qdpy.algorithms.subgoal_mcts._MacroAction
class  qdpy.algorithms.subgoal_mcts._Search
class  qdpy.algorithms.subgoal_mcts._SubgoalSearch

Namespaces

namespace  qdpy

Functions

 qdpy.algorithms.subgoal_mcts._select_subgoals (candidates, descriptors, count, neighbors, reward_weight, discount)
 Greedily retain high-return, locally different macro endpoints.
 qdpy.algorithms.subgoal_mcts.primitive_mcts (start, *, actions, simulate, budget, horizon, discount=.99, exploration=1.4, start_terminated=False, seed=0)
 Search a simulator with a single tree of primitive actions.
 qdpy.algorithms.subgoal_mcts.qd_subgoal_mcts (start, *, actions, simulate, describe, budget, horizon, macro_steps=3, probes=8, subgoals=3, neighbors=3, reward_weight=.5, discount=.99, exploration=1.4, start_terminated=False, seed=0)
 Discover macro-actions locally and choose among them with a second MCTS tree.

Detailed Description

Online subgoal discovery and tree search with a hard simulation budget.

See also
https://ieee-cog.org/2021/assets/papers/paper_283.pdf

Definition in file subgoal_mcts.py.

Function Documentation

◆ primitive_mcts()

qdpy.algorithms.subgoal_mcts.primitive_mcts ( start,
* ,
actions,
simulate,
budget,
horizon,
discount = .99,
exploration = 1.4,
start_terminated = False,
seed = 0 )

Search a simulator with a single tree of primitive actions.

Run the primitive-action control with cached deterministic transitions.

See :func:`qd_subgoal_mcts` for the simulator contract. The same
horizon, reward discount, and simulator-call cap apply. Tree
traversals pick an untried action uniformly or use UCB over
existing children. Search ends early if the finite tree is exhausted.

Definition at line 321 of file subgoal_mcts.py.

◆ qd_subgoal_mcts()

qdpy.algorithms.subgoal_mcts.qd_subgoal_mcts ( start,
* ,
actions,
simulate,
describe,
budget,
horizon,
macro_steps = 3,
probes = 8,
subgoals = 3,
neighbors = 3,
reward_weight = .5,
discount = .99,
exploration = 1.4,
start_terminated = False,
seed = 0 )

Discover macro-actions locally and choose among them with a second MCTS tree.

Interleave local trajectory discovery with a high-level subgoal tree.

Each visit to an unexpanded macro node samples one path in its
low-level tree. Local UCB uses discounted distance gains from that
node. Once enough paths are available, keep a small set using
novelty and local reward comparisons. High-level UCB backs up task
rewards and uses the sampled endpoints for continuation rollouts.
Return the best complete primitive path under discounted reward,
or a measured prefix if the budget allowed only partial paths.

:param start: Initial simulator snapshot.
:param actions: Callable yielding available actions for a snapshot.
:param simulate: Pure deterministic callback (state, action) returning
    (successor, finite reward, terminated). Treat snapshots as immutable.
:param describe: Callable returning a fixed nonempty numeric state descriptor.
:param budget: Maximum total calls to simulate, including low-level search.
:param horizon: Maximum primitive steps in any searched path.
:param macro_steps: Target primitive length of a subgoal trajectory.
    Terminal and dead-end paths can be shorter.
:param probes: Complete low-level samples before publishing subgoals,
    or fewer if the local tree is exhausted.
:param subgoals: Maximum number of macro-actions published per node.
:param neighbors: Nearest selected endpoints used in the local comparison.
:param reward_weight: Weight of local competition relative to novelty.
:param discount: Per-primitive-step reward and distance discount.
:param exploration: UCB exploration coefficient in both trees.
:param start_terminated: Whether the initial snapshot is already terminal.
:param seed: Private action-selection and rollout seed.

Definition at line 340 of file subgoal_mcts.py.