swarmrl.observables.observable Module API Reference¶
Parent class for the observable.
Observable
¶
Parent class for observables.
Observables act as inputs to the neural networks.
Source code in swarmrl/observables/observable.py
10 11 12 13 14 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 |
|
observable_shape
property
¶
Unchangeable shape of the observable. Returns
__init__(particle_type)
¶
Constructor for the observable.
Source code in swarmrl/observables/observable.py
17 18 19 20 21 22 |
|
compute_observable(colloids)
¶
Compute the current state observable for all colloids.
Parameters¶
colloids : List[Colloid] (n_colloids, ) List of all colloids in the system.
Returns¶
observables : List[np.ndarray] (n_colloids, dimension) List of observables, one for each colloid.
Source code in swarmrl/observables/observable.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
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/observables/observable.py
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 |
|
initialize(colloids)
¶
Initialize the observable 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/observables/observable.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|