From fe9d3f37a88d2f1fdeecbf0970fac7b54ae2d42f Mon Sep 17 00:00:00 2001 From: arihantlodha-cmd Date: Fri, 25 Sep 2026 20:42:12 +0900 Subject: [PATCH] Store retirement_age as int16 to shrink the parameters object Addresses the data-type part of #1080. retirement_age is a whole number of years, bounded well under the int16 range, but it was stored as a float64 array of length T+S. Casting it to int16 (rounding first, which keeps behavior identical to how it is already consumed in the retire calculation) cuts that array from 8 to 2 bytes per element. A baseline SS still solves to r = 0.0628 with pension outlays unchanged, and tests/test_parameters.py passes. This is the safe, self-contained piece of #1080; the broader float32/float16 downcasting of other arrays would change numerical results and is left out. --- ogcore/parameters.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 6e4c13ddf..b715b8ec9 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -205,6 +205,12 @@ def compute_default_params(self): param_in, dims=(self.T + self.S,), item=item ) setattr(self, item, param_out) + # retirement_age is a whole number of years (bounded well under the + # int16 range), so store it as int16 rather than float64 to reduce + # the memory footprint of the parameters object (see issue #1080). + # Rounding first keeps behavior identical to how it is already + # consumed in `retire`. + self.retirement_age = np.round(self.retirement_age).astype(np.int16) # Deal with parameters that vary across industry and over time tp_param_list2 = [ "Z",