evomo.problems.neuroevolution#

Submodules#

Classes#

MoRobtrol

Evaluate PyTorch policies in multiobjective Brax or Playground environments.

Package Contents#

class evomo.problems.neuroevolution.MoRobtrol(policy: torch.nn.Module, env_name: str, max_episode_length: int, num_episodes: int, seed: int = None, pop_size: int | None = None, rotate_key: bool = True, reduce_fn: Callable = torch.mean, backend: str | None = None, device: torch.device | None = None, num_obj: int | None = None, observation_shape: int | None = None, obs_norm: torch.Tensor = None, useless: bool = True, *, engine: str = 'brax', objectives: Dict[str, Callable] | None = None, env_config: dict | None = None, observation_key: str | None = None)#

Bases: evox.core.Problem

Evaluate PyTorch policies in multiobjective Brax or Playground environments.

engine='brax' preserves existing behavior. engine='playground' supports four legacy mo_* ports and native Playground registry names, and requires the playground extra. Its backend must be None or ‘mjx’. Native tasks use task-specific profiles with two to four maximized objectives. Inspect objective_names and num_obj instead of assuming two objectives. objectives maps names to scalar JAX functions (previous, action, next). env_config contains native config overrides. Dictionary observations use observation_key='state' by default; images/other selected arrays flatten. Both engines share the stepwise evaluator, including normalization and RNG. Different physics backends need not produce interchangeable fitness values.

Fitness has shape (pop_size, num_obj) and includes terminal rewards. Individuals share the same episode seeds. rotate_key=False makes seeds repeat; with adaptive normalization enabled, evolving statistics can still change fitness between calls.

num_obj and observation_shape are inferred from the environment when omitted. useless=True retains the historical default of no observation normalization. Set it to False to normalize policy inputs using running count/M2/mean statistics. obs_norm is [clip, min_variance, max_variance]. Before any observations have been collected, normalization uses unit scale. Statistics accumulate in float64 and exclude rows with nonfinite features. Nonfinite policy-input features normalize to zero; input dtype is preserved.

For an outer vmap over policy parameters, set pop_size to outer batch size times inner population size. RNG and normalization statistics are shared over this combined population. Mapping independent problem states or nested HPO repeats is unsupported; use num_episodes for repeated evaluations.

engine = 'brax'#
objective_names#
num_obj#
observation_shape#
max_episode_length#
state_keys#
state_forward#
env_sys#
property device#
static available_playground_tasks()#

Return legacy ports plus task names registered in installed Playground.

static playground_task_info(env_name, *, env_config=None, observation_key=None, objectives=None)#

Load task metadata to size a policy before constructing the problem.

Native robot assets may be downloaded by Playground on first use. Pass the same configuration options when constructing MoRobtrol.

property init_state#
property vmap_init_state#
evaluate(pop_params: Dict[str, torch.nn.Parameter]) → torch.Tensor#

Return episode-reduced objective rewards for batched policy parameters.

visualize(weights: Dict[str, torch.nn.Parameter], seed: int = 0, output_type: str = 'HTML', *args, **kwargs) → str | List[numpy.ndarray]#

Render a seeded rollout as HTML or a list of RGB frames without changing evaluation state.