Task Spaces#

Syllabus provides the TaskSpace class as a way to represent the entire space of classes that are playable in an environment. This is necessary for sampling tasks from the entire task space.

Usage#

You can define a Discrete task space by providing either a Discrete gym space or an integer to the constructor:

from gym.spaces import Discrete
from syllabus.task_space import TaskSpace

# You can provide a gym space
task_space = TaskSpace(Discrete(200))
# Or just an integer
task_space = TaskSpace(200)

Future Features#

This component is currently a work in progress. Future versions will include:

  • Mutable Task Spaces

  • Train, test, and validation splits over the task space

  • Support for more complex task spaces (currently only Discrete, MultiDiscrete, and Box spaces are fully supported)

syllabus.task_space.task_space module#

class syllabus.task_space.task_space.TaskSpace(gym_space: Space | int, tasks=None)#

Bases: object

add_task(task)#

Add a task to the task space. Only implemented for discrete spaces.

contains(task)#
count_tasks(gym_space: Space | None = None) int#

Return the number of discrete tasks in the task_space. Returns None for continuous spaces. Graph space not implemented.

decode(encoding)#

Convert the efficient task encoding to a task that can be used by the environment.

encode(task)#

Convert the task to an efficient encoding to speed up multiprocessing.

get_tasks(gym_space: Space | None = None, sample_interval: float | None = None) List[tuple]#

Return the full list of discrete tasks in the task_space. Return a sample of the tasks for continuous spaces if sample_interval is specified. Can be overridden to exclude invalid tasks within the space.

increase_space(amount: int | float = 1)#
list_tasks()#
property num_tasks: int#
sample()#
task_name(task)#
property tasks: List[Any]#