Multiple Reference Generator
- class gym_electric_motor.reference_generators.MultipleReferenceGenerator(sub_generators, sub_args=None, **kwargs)[source]
Reference Generator that combines multiple sub reference generators that all have to reference different state variables.
- Parameters:
sub_generators (list(str/class/object)) – List of keys, classes or objects to instantiate the sub_generators
sub_args (dict/list(dict)/None) – (Optional) Arguments to pass to the sub_converters. If not passed all kwargs will be passed to each sub_generator.
kwargs – All kwargs of the environment. Passed to the sub_generators, if no sub_args are passed.
- close()
Called by the environment, when the environment is deleted to close files, store logs, etc.
- get_reference(state, **kwargs)[source]
Returns the reference array of the current time step.
The reference array needs to be in the same shape as the state variables. For referenced states the reference value is passed. For unreferenced states a default value (e.g. Zero) can be set in the reference array.
- Parameters:
state (ndarray(float)) – Current state array of the environment.
- Returns:
Current reference array.
- Return type:
ndarray(float))
- get_reference_observation(state, *_, **kwargs)[source]
Returns the reference observation for the next time step. This observation needs to fit in the reference space.
- Parameters:
state (ndarray(float)) – Current state array of the environment.
- Returns:
Observation for the next reference time step.
- Return type:
value in reference_space
- next_generator()
Sets a new reference generator for a new episode.
- property random_generator
The random generator that has to be used to draw the random numbers.
- property reference_names
Returns: reference_names(list(str)): A list containing all names of the referenced states in the reference observation.
- property referenced_states
Returns: ndarray(bool): Boolean-Array with the length of the state_variables indicating which states are referenced.
- reset(initial_state=None, initial_reference=None)[source]
Reset of references for a new episode.
- Parameters:
initial_state (ndarray(float)) – The initial state array of the environment.
initial_reference (ndarray(float)) – If not None: A desired initial reference array.
- Returns:
The reference array at time step 0.
reference_observation(value in reference_space): The reference observation for the next time step.
trajectories(dict(list(float)): If available, generated trajectories for the Visualization can be passed here. Otherwise return None.
- Return type:
reference_array(ndarray(float))
- seed(seed=None)[source]
The function to set the seed.
This function is called by within the global seed call of the environment. The environment passes the sub-seed to this component that is generated based on the source-seed of the env.
- Parameters:
seed ((np.random.SeedSequence, None)) – Seed sequence to derive new seeds and reference generators at every episode start. Default: None (a new SeedSequence is generated).
- Returns:
A list containing all seeds within this RandomComponent. In general, this list has length 1. If the RandomComponent holds further RandomComponent instances, the list has to contain also these entropies. The entropy of this instance has to be placed always at first place.
- Return type:
List(int)
- property seed_sequence
The base seed sequence that generates the sub generators and sub seeds at every environment reset.
- set_modules(physical_system)[source]
- Parameters:
physical_system (PhysicalSystem) – The physical system of the environment.