Normalisation
Submodules
Normalisation base class
- class fleetrl.utils.normalization.normalization.Normalization[source]
Bases:
object
Parent class for Normalization.
- make_boundaries(dim)[source]
Create the observation space for gym. Depending on the observation, upper and lower boundaries can change.
- Parameters:
dim (
tuple
[int
]) – The length of the array, depends on the number of cars, and other information contained in the obs- Return type:
tuple
[float
,float
] |tuple
[ndarray
,ndarray
]- Returns:
A tuple, containing the low obs and high obs array that will be parsed to gym.Spaces.box
Oracle normalisation
- class fleetrl.utils.normalization.oracle_normalization.OracleNormalization(db, building_flag, pv_flag, price_flag, ev_conf, load_calc, aux)[source]
Bases:
Normalization
Oracle Normalization assumes the knowledge of the max and min values of the dataset. This is necessary to perform a global min/max normalization. Alternatively, a rolling normalization could be implemented.
- static flatten_obs(obs)[source]
Observations must be flattened for openAI gym compatibility. The parsed observation must be a flat array and not a dictionary. The dictionary either includes float or array. The function removes the nesting.
- Parameters:
obs – Normalized observation dictionary
- Returns:
A flattened array - necessary for the RL algorithms to be in a 1-dim array e.g. [v_1, …, v_N]
- make_boundaries(dim)[source]
The boundaries are 0 and 1 because the observations are min/max normalized.
- Parameters:
dim (
tuple
[int
]) – Dimension of the observation depending on the flags- Return type:
tuple
[float
,float
] |tuple
[ndarray
,ndarray
]- Returns:
Low and high observation arrays for gym.Spaces.
- normalize_obs(input_obs)[source]
Normalization function. Different cases are checked depending on the flags of PV, load, price, and aux. Input observations are a dictionary with clear namings, to make further changes in the code easy and readable.
- Parameters:
input_obs (
dict
) – Input observation: Un-normalized observations as specified in the observer.- Return type:
ndarray
- Returns:
Normalized observation.
Unit normalisation
- class fleetrl.utils.normalization.unit_normalization.UnitNormalization[source]
Bases:
Normalization
This function does not normalize, but parses the un-normalized values.
- static flatten_obs(obs)[source]
Flattening nested dict to np.ndarray
- Parameters:
obs – Observation dictionary including floats or arrays
- Returns:
Flattened observation
- make_boundaries(dim)[source]
The bounds can be -inf and inf. This is the least restricting path and allows for cross-compatibility of agents on environments that have the same shape.
- Parameters:
dim (
tuple
[int
]) – Dimension depending on the flags.- Return type:
tuple
[float
,float
] |tuple
[ndarray
,ndarray
]- Returns:
Low_obs and high_obs for gym.Spaces.