Problem
Investment.lifetime and PiecewiseInvestment.lifetime are typed as int | None and documented as "Periods active after build." The implementation uses period indices (p_idx < t_idx + lt_int), so the value represents a count of periods.
However, periods themselves have durations (e.g., 5 years each). A user seeing lifetime=20 would naturally assume 20 years, but it actually means 20 periods. If periods are 5 years, that's 100 years.
Current behavior
# 3 periods of 5 years each
# lifetime=2 → active for 2 periods (10 years), NOT 2 years
Investment(lifetime=2, ...)
Proposed change
Use the period values (which are typically years) instead of counts. The lifetime integer should represent the same unit as the period index values.
# periods = [2025, 2030, 2035] (5-year periods)
# lifetime=10 → active for 10 years → 2 periods
Investment(lifetime=10, ...)
This way lifetime=20 means "20 years" when periods are in years, which matches user intuition.
Implementation
The active logic in _constrain_investment / _constrain_piecewise_investment currently does:
if t_idx <= p_idx < t_idx + lt_int: # counting period indices
Would change to compare against actual period values/durations instead of index arithmetic.
Problem
Investment.lifetimeandPiecewiseInvestment.lifetimeare typed asint | Noneand documented as "Periods active after build." The implementation uses period indices (p_idx < t_idx + lt_int), so the value represents a count of periods.However, periods themselves have durations (e.g., 5 years each). A user seeing
lifetime=20would naturally assume 20 years, but it actually means 20 periods. If periods are 5 years, that's 100 years.Current behavior
Proposed change
Use the period values (which are typically years) instead of counts. The lifetime integer should represent the same unit as the period index values.
This way
lifetime=20means "20 years" when periods are in years, which matches user intuition.Implementation
The active logic in
_constrain_investment/_constrain_piecewise_investmentcurrently does:Would change to compare against actual period values/durations instead of index arithmetic.