|
| 1 | +# Elements & GDS Mapping |
| 2 | + |
| 3 | +`gds-control` provides four element types, each mapping to a specific GDS role and corresponding to the standard state-space representation. |
| 4 | + |
| 5 | +## State |
| 6 | + |
| 7 | +A state variable in the plant. Each state becomes a GDS entity with a `value` state variable, and a dynamics block that applies incoming control signals. |
| 8 | + |
| 9 | +```python |
| 10 | +State(name="temperature", initial=20.0) |
| 11 | +``` |
| 12 | + |
| 13 | +**GDS mapping:** `Mechanism` (state update *f*) + `Entity` (state *X*) |
| 14 | + |
| 15 | +**State-space:** x (state vector) |
| 16 | + |
| 17 | +| Field | Type | Default | Description | |
| 18 | +|-------|------|---------|-------------| |
| 19 | +| `name` | str | required | State name (becomes entity name) | |
| 20 | +| `initial` | float \| None | None | Initial value | |
| 21 | + |
| 22 | +### Port Convention |
| 23 | + |
| 24 | +- Output: `"{Name} State"` (temporal feedback to sensors) |
| 25 | +- Input: `"{ControllerName} Control"` (incoming control signals) |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Input |
| 30 | + |
| 31 | +An exogenous reference signal or disturbance entering the system from outside. Inputs have no internal sources -- they represent the boundary between the system and its environment. |
| 32 | + |
| 33 | +```python |
| 34 | +Input(name="setpoint") |
| 35 | +``` |
| 36 | + |
| 37 | +**GDS mapping:** `BoundaryAction` (exogenous input *U*) |
| 38 | + |
| 39 | +**State-space:** r (reference signal) |
| 40 | + |
| 41 | +| Field | Type | Default | Description | |
| 42 | +|-------|------|---------|-------------| |
| 43 | +| `name` | str | required | Input name | |
| 44 | + |
| 45 | +### Port Convention |
| 46 | + |
| 47 | +- Output: `"{Name} Reference"` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Sensor |
| 52 | + |
| 53 | +A sensor reads state variables and emits a measurement signal. The `observes` list declares which states the sensor can read -- validated at model construction time. |
| 54 | + |
| 55 | +```python |
| 56 | +Sensor(name="thermometer", observes=["temperature"]) |
| 57 | +``` |
| 58 | + |
| 59 | +**GDS mapping:** `Policy` (observation *g*) |
| 60 | + |
| 61 | +**State-space:** y = Cx + Du (sensor output) |
| 62 | + |
| 63 | +| Field | Type | Default | Description | |
| 64 | +|-------|------|---------|-------------| |
| 65 | +| `name` | str | required | Sensor name | |
| 66 | +| `observes` | list[str] | [] | Names of states this sensor reads | |
| 67 | + |
| 68 | +### Port Convention |
| 69 | + |
| 70 | +- Input: `"{StateName} State"` |
| 71 | +- Output: `"{Name} Measurement"` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Controller |
| 76 | + |
| 77 | +A controller reads sensor measurements and/or reference inputs, then emits control signals to drive state variables. |
| 78 | + |
| 79 | +```python |
| 80 | +Controller(name="PID", reads=["thermometer", "setpoint"], drives=["temperature"]) |
| 81 | +``` |
| 82 | + |
| 83 | +**GDS mapping:** `Policy` (decision logic *g*) |
| 84 | + |
| 85 | +**State-space:** u = K(y, r) (control law) |
| 86 | + |
| 87 | +| Field | Type | Default | Description | |
| 88 | +|-------|------|---------|-------------| |
| 89 | +| `name` | str | required | Controller name | |
| 90 | +| `reads` | list[str] | [] | Names of sensors/inputs this controller reads | |
| 91 | +| `drives` | list[str] | [] | Names of states this controller drives | |
| 92 | + |
| 93 | +### Port Convention |
| 94 | + |
| 95 | +- Input: `"{ReadName} Measurement"` or `"{ReadName} Reference"` |
| 96 | +- Output: `"{Name} Control"` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Semantic Type System |
| 101 | + |
| 102 | +Four distinct semantic spaces, all `float`-backed but structurally separate -- this prevents accidentally wiring a measurement where a control signal is expected: |
| 103 | + |
| 104 | +| Type | Space | Used By | Description | |
| 105 | +|------|-------|---------|-------------| |
| 106 | +| `StateType` | `StateSpace` | States | Plant state variables | |
| 107 | +| `ReferenceType` | `ReferenceSpace` | Inputs | Exogenous reference/disturbance signals | |
| 108 | +| `MeasurementType` | `MeasurementSpace` | Sensors | Sensor output measurements | |
| 109 | +| `ControlType` | `ControlSpace` | Controllers | Controller output signals | |
| 110 | + |
| 111 | +## Composition Structure |
| 112 | + |
| 113 | +The compiler builds a tiered composition tree: |
| 114 | + |
| 115 | +``` |
| 116 | +(inputs | sensors) >> (controllers) >> (state dynamics) |
| 117 | + .loop([state dynamics forward_out -> sensor forward_in]) |
| 118 | +``` |
| 119 | + |
| 120 | +This maps to the GDS canonical form `h = f . g` where states carry state (X), dynamics provide f, and sensors + controllers contribute to g. |
0 commit comments