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:

  1. A projection entity declares projection values as instance attributes. For example, a person might have an attained age value.

  2. 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.

  3. 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

Inheritance diagram of ProjectionEntity

Variables & Properties

time_steps

Projection-wide timekeeping object.

data_sources

Data sources to initialize projection values.

init_t

Initial time step.

Methods

__init__(time_steps, data_sources[, init_t])

Constructor method.

write_projection_values(output_file_path)

Writes all ProjectionValue attributes in this projection entity to a CSV file.

write_projection_values_recursively(...)

Convenience method that writes ProjectionValue attributes for itself, as well as any nested ProjectionEntity attributes.

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.

time_steps: TimeSteps

Projection-wide timekeeping object.

write_projection_values(output_file_path: str) None

Writes all ProjectionValue attributes 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 ProjectionValue attributes for itself, as well as any nested ProjectionEntity attributes.

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.