Actionprocessors

Postprocessors can be used to process the output of an agent before it is being passed to the environment.

source

ClipAction

 ClipAction (lower:Union[float,int,numpy.ndarray,NoneType]=None,
             upper:Union[float,numpy.ndarray,NoneType]=None)

A class to clip input values within specified bounds. If the parameters lower and upper are not specified, no clipping is performed. If the parameters are scalar values, then all elements of the input are clipped to the same bounds. If the parameters are arrays, then each element of the input is clipped to the corresponding bounds.

Type Default Details
lower Union None
upper Union None

source

ClipAction._convert_to_array

 ClipAction._convert_to_array
                               (value:Union[float,int,list,numpy.ndarray,N
                               oneType])

Converts a float value to a numpy array of shape (1,) if needed.


source

ClipAction.__call__

 ClipAction.__call__ (input:numpy.ndarray)

Clips the input array within the specified bounds.

Type Details
input ndarray
Returns ndarray

source

RoundAction

 RoundAction (unit_size:Union[float,int,numpy.ndarray])

A class to round input values to the nearest specified unit size. Unit size can be any decimal value like 10, 3, 1, 0.1, 0.03, etc.

Type Details
unit_size Union

source

RoundAction._validate_unit_size

 RoundAction._validate_unit_size
                                  (unit_size:Union[float,int,numpy.ndarray
                                  ])

Ensures that the unit size is a positive float, int, or a numpy array of positive values.


source

RoundAction.__call__

 RoundAction.__call__ (input:numpy.ndarray)

Rounds the input array to the nearest specified unit size.

Example usage of [`RoundAction`](https://opimwue.github.io/ddopai/20_environments/actionprocessors.html#roundaction). Expected result:

[1. 2. 4. 5. 6.]

[0.1 0.4]

[ 0. 12. 6. 0. 0. 0. 3.]

input = np.array([1.1, 2.5, 3.5, 4.6, 5.9])
round_action = RoundAction(1)
print(round_action(input))

input = np.array([0.12, 0.39])
round_action = RoundAction(0.1)
print(round_action(input))

input = np.array([1.1231, 12.13, 7, 0.5, 1.4, 1.5, 1.6])
round_action = RoundAction(3)
print(round_action(input))
[1. 2. 4. 5. 6.]
[0.1 0.4]
[ 0. 12.  6.  0.  0.  0.  3.]

source

MoveBatchToProductDim

 MoveBatchToProductDim (remove_action_per_unit_dim:bool=False)

A class that moves the first dimension to the last place. Usefull for meta learners that return the predictions of various units in the batch dimension while in environment the num_unit (e.g., num_SKU) dimension is usually the last one

Type Default Details
remove_action_per_unit_dim bool False If there is only one action per unit, the action dimension can be removed by setting this to True

source

MoveBatchToProductDim.__call__

 MoveBatchToProductDim.__call__ (input:numpy.ndarray)

Moves the first dimension to the last place.