Bases: Tagged
A named component of the system state.
In GDS terms, the full state space X is the product of all entity
state spaces. Entities correspond to actors, resources, registries —
anything that persists across timesteps.
Source code in packages/gds-framework/gds/state.py
| class Entity(Tagged):
"""A named component of the system state.
In GDS terms, the full state space X is the product of all entity
state spaces. Entities correspond to actors, resources, registries —
anything that persists across timesteps.
"""
name: str
variables: dict[str, StateVariable] = Field(default_factory=dict)
description: str = ""
model_config = ConfigDict(frozen=True)
def validate_state(self, data: dict[str, Any]) -> list[str]:
"""Validate a state snapshot for this entity.
Returns a list of error strings (empty means valid).
"""
errors: list[str] = []
for vname, var in self.variables.items():
if vname not in data:
errors.append(f"{self.name}.{vname}: missing")
elif not var.check_value(data[vname]):
errors.append(f"{self.name}.{vname}: type/constraint violation")
return errors
|
validate_state(data)
Validate a state snapshot for this entity.
Returns a list of error strings (empty means valid).
Source code in packages/gds-framework/gds/state.py
| def validate_state(self, data: dict[str, Any]) -> list[str]:
"""Validate a state snapshot for this entity.
Returns a list of error strings (empty means valid).
"""
errors: list[str] = []
for vname, var in self.variables.items():
if vname not in data:
errors.append(f"{self.name}.{vname}: missing")
elif not var.check_value(data[vname]):
errors.append(f"{self.name}.{vname}: type/constraint violation")
return errors
|