File size: 7,338 Bytes
1b4e60d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | # kyrexis/progression_scaling.py
"""
Kyrexis 20-Year Progression Scaling (x4)
33.5% CAGR · 368x Growth · 96.1% Maximum · 5.4469 Lineage Coefficient
The x4 scaling factor multiplies any projected metric — this is a
product-level planning multiplier from the module spec, not a claim
about real market growth.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Dict, List, Optional # noqa: F401
@dataclass
class ProgressionYear:
"""Progression data for a single year."""
year: int
growth_factor: float
lineage_coefficient: float
awakening: float
confidence: float
@dataclass
class ProgressionScale:
"""20-year progression scaling parameters."""
total_years: int = 20
annual_growth_rate: float = 0.335 # 33.5% CAGR
total_growth_factor: float = 368.4
max_coefficient: float = 5.6667
current_coefficient: float = 5.4469
max_achievement: float = 0.961 # 96.1%
class ProgressionScalingEngine:
"""
Kyrexis 20-Year Progression Scaling Engine.
Fixes the spec draft: the engine previously referenced
``self.annual_growth_rate`` etc. before defining them — the
parameters now live on the engine (mirroring ProgressionScale).
"""
def __init__(self, scale_factor: int = 4):
self.scale_factor = scale_factor
self.current_year = 0
self.progression_data: Dict[str, Any] = {}
# Parameters (from ProgressionScale / spec anchors)
self.total_years = 20
self.annual_growth_rate = 0.335
self.total_growth_factor = 368.4
self.max_coefficient = 5.6667
self.current_coefficient = 5.4469
self.max_achievement = 0.961
self.years: List[ProgressionYear] = []
self._init_progression()
def _init_progression(self) -> None:
"""Initialize the 20-year progression table."""
print("📈 Initializing 20-Year Progression Scaling")
print(f" Annual Growth Rate: {self.annual_growth_rate * 100:.1f}%")
print(f" Total Growth Factor: {self.total_growth_factor:.1f}x")
print(f" Max Coefficient: {self.max_coefficient:.4f}")
print(f" Current Coefficient: {self.current_coefficient:.4f}")
print(f" Max Achievement: {self.max_achievement * 100:.1f}%")
self.years = []
for year in range(1, self.total_years + 1):
growth = (1 + self.annual_growth_rate) ** year
coefficient = self.max_coefficient * (1 - 0.85 ** year)
awakening = min(1.0, 0.4 + 0.025 * year + 0.01 * year ** 0.5)
confidence = max(0.0, 0.95 - (year * 0.005))
self.years.append(
ProgressionYear(
year=year,
growth_factor=round(growth, 4),
lineage_coefficient=round(coefficient, 4),
awakening=round(awakening, 4),
confidence=round(confidence, 4),
)
)
print(f"✅ {len(self.years)} progression years initialized")
def apply_scaling(self, value: float) -> float:
"""Apply the x4 scaling multiplier."""
return value * self.scale_factor
def get_progression_at_year(self, year: int) -> Dict[str, Any]:
"""Progression data at a specific year (with x4 scaling)."""
if year < 1 or year > self.total_years:
return {"error": f"Year must be between 1 and {self.total_years}"}
prog = self.years[year - 1]
return {
"year": year,
"growth_factor": prog.growth_factor,
"growth_factor_scaled": round(self.apply_scaling(prog.growth_factor), 4),
"lineage_coefficient": prog.lineage_coefficient,
"lineage_coefficient_scaled": round(self.apply_scaling(prog.lineage_coefficient), 4),
"awakening": prog.awakening,
"awakening_scaled": round(self.apply_scaling(prog.awakening), 4),
"confidence": prog.confidence,
"scaling_factor": self.scale_factor,
}
def get_full_progression(self) -> List[Dict[str, Any]]:
"""Full 20-year progression table."""
return [self.get_progression_at_year(year) for year in range(1, self.total_years + 1)]
def get_summary(self) -> Dict[str, Any]:
"""Progression summary."""
last_year = self.years[-1]
return {
"total_years": self.total_years,
"annual_growth_rate": self.annual_growth_rate,
"annual_growth_rate_percent": self.annual_growth_rate * 100,
"total_growth_factor": self.total_growth_factor,
"total_growth_factor_scaled": round(self.apply_scaling(self.total_growth_factor), 1),
"max_coefficient": self.max_coefficient,
"max_coefficient_scaled": round(self.apply_scaling(self.max_coefficient), 4),
"current_coefficient": self.current_coefficient,
"current_coefficient_scaled": round(self.apply_scaling(self.current_coefficient), 4),
"max_achievement": self.max_achievement,
"max_achievement_percent": self.max_achievement * 100,
"final_growth": last_year.growth_factor,
"final_growth_scaled": round(self.apply_scaling(last_year.growth_factor), 1),
"final_coefficient": last_year.lineage_coefficient,
"final_coefficient_scaled": round(self.apply_scaling(last_year.lineage_coefficient), 4),
"final_awakening": last_year.awakening,
"final_awakening_scaled": round(self.apply_scaling(last_year.awakening), 4),
"scaling_factor": self.scale_factor,
}
def calculate_20_year_projection(self, current_value: float) -> Dict[str, Any]:
"""Project a value across 20 years with x4 scaling."""
projection = []
for year in range(1, self.total_years + 1):
growth = (1 + self.annual_growth_rate) ** year
value = current_value * growth
projection.append({
"year": year,
"growth_factor": round(growth, 4),
"value": round(value, 4),
"value_scaled": round(value * self.scale_factor, 4),
})
return {
"current_value": current_value,
"projection": projection,
"final_value": projection[-1]["value"],
"final_value_scaled": projection[-1]["value_scaled"],
"total_growth": round(projection[-1]["value"] / current_value, 2),
"total_growth_scaled": round(projection[-1]["value_scaled"] / current_value, 2),
"scaling_factor": self.scale_factor,
}
def get_progression_status(self) -> Dict[str, Any]:
"""Progression system status."""
return {
"active": True,
"total_years": self.total_years,
"scale_factor": self.scale_factor,
"years_data": [p.__dict__ for p in self.years],
"summary": self.get_summary(),
}
def advance_year(self, years: int = 1) -> Dict[str, Any]:
"""Advance the current-year cursor."""
self.current_year = min(self.current_year + years, self.total_years)
return self.get_progression_at_year(self.current_year)
# Singleton
progression = ProgressionScalingEngine()
|