sciencegym.simulations.LagrangeEnvironment module

class sciencegym.simulations.LagrangeEnvironment.Body

Bases: object

Represents a body inside the Lagrange Environment for the 3-body problem

generate_mass_heavy() None

Generates a random (normalized) mass for a heavier body

generate_mass_light() None

Generates a random (normalized) mass for a lighter body

class sciencegym.simulations.LagrangeEnvironment.LagrangeEnv(*args: Any, **kwargs: Any)

Bases: Env

differential_equation(_: float, x_vals: numpy.typing.NDArray) numpy.typing.NDArray

simulates the movement of the bodies

Note

arguments are filled in by the integrate.solve_ivp-function

Returns:

returns a Numpy Array with the the resulting values

get_reward(action: numpy.typing.NDArray) float

Calculates the reward for the reinforment learner

Parameters:

action – the positon of the 3rd position

Returns:

returns a float between 0 and 1

internal_step(action: numpy.typing.NDArray) None

Prepares the data that is used for the simulation

Parameters:

action – the positon of the 3rd position

Returns:

returns the (normalized) observation space

render(mode='human', action=None, reward=None) None

render function to visualize the simulation

Parameters:
  • mode – unused, only here for compatibility

  • action (optional) – the positon of the 3rd position

  • reward (optional) – reward of the action

Note

action and reward are additional arguments, used only for dev-purposes

when using the animation, the window is not closing after the animation is done

reset() numpy.typing.NDArray

Resets the state of the environment by generating new masses and a distance for the bodies

Returns:

returns a numpy array of the new state

seed(num)
step(action: numpy.typing.NDArray) tuple[numpy.typing.NDArray, float, bool, dict]

step-function that is used by the stable-baselines3-agent

Parameters:

action – the positon of the 3rd position

Returns:

returns a tuple of the state, reward, status of the step, and additional infos