mujoco_worker¶
Base class for parallel MuJoCo robot evaluation.
Users subclass MuJoCoWorkerBase and implement evaluate() with their experiment-specific fitness logic. The instance is passed directly to multiprocessing.Pool.imap — it is picklable because it is a named class.
Module Contents¶
Classes¶
Minimal config passed to each worker process. |
|
Callable base class for MuJoCo robot evaluation in worker processes. |
- class EvalConfig¶
Minimal config passed to each worker process.
Users may subclass this to carry additional experiment-specific fields.
- spawn_position: tuple[float, float, float]¶
- target_position: tuple[float, float, float]¶
- seed: int | None = None¶
- class MuJoCoWorkerBase¶
Bases:
digraph inheritance1cc44eae13 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "MuJoCoWorkerBase" [URL="#ariel.simulation.mujoco_worker.MuJoCoWorkerBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Callable base class for MuJoCo robot evaluation in worker processes."]; "ABC" -> "MuJoCoWorkerBase" [arrowsize=0.5,style="setlinewidth(0.5)"]; }abc.ABCCallable base class for MuJoCo robot evaluation in worker processes.
Subclass and implement evaluate(). Pass an instance to multiprocessing.Pool.imap as the map function:
worker = MyWorker() with pool: results = list(pool.imap(worker, eval_args))
where eval_args is a list of (xml_string, EvalConfig) tuples.
- __call__(args: tuple[str, EvalConfig]) float¶
Entry point called by the worker process.
Loads the MuJoCo model from XML and delegates to evaluate(). Returns the result of evaluate(), or raises if the XML is invalid.
- Returns:
The fitness value returned by evaluate().
- Return type:
- abstract evaluate(model: mujoco.MjModel, data: mujoco.MjData, config: EvalConfig) float¶
Evaluate a robot and return a scalar fitness value.
Called once per individual per generation inside a worker process. PyTorch is already limited to 1 thread when this is called.
- Parameters:
model (
Loaded MuJoCo model.)data (
Corresponding MjData,ready for simulation.)config (
Experiment configuration passed from the main process.)
- Returns:
A scalar fitness value (convention (
lower = better,but the)sign is entirely uptothe user's experiment).