dacbench.wrappers
Submodules
dacbench.wrappers.action_tracking_wrapperdacbench.wrappers.episode_time_trackerdacbench.wrappers.instance_sampling_wrapperdacbench.wrappers.observation_wrapperdacbench.wrappers.performance_tracking_wrapperdacbench.wrappers.policy_progress_wrapperdacbench.wrappers.reward_noise_wrapperdacbench.wrappers.state_tracking_wrapper
Package Contents
Classes
Wrapper to action frequency. |
|
Wrapper to track time spent per episode. |
|
Wrapper to sample a new instance at a given time point. |
|
Wrapper to track progress towards optimal policy. |
|
Wrapper to add noise to the reward signal. |
|
Wrapper to track state changed over time |
|
Wrapper to track episode performance. |
|
Wrapper covert observations spaces to spaces.Box for convenience |
- class dacbench.wrappers.ActionFrequencyWrapper(env, action_interval=None, logger=None)
Bases:
gym.WrapperWrapper to action frequency. Includes interval mode that returns frequencies in lists of len(interval) instead of one long list.
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and record state
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- get_actions(self)
Get state progression
- Returns
all states or all states and interval sorted states
- Return type
np.array or np.array, np.array
- render_action_tracking(self)
Render action progression
- Returns
RBG data of action tracking
- Return type
np.array
- class dacbench.wrappers.EpisodeTimeWrapper(env, time_interval=None, logger=None)
Bases:
gym.WrapperWrapper to track time spent per episode. Includes interval mode that returns times in lists of len(interval) instead of one long list.
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and record time
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- get_times(self)
Get times
- Returns
all times or all times and interval sorted times
- Return type
np.array or np.array, np.array
- render_step_time(self)
Render step times
- render_episode_time(self)
Render episode times
- class dacbench.wrappers.InstanceSamplingWrapper(env, sampling_function=None, instances=None, reset_interval=0)
Bases:
gym.WrapperWrapper to sample a new instance at a given time point. Instances can either be sampled using a given method or a distribution infered from a given list of instances.
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- reset(self)
Reset environment and use sampled instance for training
- Returns
state
- Return type
np.array
- fit_dist(self, instances)
Approximate instance distribution in given instance set
- Parameters
instances (List) – instance set
- Returns
sampling method for new instances
- Return type
method
- class dacbench.wrappers.PolicyProgressWrapper(env, compute_optimal)
Bases:
gym.WrapperWrapper to track progress towards optimal policy. Can only be used if a way to obtain the optimal policy given an instance can be obtained
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and record distance
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- render_policy_progress(self)
Plot progress
- class dacbench.wrappers.RewardNoiseWrapper(env, noise_function=None, noise_dist='standard_normal', dist_args=None)
Bases:
gym.WrapperWrapper to add noise to the reward signal. Noise can be sampled from a custom distribution or any distribution in numpy’s random module
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and add noise
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- add_noise(self, dist, args)
Make noise function from distribution name and arguments
- Parameters
dist (str) – Name of distribution
args (list) – List of distribution arguments
- Returns
Noise sampling function
- Return type
function
- class dacbench.wrappers.StateTrackingWrapper(env, state_interval=None, logger=None)
Bases:
gym.WrapperWrapper to track state changed over time Includes interval mode that returns states in lists of len(interval) instead of one long list.
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- reset(self)
Reset environment and record starting state
- Returns
state
- Return type
np.array
- step(self, action)
Execute environment step and record state
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- get_states(self)
Get state progression
- Returns
all states or all states and interval sorted states
- Return type
np.array or np.array, np.array
- render_state_tracking(self)
Render state progression
- Returns
RBG data of state tracking
- Return type
np.array
- class dacbench.wrappers.PerformanceTrackingWrapper(env, performance_interval=None, track_instance_performance=True, logger=None)
Bases:
gym.WrapperWrapper to track episode performance. Includes interval mode that returns performance in lists of len(interval) instead of one long list.
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and record performance
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- get_performance(self)
Get state performance
- Returns
all states or all states and interval sorted states
- Return type
np.array or np.array, np.array or np.array, dict or np.array, np.arry, dict
- render_performance(self)
Plot performance
- render_instance_performance(self)
Plot mean performance for each instance
- class dacbench.wrappers.ObservationWrapper(env)
Bases:
gym.WrapperWrapper covert observations spaces to spaces.Box for convenience Currently only supports Dict -> Box
- __setattr__(self, name, value)
Set attribute in wrapper if available and in env if not
- Parameters
name (str) – Attribute to set
value – Value to set attribute to
- __getattribute__(self, name)
Get attribute value of wrapper if available and of env if not
- Parameters
name (str) – Attribute to get
- Returns
Value of given name
- Return type
value
- step(self, action)
Execute environment step and record distance
- Parameters
action (int) – action to execute
- Returns
state, reward, done, metainfo
- Return type
np.array, float, bool, dict
- reset(self)
Execute environment step and record distance
- Returns
state
- Return type
np.array
- flatten(self, state_dict)