src.system.projection_entity.ProjectionEntity¶
- class src.system.projection_entity.ProjectionEntity(time_steps: TimeSteps, data_sources: DataSourcesRoot, init_t: date = None)¶
Abstract class that represents an entity within a projection (like a person or a policy). A projection entity is the primary building block for projections, and has several defined properties:
A projection entity declares
projection valuesas instance attributes. For example, a person might have an attained age value.A projection entity declares instance methods that update its
projection values. For example, a person could have a death method that updates a death claim payout amount.A projection entity implements a special write method, which prints out all its
projection values.
Inherit this class to implement a custom projection entity.
Inheritance Diagram

Variables & Properties
Projection-wide timekeeping object.
Data sources to initialize projection values.
Initial time step.
Methods
__init__(time_steps, data_sources[, init_t])Constructor method.
write_projection_values(output_file_path)Writes all
ProjectionValueattributes in this projection entity to a CSV file.Convenience method that writes
ProjectionValueattributes for itself, as well as any nestedProjectionEntityattributes.Details
- __init__(time_steps: TimeSteps, data_sources: DataSourcesRoot, init_t: date = None)¶
Constructor method. Initializes several critical timekeeping attributes, which synchronize this projection entity with other projection entities across time.
- Parameters:
time_steps – Projection-wide timekeeping object.
data_sources – Data sources to initialize projection values.
init_t – Optional initial time step. Defaults to time_steps.t if no value is provided.
- data_sources: DataSourcesRoot¶
Data sources to initialize projection values.
- init_t: date¶
Initial time step. Marks when this entity first came into existence.
- write_projection_values(output_file_path: str) None¶
Writes all
ProjectionValueattributes in this projection entity to a CSV file. Existing file will be overwritten.- Parameters:
output_file_path – Output file path.
- Returns:
Nothing.
- write_projection_values_recursively(output_file_path: str) None¶
Convenience method that writes
ProjectionValueattributes for itself, as well as any nestedProjectionEntityattributes.This function behaves recursively, writing output for all nested projection entities no matter how deeply they are nested.
- Parameters:
output_file_path – Output file path
- Returns:
Nothing.