dacbench.envs.geometric
Geometric environment. Original environment authors: Rasmus von Glahn
Module Contents
Classes
Environment for tracing different curves that are orthogonal to each other |
|
- class dacbench.envs.geometric.GeometricEnv(config)
Bases:
dacbench.AbstractEnvEnvironment for tracing different curves that are orthogonal to each other Use product approach: f(t,x,y,z) = X(t,x) * Y(t,y) * Z(t,z) Normalize Function Value on a Scale between 0 and 1
min and max value for normalization over all timesteps
- get_optimal_policy(self, instance: List = None, vector_action: bool = True) List[numpy.array]
Calculates the optimal policy for an instance
- Parameters
instance (List, optional) – instance with information about function config.
vector_action (bool, optional) – if True return multidim actions else return onedimensional action, by default True
- Returns
List with entry for each timestep that holds all optimal values in an array or as int
- Return type
List[np.array]
- step(self, action: int)
Execute environment step
- Parameters
action (int) – action to execute
- Returns
state, reward, done, info
- Return type
np.array, float, bool, dict
- reset(self) List[int]
Resets env
- Returns
Environment state
- Return type
numpy.array
- get_default_reward(self, _) float
Calculate euclidean distance between action vector and real position of Curve.
- Parameters
_ (self) – ignore
- Returns
Euclidean distance
- Return type
float
- get_default_state(self, _) numpy.array
Gather state information.
- Parameters
_ – ignore param
- Returns
numpy array with state information
- Return type
np.array
- close(self) bool
Close Env
- Returns
Closing confirmation
- Return type
bool
- render(self, dimensions: List, absolute_path: str)
Multiplot for specific dimensions of benchmark with policy actions.
- Parameters
dimensions (List) – List of dimensions that get plotted
- render_3d_dimensions(self, dimensions: List, absolute_path: str)
Plot 2 Dimensions in 3D space
- Parameters
dimensions (List) – List of dimensions that get plotted. Max 2
- _pre_reward(self) Tuple[numpy.ndarray, List]
Prepare actions and coordinates for reward calculation.
- Returns
[description]
- Return type
Tuple[np.ndarray, List]
- class dacbench.envs.geometric.Functions(n_steps: int, n_actions: int, n_instances: int, correlation: bool, correlation_table: numpy.ndarray, correlation_depth: int, derivative_interval: int)
- set_instance(self, instance: List, instance_index)
update instance
- get_coordinates(self, instance: List = None) List[numpy.array]
Calculates coordinates for instance over all time_steps. The values will change if correlation is applied and not optimal actions are taken.
- Parameters
instance (List, optional) – Instance that holds information about functions, by default None
- Returns
Index of List refers to time step
- Return type
List[np.array]
- get_coordinates_at_time_step(self, time_step: int) numpy.array
Calculate coordiantes at time_step. Apply correlation.
- Parameters
instance (List) – Instance that holds information about functions
time_step (int) – Time step of functions
- Returns
array of function values at timestep
- Return type
np.array
- calculate_derivative(self, trajectory: List, c_step: int) numpy.array
Calculate derivatives of each dimension, based on trajectories.
- Parameters
trajectory (List) – List of actions or coordinates already taken
c_step (int) – current timestep
- Returns
derivatives for each dimension
- Return type
np.array
- calculate_norm_values(self, instance_set: Dict)
Norm Functions to Intervall between -1 and 1
- _calculate_function_value(self, time_step: int, function_infos: List, func_idx: int) float
Call different functions with their speicifc parameters and norm them.
- Parameters
function_infos (List) – Consists of function name and the coefficients
time_step (int) – time step for each function
calculate_norm (bool, optional) – True if norm gets calculated, by default False
- Returns
coordinate in dimension of function
- Return type
float
- _add_correlation(self, value_array: numpy.ndarray, time_step: int)
Adds correlation between dimensions but clips at -1 and 1. Correlation table holds numbers between -1 and 1. e.g. correlation_table[0][2] = 0.5 if dimension 1 changes dimension 3 changes about 50% of dimension one
- Parameters
correlation_table (np.array) – table that holds all values of correlation between dimensions [n,n]
- _apply_correlation_update(self, idx: int, diff: float, depth)
Recursive function for correlation updates Call function recursively till depth is 0 or diff is too small.
- _sigmoid(self, t: float, scaling: float, inflection: float)
Simple sigmoid function
- _linear(self, t: float, a: float, b: float)
Linear function
- _parabel(self, t: float, sig: int, x_int: int, y_int: int)
Parabel function
- _cubic(self, t: float, sig: int, x_int: int, y_int: int)
cubic function
- _logarithmic(self, t: float, a: float)
Logarithmic function
- _constant(self, c: float)
Constant function
- _sinus(self, t: float, scale: float)
Sinus function