Documentation for the Integrator
src.pcgym.integrator.integration_engine
Integration class that contains both the casadi and JAX integration wrappers.
This class provides methods for integrating dynamical systems using either CasADi or JAX libraries.
Attributes:
Name | Type | Description |
---|---|---|
env |
The environment object. |
|
integration_method |
The chosen integration method ('jax' or 'casadi'). |
__init__(make_env, env_params)
Initialize the integration engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
make_env
|
Callable
|
A function to create the environment. |
required |
env_params
|
Dict[str, Any]
|
A dictionary of environment parameters. |
required |
jax_step(state, uk)
Integrate one time step using JAX.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
ndarray
|
The current state. |
required |
uk
|
ndarray
|
The control input. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The next state after integration. |
casadi_step(state, uk)
Integrate one time step using CasADi.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
state
|
ndarray
|
The current state. |
required |
uk
|
ndarray
|
The control input. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The next state after integration. |
casadify(model, sym_x, sym_u)
Convert a given model to CasADi symbolic form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Callable
|
The model to be converted. |
required |
sym_x
|
SX
|
Symbolic states. |
required |
sym_u
|
SX
|
Symbolic inputs. |
required |
Returns:
Type | Description |
---|---|
SX
|
CasADi symbolic model representing the right-hand side of the ODE. |
gen_casadi_variable(n_dim, name='x')
Generate a CasADi symbolic variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_dim
|
int
|
The dimension of the variable. |
required |
name
|
str
|
The name of the variable (default: "x"). |
'x'
|
Returns:
Type | Description |
---|---|
SX
|
A CasADi symbolic variable. |
gen_casadi_function(casadi_input, casadi_output, name, input_name=[], output_name=[])
Generate a CasADi function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
casadi_input
|
List[SX]
|
List of CasADi symbolic inputs. |
required |
casadi_output
|
List[SX]
|
List of CasADi symbolic outputs. |
required |
name
|
str
|
Name of the function. |
required |
input_name
|
List[str]
|
List of names for each input (optional). |
[]
|
output_name
|
List[str]
|
List of names for each output (optional). |
[]
|
Returns:
Type | Description |
---|---|
Function
|
A CasADi function mapping inputs to outputs. |
discretise_model(casadi_func, delta_t)
Discretize a continuous-time CasADi model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
casadi_func
|
Function
|
The continuous-time CasADi function to be discretized. |
required |
delta_t
|
float
|
The time step for discretization. |
required |
Returns:
Type | Description |
---|---|
Function
|
A discretized CasADi function. |