swarmrl.tasks.task Module API Reference¶
Module for the parent class of the tasks.
Notes¶
The reward classes handle the computation of the reward from an environment and compute the loss for the models to train on.
Task
¶
Parent class for the reinforcement learning tasks.
Source code in swarmrl/tasks/task.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
kill_switch
property
writable
¶
Kill switch property of the task
__call__(colloids)
¶
Compute the reward on the whole group of particles.
Parameters¶
colloids : List[Colloid] (n_colloids, dimension) List of colloid objects in the system.
Returns¶
Reward : float Reward for the current state.
Examples¶
my_task = Task() reward = my_task(state)
Source code in swarmrl/tasks/task.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
__init__(particle_type=0)
¶
Constructor for the reward class.
Parameters¶
particle_type : int (default=0) Particle type to compute the reward for.
Source code in swarmrl/tasks/task.py
20 21 22 23 24 25 26 27 28 29 30 31 |
|
get_colloid_indices(colloids, p_type=None)
¶
Get the indices of the colloids in the observable of a specific type.
Parameters¶
colloids : List[Colloid] List of colloids from which to get the indices. p_type : int (default=None) Type of the colloids to get the indices for. If None, the particle_type attribute of the class is used.
Returns¶
indices : List[int] List of indices for the colloids of a particular type.
Source code in swarmrl/tasks/task.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
initialize(colloids)
¶
Initialize the task with starting positions of the colloids.
The parent method will just pass. This is because some observables might not need to be initialized. Those that do need to be initialized will override this method.
Parameters¶
colloids : List[Colloid] List of colloids with which to initialize the observable.
Returns¶
Updates the class state.
Source code in swarmrl/tasks/task.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|