releso.geometry.Geometry
- class releso.geometry.Geometry(*, save_location: Path, logger_name: str | None = None, shape_definition: ShapeDefinition | BSplineDefinition | NURBSDefinition | List[ShapeDefinition | BSplineDefinition | NURBSDefinition], action_based_observation: bool = True, discrete_actions: bool = True, reset_with_random_action_values: bool = False)
Bases:
BaseModelDefinition of the Geometry.
- __init__(**data: Any) None
Definition of the Geometry.
Base geometry which just represents the used shape.
Geometry also handles how the actions are defined and applied to the shape.
Methods
apply()Function which applies the current action values to the geometry.
apply_action(action)Function that applies a given action to the Spline.
apply_random_action([seed])Apply a random continuous action.
convert_to_pathlib_add_datetime(v)Add timestamp to save_location, of applicable.
Return actions definition defined by the shape parametrization.
get_logger()Gets the currently defined environment logger.
Returns the current observations.
Return the geometry observation definition.
Return all control_points of the spline.
Checks if the geometry was changed with the previous action apply.
reset([validation_id])Resets the geometry to its initial values.
set_logger_name_recursively(logger_name)Set the logger_name variable for all child elements.
setup(environment_id)Setup with additional information from the environment.
Attributes
Definition of the shape used for the geometry.
use the action space for the observations.
Whether or not to use discrete actions if False continuous actions will be used.
Whether or not to reset the controllable control point variables to a random state (True) or the default original state (False).
save_locationDefinition of the save location of the logs and validation results.
logger_namename of the logger.
- action_based_observation: bool
use the action space for the observations. If this is set to False please note that you need to define your own observation via a
releso.spor.SPORObject
- apply() Any | None
Function which applies the current action values to the geometry.
Overwrite if the geometry is represented by more than the shape representation.
For the basic geometry no changes to the geometry are necessary. Since geometry is given by the shape directly.
It also returns the basic information about the geometry. In this basic case it just returns the control_points of the shape. Do not rely on it returning the control_points since this might not be the case for subclasses. If you need the control_points use the relevant function.
- Returns:
Current control points of the shape.
- Return type:
List[List[float]]
- apply_action(action: List[float] | int) Any | None
Function that applies a given action to the Spline.
- Parameters:
action ([type]) – Action value depends on if the ActionSpace is discrete (int - Signifier of the action) or Continuous (List[float] - Value for each continuous variable.)
- apply_random_action(seed: str | None = None)
Apply a random continuous action.
Applying a random continuous action to all movable control point variables. Can be activated to be used during the reset of an environment.
- Parameters:
seed (Optional[str], optional) – Seed for the generation of the random action. The same seed will result in always the same action. This functionality is chosen to make validation possible. If None (default) a random seed will be used and the action will be different each time. Defaults to None.
- discrete_actions: bool
Whether or not to use discrete actions if False continuous actions will be used.
- get_action_definition() gymnasium.spaces.Space
Return actions definition defined by the shape parametrization.
- Returns:
VariableLocations that have ‘wriggle’ room.
- Return type:
spaces.Space
- get_observation() ndarray | None
Returns the current observations.
For the basic geometry it is possible to define the current values of actions to be the observations. This can be done via the variable action_based_observation.
- Returns:
Optional action based observations.
- Return type:
Optional[np.ndarray]
- get_observation_definition() Tuple[str, ndarray | Dict[str, ndarray] | Tuple[ndarray, ...]]
Return the geometry observation definition.
The geometry observation by default just includes the action space of the shape definition.
- Returns:
- Tuple of the descriptor of the
observation space and the gym based definition of the observation space.
- Return type:
Tuple[str, ObservationType]
- get_parameter_values() List[List[float]]
Return all control_points of the spline.
- Returns:
Nested list of control_points.
- Return type:
List[List[float]]
- is_geometry_changed() bool
Checks if the geometry was changed with the previous action apply.
This function uses the actions as a metric on whether the geometry was changed. If the actions were not changed the function will return False, if the actions were changed it will return True.
Needs to be reimplemented if other factors influence the geometry.
- Returns:
See above.
- Return type:
bool
- reset(validation_id: int | None = None) Any
Resets the geometry to its initial values.
- reset_with_random_action_values: bool
Whether or not to reset the controllable control point variables to a random state (True) or the default original state (False). If discrete actions are used this will reset the action values to valid discrete values.
- setup(environment_id: UUID)
Setup with additional information from the environment.
Base geometry has no changes.
- Parameters:
environment_id (UUID) – Environment id.
- shape_definition: ShapeDefinition | BSplineDefinition | NURBSDefinition | List[ShapeDefinition | BSplineDefinition | NURBSDefinition]
Definition of the shape used for the geometry. This is the shape that will be used to define the geometry and the action space. If only a single shape is used this can be a single shape definition, if multiple shapes are used this can be a list of shape definitions.