Triangular Reference Generator
- class gym_electric_motor.reference_generators.TriangularReferenceGenerator(amplitude_range=None, frequency_range=(1, 10), offset_range=None, *_, **kwargs)[source]
Reference Generator that generates a triangular waveform with random asymmetry. The Amplitude, frequency and offset are also randomized within a specified range. The reference is generated for a certain length and then new parameters are drawn uniformly from a selectable range.
- Parameters:
amplitude_range (tuple(float,float)) – Lower and upper limit for the amplitude.
frequency_range (tuple(float,float)) – Lower and upper limit for the frequency.
offset_range (tuple(float,float)) – Lower and upper limit for the offset
kwargs (dict) – Arguments passed to the superclass SubepisodedReferenceGenerator .
- close()
Called by the environment, when the environment is deleted to close files, store logs, etc.
- get_reference(*_, **__)
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(*_, **__)
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)
The references are reset. If an initial reference is passed, this value will be the first reference value of the next episode. Otherwise it will be 0.
- Parameters:
initial_state (ndarray(float)) – The initial state of the physical system.
initial_reference (ndarray(float)) – (Optional) The first reference value.
- Returns:
initial reference array. initial_reference_observation(element of reference_space): An initial observation of the next reference. trajectory(None): No initial trajectory is passed.
- Return type:
initial_reference(ndarray(float))
- seed(seed=None)
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]
Announcement of the PhysicalSystem to the ReferenceGenerator.
In subclasses, store all important information from the physical system to the ReferenceGenerator here. The environment announces the physical system to the ReferenceGenerator during its initialization.
- Parameters:
physical_system (PhysicalSystem) – The physical system of the environment.