Model base class
pynamics.models.base
This module contains the model base class, which forms the template for every plant model supported by this package.
Classes:
| Name | Description |
|---|---|
BaseModel |
Model base class. |
BaseModel(initial_state, input_dim, output_dim, input_labels=None, output_labels=None)
Bases: ABC
This is the parent class for every plant model supported by pynamics. While custom models are supported, they must all inherit from this class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state |
ndarray
|
The system's initial state. Should be an array shaped (n, 1), where n is the number of state variables. |
required |
input_dim |
int
|
Number of system inputs. |
required |
output_dim |
int
|
Number of system outputs. |
required |
input_labels |
list[str] | None
|
List of input labels. If |
None
|
output_labels |
list[str] | None
|
List of output labels. If |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
x |
ndarray
|
The system's state vector. |
input_dim |
int
|
Number of system inputs. |
output_dim |
int
|
Number of system outputs. |
state_dim |
int
|
Number of states in the state vector. |
input_labels |
list[str]
|
List of input labels. |
output_labels |
list[str]
|
List of output labels. |
Methods:
| Name | Description |
|---|---|
get_state |
Get the current state vector. |
get_output |
Compute the system's output from the current state. |
get_input |
Get the current inputs. |
set_input |
Pass new inputs to the system. |
update_state |
Assign new values to the system's state vector. |
eval |
Compute the system's state derivative. |
Warning
This is an abstract base class. It should not be used directly.
Source code in pynamics/models/base.py
eval()
abstractmethod
Compute the system's state derivative.
Abstract method. Implementation details may vary with the model.
get_input()
abstractmethod
Access the system's input.
Abstract method. Implementation details may vary with the model.
get_output()
abstractmethod
Compute the system's output from the current state vector.
Abstract method. Implementation details may vary with the model.
get_state()
abstractmethod
Access the system's state.
Abstract method. Implementation details may vary with the model.
set_input(u)
abstractmethod
Pass a new set of inputs (references, control actions, etc.) to the system.
Abstract method. Implementation details may vary with the model.
update_state()
abstractmethod
Assign new values to the system's state vector.
Abstract method. Implementation details may vary with the model.