import%20marimo%0A%0A__generated_with%20%3D%20%220.21.0%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%0A%20%20%20%20return%20mo%2C%20np%2C%20pd%2C%20plt%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20The%20Birthrate%20Shredder%3A%20Demographic%20Simulations%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Simulation%20Constants%20%26%20Assumptions%0A%0A%20%20%20%20This%20notebook%20relies%20on%20a%20centralized%20parameters%20system.%20By%20sharing%20these%20constants%20across%20all%20scenarios%2C%20we%20ensure%20that%20every%20divergence%E2%80%94from%20gradual%20degrowth%20to%20AGI%20handoffs%E2%80%94is%20governed%20by%20the%20same%20demographic%20and%20macroeconomic%20baseline.%0A%0A%20%20%20%20%23%23%23%201.%20Fertility%20and%20Mortality%0A%20%20%20%20*%20**TFR%20Floor%20(%240.72%24)%3A**%20The%20empirical%20minimum%20total%20fertility%20rate%20for%20advanced%2C%20secular%20populations%20(based%20on%20current%20KOSTAT%20census%20data).%0A%20%20%20%20*%20**TFR%20Acceleration%20(%24%2B0.0016%2F%5Ctext%7Byear%7D%5E2%24)%3A**%20The%20rate%20of%20fertility%20decline%20is%20modeled%20as%20an%20accelerating%20feedback%20loop.%20This%20derivative%20is%20calculated%20directly%20from%20the%20historical%20acceleration%20of%20South%20Korea's%20TFR%20drops%20between%201990%20and%202023.%0A%20%20%20%20*%20**Agrarian%20Rebound%20TFR%20(%245.5%24)%3A**%20The%20historical%20baseline%20for%20pre-industrial%20societies.%20Triggered%20only%20if%20the%20complexity%20threshold%20is%20breached%20and%20the%20global%20grid%20collapses.%0A%20%20%20%20*%20**Mortality%20Scaling%3A**%20Modern%20mortality%20curves%20are%20scaled%20to%20a%20%240.7%24%20global%20baseline.%20In%20post-collapse%20scenarios%2C%20mortality%20transitions%20to%20%243%5Ctimes%24%20modern%20rates%20over%20a%2030-year%20period%2C%20with%20infant%20mortality%20spiking%20to%20%2420%5C%25%24.%0A%0A%20%20%20%20%23%23%23%202.%20Complexity%20and%20Automation%0A%20%20%20%20The%20survival%20of%20technologically%20advanced%20civilization%20is%20modeled%20as%20a%20race%20between%20a%20shrinking%20population%20and%20the%20rate%20of%20supply%20chain%20automation.%0A%0A%20%20%20%20*%20**Initial%20Complexity%20Threshold%20(%241.3%20%5Ctext%7B%20Billion%7D%24)%3A**%20The%20estimated%20minimum%20population%20required%20to%20sustain%20a%20modern%20global%20supply%20chain%2C%20arrived%20at%20by%20summing%20the%20populations%20of%20China%2C%20Taiwan%2C%20South%20Korea%2C%20Japan%2C%20the%20EU%2C%20and%20the%20US%2C%20since%20those%20are%20the%20countries%20needed%20to%20create%20a%20full%20supply%20chain%20for%20advanced%20technology.%0A%20%20%20%20*%20**Innovation%20Death%20(%24DR%20%5Cgeq%200.8%24)%3A**%20The%20dependency%20ratio%20limit%20where%20eldercare%20and%20system%20maintenance%20consume%20all%20available%20capital%2C%20stalling%20systemic%20R%26D.%0A%20%20%20%20*%20**Automation%20Factor%20(%2443.3%5Ctext%7BM%7D%24)%3A**%20The%20annual%20reduction%20in%20the%20complexity%20threshold%20per%20unit%20of%20innovation%20surplus.%0A%20%20%20%20%20%20%20%20*%20*Derivation%3A*%20Assuming%20a%20conservative%20%241%5C%25%24%20annual%20labor%20productivity%20growth%2C%20an%20economy%20of%201.3B%20people%20can%20automate%20%24%5Csim13%5Ctext%7BM%7D%24%20jobs%20per%20year.%20At%20a%20current%20estimated%20global%20DR%20of%20%240.5%24%2C%20the%20%22innovation%20surplus%22%20before%20reaching%20the%200.8%20death%20limit%20is%20%240.3%24.%0A%20%20%20%20%20%20%20%20*%20*Calculation%3A*%20%24%5Ctext%7BAutomation%20Factor%7D%20%3D%20%5Cfrac%7B13%5Ctext%7BM%7D%7D%7B0.3%7D%20%5Capprox%2043.3%5Ctext%7BM%7D%20%5Ctext%7B%20people%2Fyear%7D%24.%0A%20%20%20%20%20%20%20%20*%20*Application%3A*%20%24%5CDelta%20%5Ctext%7BThreshold%7D%20%3D%2043.3%5Ctext%7BM%7D%20%5Ctimes%20%5Cmax(0%2C%200.8%20-%20%5Ctext%7BCurrent%20DR%7D)%24.%0A%0A%20%20%20%20%23%23%23%203.%20Technological%20Interventions%0A%20%20%20%20*%20**Cognitive%20Healthspan%20(2070)%3A**%20Pushes%20the%20effective%20working-age%20limit%20from%2065%20to%2085.%20Modeled%20using%20a%2014-year%20logistical%20S-Curve%20to%20account%20for%20manufacturing%20and%20distribution%20bottlenecks.%0A%20%20%20%20*%20**Ectogenesis%20(2120)%3A**%20Introduces%20industrialized%20human%20reproduction%20at%20a%20fixed%20rate%20of%2010%20million%20artificial%20births%20annually.%0A%20%20%20%20*%20**AGI%20Handoff%3A**%20Artificial%20General%20Intelligence%20entirely%20removes%20the%20complexity%20floor%20(%24%5Ctext%7BAbsolute%20Floor%7D%20%3D%200%24)%2C%20breaking%20the%20biological%20dependency%20link.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20%23%20Define%20the%20interactive%20sliders%0A%20%20%20%20ui_tfr_floor%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D0.5%2C%0A%20%20%20%20%20%20%20%20stop%3D1.5%2C%0A%20%20%20%20%20%20%20%20step%3D0.01%2C%0A%20%20%20%20%20%20%20%20value%3D0.72%2C%0A%20%20%20%20%20%20%20%20label%3D%22Secular%20TFR%20Floor%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20ui_prod_growth%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D0.001%2C%0A%20%20%20%20%20%20%20%20stop%3D0.030%2C%0A%20%20%20%20%20%20%20%20step%3D0.001%2C%0A%20%20%20%20%20%20%20%20value%3D0.010%2C%0A%20%20%20%20%20%20%20%20label%3D%22Labor%20Productivity%20Growth%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20ui_inno_death%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D0.6%2C%0A%20%20%20%20%20%20%20%20stop%3D1.2%2C%0A%20%20%20%20%20%20%20%20step%3D0.05%2C%0A%20%20%20%20%20%20%20%20value%3D0.8%2C%0A%20%20%20%20%20%20%20%20label%3D%22Innovation%20Death%20DR%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20ui_healthspan%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D2040%2C%0A%20%20%20%20%20%20%20%20stop%3D2150%2C%0A%20%20%20%20%20%20%20%20step%3D5%2C%0A%20%20%20%20%20%20%20%20value%3D2070%2C%0A%20%20%20%20%20%20%20%20label%3D%22Healthspan%20Breakthrough%20Year%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20ui_ecto_year%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D2080%2C%0A%20%20%20%20%20%20%20%20stop%3D2200%2C%0A%20%20%20%20%20%20%20%20step%3D5%2C%0A%20%20%20%20%20%20%20%20value%3D2120%2C%0A%20%20%20%20%20%20%20%20label%3D%22Ectogenesis%20Start%20Year%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%20%20%20%20ui_ecto_prod%20%3D%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20start%3D1%2C%0A%20%20%20%20%20%20%20%20stop%3D50%2C%0A%20%20%20%20%20%20%20%20step%3D1%2C%0A%20%20%20%20%20%20%20%20value%3D10%2C%0A%20%20%20%20%20%20%20%20label%3D%22Ectogenesis%20(Millions%2Fyr)%22%2C%0A%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Render%20the%20dashboard%0A%20%20%20%20control_panel%20%3D%20mo.md(f%22%22%22%0A%20%20%20%20%23%23%23%20%F0%9F%8E%9B%EF%B8%8F%20The%20Shredder%20Control%20Panel%0A%20%20%20%20Adjust%20the%20physical%20and%20economic%20constants%20of%20the%20universe%20to%20see%20how%20the%20timelines%20shift%20in%20real-time.%0A%0A%20%20%20%20**Biological%20%26%20Economic%20Limits**%0A%20%20%20%20%7Bui_tfr_floor%7D%0A%20%20%20%20%7Bui_prod_growth%7D%0A%20%20%20%20%7Bui_inno_death%7D%0A%0A%20%20%20%20**Technological%20Escapes**%0A%20%20%20%20%7Bui_healthspan%7D%0A%20%20%20%20%7Bui_ecto_year%7D%0A%20%20%20%20%7Bui_ecto_prod%7D%0A%20%20%20%20%22%22%22)%0A%0A%20%20%20%20control_panel%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20ui_ecto_prod%2C%0A%20%20%20%20%20%20%20%20ui_ecto_year%2C%0A%20%20%20%20%20%20%20%20ui_healthspan%2C%0A%20%20%20%20%20%20%20%20ui_inno_death%2C%0A%20%20%20%20%20%20%20%20ui_prod_growth%2C%0A%20%20%20%20%20%20%20%20ui_tfr_floor%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20np%2C%0A%20%20%20%20ui_ecto_prod%2C%0A%20%20%20%20ui_ecto_year%2C%0A%20%20%20%20ui_healthspan%2C%0A%20%20%20%20ui_inno_death%2C%0A%20%20%20%20ui_prod_growth%2C%0A%20%20%20%20ui_tfr_floor%2C%0A)%3A%0A%20%20%20%20%23%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%20%20%20%20%23%20REACTIVE%20SIMULATION%20CONSTANTS%0A%20%20%20%20%23%20Values%20automatically%20update%20when%20UI%20sliders%20are%20moved%0A%20%20%20%20%23%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A%0A%20%20%20%20%23%20---%201.%20Map%20UI%20Values%20to%20Constants%20---%0A%20%20%20%20TFR_FLOOR_SECULAR%20%3D%20ui_tfr_floor.value%0A%20%20%20%20LABOR_PRODUCTIVITY_GROWTH%20%3D%20ui_prod_growth.value%0A%20%20%20%20INNOVATION_DEATH_DR%20%3D%20ui_inno_death.value%0A%20%20%20%20HEALTHSPAN_BREAKTHROUGH_YEAR%20%3D%20ui_healthspan.value%0A%20%20%20%20ECTOGENESIS_START_YEAR%20%3D%20ui_ecto_year.value%0A%20%20%20%20ECTOGENESIS_ANNUAL_PRODUCTION%20%3D%20(%0A%20%20%20%20%20%20%20%20ui_ecto_prod.value%20*%201e6%0A%20%20%20%20)%20%20%23%20Convert%20to%20actual%20millions%0A%0A%20%20%20%20%23%20---%20Time%20Parameters%20---%0A%20%20%20%20START_YEAR%20%3D%202026%0A%20%20%20%20SIMULATION_YEARS%20%3D%20274%0A%20%20%20%20EXTENDED_YEARS%20%3D%20374%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20%3D%201.3e9%0A%0A%20%20%20%20%23%20---%20AUTOMATION%20FACTOR%20CALCULATION%20---%0A%20%20%20%20BASELINE_PRODUCTIVITY_REDUCTION%20%3D%20(%0A%20%20%20%20%20%20%20%20LABOR_PRODUCTIVITY_GROWTH%20*%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20)%0A%20%20%20%20CURRENT_DR_ESTIMATE%20%3D%200.5%0A%20%20%20%20INNOVATION_SURPLUS_BASELINE%20%3D%20INNOVATION_DEATH_DR%20-%20CURRENT_DR_ESTIMATE%0A%20%20%20%20AUTOMATION_FACTOR%20%3D%20(%0A%20%20%20%20%20%20%20%20BASELINE_PRODUCTIVITY_REDUCTION%20%2F%20INNOVATION_SURPLUS_BASELINE%0A%20%20%20%20)%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%3D%20100e6%0A%0A%20%20%20%20%23%20---%20Population%20Parameters%20---%0A%20%20%20%20TOTAL_POP_INITIAL%20%3D%208.25e9%0A%20%20%20%20AGE_DIST_0_14%20%3D%200.25%0A%20%20%20%20AGE_DIST_15_24%20%3D%200.16%0A%20%20%20%20AGE_DIST_25_64%20%3D%200.49%0A%20%20%20%20AGE_DIST_65_PLUS%20%3D%200.10%0A%0A%20%20%20%20%23%20---%20Fertility%20Parameters%20---%0A%20%20%20%20TFR_START%20%3D%202.23%0A%20%20%20%20TFR_REPLACEMENT%20%3D%202.1%0A%20%20%20%20PRE_INDUSTRIAL_TFR%20%3D%205.5%0A%0A%20%20%20%20TFR_VELOCITY_START%20%3D%200.0058%0A%20%20%20%20TFR_ACCELERATION%20%3D%200.0016%0A%20%20%20%20MAX_TFR_VELOCITY%20%3D%200.065%0A%0A%20%20%20%20FERTILITY_PEAK_AGE%20%3D%2028%0A%20%20%20%20FERTILITY_SIGMA%20%3D%206%0A%20%20%20%20FERTILITY_MIN_AGE%20%3D%2015%0A%20%20%20%20FERTILITY_MAX_AGE%20%3D%2050%0A%0A%20%20%20%20%23%20---%20Mortality%20Parameters%20---%0A%20%20%20%20MR_INFANT_BASE%20%3D%200.02%0A%20%20%20%20MR_CHILD_BASE%20%3D%200.001%0A%20%20%20%20MR_YOUNG_ADULT_BASE%20%3D%200.002%0A%20%20%20%20MR_MIDDLE_AGE_BASE%20%3D%200.005%0A%20%20%20%20MR_EARLY_ELDERLY_BASE%20%3D%200.015%0A%20%20%20%20MR_ELDERLY_BASE%20%3D%200.04%0A%20%20%20%20MR_VERY_ELDERLY_BASE%20%3D%200.10%0A%20%20%20%20MR_CENTENARIAN_BASE%20%3D%200.25%0A%0A%20%20%20%20MORTALITY_MODERN_SCALING%20%3D%200.7%0A%20%20%20%20MORTALITY_PRE_INDUSTRIAL_MULTIPLIER%20%3D%203.0%0A%20%20%20%20MR_PRE_INDUSTRIAL_INFANT%20%3D%200.20%0A%20%20%20%20TRANSITION_PERIOD%20%3D%2030%0A%0A%20%20%20%20%23%20---%20Scenario-Specific%20Constants%20---%0A%20%20%20%20FUNDAMENTALIST_INITIAL_POP%20%3D%203.5e6%0A%20%20%20%20TFR_FUNDAMENTALIST_START%20%3D%206.5%0A%20%20%20%20TFR_FUNDAMENTALIST_FLOOR%20%3D%205.5%0A%20%20%20%20FUNDAMENTALIST_TFR_VELOCITY%20%3D%200.04%0A%0A%20%20%20%20FUND_AGE_0_14%20%3D%200.45%0A%20%20%20%20FUND_AGE_15_24%20%3D%200.20%0A%20%20%20%20FUND_AGE_25_64%20%3D%200.30%0A%20%20%20%20FUND_AGE_65_PLUS%20%3D%200.05%0A%0A%20%20%20%20BASE_ATTRITION_RATE%20%3D%200.15%0A%20%20%20%20MINORITY_ATTRITION_RATE%20%3D%200.02%0A%0A%20%20%20%20ADOPTION_CURVE%20%3D%20%5B%0A%20%20%20%20%20%20%20%200.01%2C%0A%20%20%20%20%20%20%20%200.03%2C%0A%20%20%20%20%20%20%20%200.08%2C%0A%20%20%20%20%20%20%20%200.16%2C%0A%20%20%20%20%20%20%20%200.28%2C%0A%20%20%20%20%20%20%20%200.45%2C%0A%20%20%20%20%20%20%20%200.65%2C%0A%20%20%20%20%20%20%20%200.80%2C%0A%20%20%20%20%20%20%20%200.88%2C%0A%20%20%20%20%20%20%20%200.94%2C%0A%20%20%20%20%20%20%20%200.97%2C%0A%20%20%20%20%20%20%20%200.99%2C%0A%20%20%20%20%20%20%20%200.995%2C%0A%20%20%20%20%20%20%20%201.0%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20STANDARD_WORKING_AGE_START%20%3D%2015%0A%20%20%20%20STANDARD_WORKING_AGE_END%20%3D%2065%0A%20%20%20%20EXTENDED_WORKING_AGE_END%20%3D%2085%0A%0A%20%20%20%20%23%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%20%20%20%20%23%20DERIVED%20CONSTANTS%20(Pre-calculated%20for%20efficiency)%0A%20%20%20%20%23%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%0A%20%20%20%20MR_MODERN%20%3D%20np.zeros(101)%0A%20%20%20%20MR_MODERN%5B0%3A1%5D%20%3D%20MR_INFANT_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B1%3A15%5D%20%3D%20MR_CHILD_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B15%3A40%5D%20%3D%20MR_YOUNG_ADULT_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B40%3A60%5D%20%3D%20MR_MIDDLE_AGE_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B60%3A70%5D%20%3D%20MR_EARLY_ELDERLY_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B70%3A80%5D%20%3D%20MR_ELDERLY_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B80%3A90%5D%20%3D%20MR_VERY_ELDERLY_BASE%20*%20MORTALITY_MODERN_SCALING%0A%20%20%20%20MR_MODERN%5B90%3A101%5D%20%3D%20MR_CENTENARIAN_BASE%20*%20MORTALITY_MODERN_SCALING%0A%0A%20%20%20%20MR_PRE_INDUSTRIAL%20%3D%20MR_MODERN%20*%20MORTALITY_PRE_INDUSTRIAL_MULTIPLIER%0A%20%20%20%20MR_PRE_INDUSTRIAL%5B0%5D%20%3D%20MR_PRE_INDUSTRIAL_INFANT%0A%0A%20%20%20%20AGES%20%3D%20np.arange(101)%0A%20%20%20%20ASFR_SHAPE%20%3D%20np.exp(%0A%20%20%20%20%20%20%20%20-0.5%20*%20((AGES%20-%20FERTILITY_PEAK_AGE)%20%2F%20FERTILITY_SIGMA)%20**%202%0A%20%20%20%20)%0A%20%20%20%20ASFR_SHAPE%5B%3AFERTILITY_MIN_AGE%5D%20%3D%200%0A%20%20%20%20ASFR_SHAPE%5BFERTILITY_MAX_AGE%3A%5D%20%3D%200%0A%20%20%20%20ASFR_SHAPE%20%3D%20ASFR_SHAPE%20%2F%20np.sum(ASFR_SHAPE)%0A%0A%20%20%20%20POP_INITIAL_0_14%20%3D%20(AGE_DIST_0_14%20*%20TOTAL_POP_INITIAL)%20%2F%2015%0A%20%20%20%20POP_INITIAL_15_24%20%3D%20(AGE_DIST_15_24%20*%20TOTAL_POP_INITIAL)%20%2F%2010%0A%20%20%20%20POP_INITIAL_25_64%20%3D%20(AGE_DIST_25_64%20*%20TOTAL_POP_INITIAL)%20%2F%2040%0A%20%20%20%20POP_INITIAL_65_PLUS%20%3D%20(AGE_DIST_65_PLUS%20*%20TOTAL_POP_INITIAL)%20%2F%2036%0A%0A%20%20%20%20FUND_POP_0_14%20%3D%20(FUND_AGE_0_14%20*%20FUNDAMENTALIST_INITIAL_POP)%20%2F%2015%0A%20%20%20%20FUND_POP_15_24%20%3D%20(FUND_AGE_15_24%20*%20FUNDAMENTALIST_INITIAL_POP)%20%2F%2010%0A%20%20%20%20FUND_POP_25_64%20%3D%20(FUND_AGE_25_64%20*%20FUNDAMENTALIST_INITIAL_POP)%20%2F%2040%0A%20%20%20%20FUND_POP_65_PLUS%20%3D%20(FUND_AGE_65_PLUS%20*%20FUNDAMENTALIST_INITIAL_POP)%20%2F%2036%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20ADOPTION_CURVE%2C%0A%20%20%20%20%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20%20%20%20%20BASE_ATTRITION_RATE%2C%0A%20%20%20%20%20%20%20%20ECTOGENESIS_ANNUAL_PRODUCTION%2C%0A%20%20%20%20%20%20%20%20ECTOGENESIS_START_YEAR%2C%0A%20%20%20%20%20%20%20%20EXTENDED_WORKING_AGE_END%2C%0A%20%20%20%20%20%20%20%20EXTENDED_YEARS%2C%0A%20%20%20%20%20%20%20%20FUNDAMENTALIST_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20FUND_POP_0_14%2C%0A%20%20%20%20%20%20%20%20FUND_POP_15_24%2C%0A%20%20%20%20%20%20%20%20FUND_POP_25_64%2C%0A%20%20%20%20%20%20%20%20FUND_POP_65_PLUS%2C%0A%20%20%20%20%20%20%20%20HEALTHSPAN_BREAKTHROUGH_YEAR%2C%0A%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20MINORITY_ATTRITION_RATE%2C%0A%20%20%20%20%20%20%20%20MR_MODERN%2C%0A%20%20%20%20%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20%20%20%20%20SIMULATION_YEARS%2C%0A%20%20%20%20%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20%20%20%20%20START_YEAR%2C%0A%20%20%20%20%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20%20%20%20%20TFR_FUNDAMENTALIST_FLOOR%2C%0A%20%20%20%20%20%20%20%20TFR_FUNDAMENTALIST_START%2C%0A%20%20%20%20%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20%20%20%20%20TFR_START%2C%0A%20%20%20%20%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%201%3A%20Global%20Nursing%20Home%20(Gradual%20Degrowth)%0A%0A%20%20%20%20A%20%22soft%20landing%22%20where%20global%20fertility%20declines%20linearly%20from%202.23%20to%200.72%20over%20350%2B%20years.%20The%20world%20becomes%20a%20geriatric%20society%20with%20an%20inverted%20age%20pyramid.%20Despite%20the%20gradual%20decline%2C%20civilization%20still%20collapses%20when%20the%20secular%20population%20falls%20below%20the%20dynamically-reducing%20complexity%20threshold.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**Linear%20TFR%20decline**%3A%20Constant%20velocity%20of%200.0058%2Fyear%20(no%20acceleration)%0A%20%20%20%20-%20**Extended%20timeline**%3A%20Runs%20to%202400%20to%20show%20full%20post-collapse%20trajectory%0A%20%20%20%20-%20**Post-collapse%20transition**%3A%2030-year%20shift%20from%20modern%20(TFR%200.72)%20to%20pre-industrial%20(TFR%205.5)%20with%20mortality%20tripling%0A%20%20%20%20-%20**Dynamic%20complexity%20threshold**%3A%20Declines%20by%2043.3M%20%C3%97%20(0.8%20-%20DR)%20annually%20while%20innovation%20capacity%20exists%20(DR%20%3C%200.8)%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%2010.33B%20(2084)%20%E2%86%92%20Innovation%20death%202226%20%E2%86%92%20Collapse%202337%20%E2%86%92%20Nadir%200.06B%20(2375).%20Even%20gradual%20decline%20ends%20in%20collapse.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20EXTENDED_YEARS%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_master_shredder_simulation()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%20(not%20constants)%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%0A%20%20%20%20%20%20%20%20pop%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%0A%20%20%20%20%20%20%20%20pop%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%0A%20%20%20%20%20%20%20%20pop%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%0A%0A%20%20%20%20%20%20%20%20%23%20---%20Run%20Simulation%20(Extended%20to%202400)%20---%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(EXTENDED_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_pop%20%3D%20np.sum(pop)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Calculate%20dependency%20ratio%0A%20%20%20%20%20%20%20%20%20%20%20%20working_age%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dependents%20%3D%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dependency_ratio%20%3D%20dependents%20%2F%20working_age%20if%20working_age%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20for%20innovation%20death%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20is%20None%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20and%20dependency_ratio%20%3E%3D%20INNOVATION_DEATH_DR%0A%20%20%20%20%20%20%20%20%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dependency_ratio)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20for%20collapse%20against%20DYNAMIC%20threshold%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%20and%20current_pop%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Determine%20mortality%20rates%20and%20TFR%20based%20on%20collapse%20state%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr%20-%200.0058)%20%20%23%20Linear%20decline%20rate%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Population%22%3A%20current_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%22%3A%20tfr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Dependency_Ratio%22%3A%20dependency_ratio%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Population%20dynamics%20using%20shared%20fertility%2Fmortality%20constants%0A%20%20%20%20%20%20%20%20%20%20%20%20females%20%3D%20pop%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20births%20%3D%20np.sum(females%20*%20ASFR_SHAPE%20*%20tfr)%0A%20%20%20%20%20%20%20%20%20%20%20%20deaths%20%3D%20pop%20*%20current_mr%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B0%5D%20%3D%20births%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B1%3A%5D%20%3D%20pop%5B%3A-1%5D%20-%20deaths%5B%3A-1%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20pop%20%3D%20new_pop%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%0A%20%20%20%20%20%20%20%20%23%20---%20Calculate%20Milestones%20---%0A%20%20%20%20%20%20%20%20collapse_mask%20%3D%20df%5B%22Population%22%5D%20%3C%20df%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20u_threshold_df%20%3D%20df%5Bcollapse_mask%5D%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20u_threshold_df.iloc%5B0%5D%5B%22Year%22%5D%20if%20not%20u_threshold_df.empty%20else%20None%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_idx%20%3D%20df_pre_collapse%5B%22Population%22%5D.idxmax()%0A%20%20%20%20%20%20%20%20peak_year%20%3D%20df_pre_collapse.loc%5Bpeak_idx%2C%20%22Year%22%5D%0A%20%20%20%20%20%20%20%20peak_pop%20%3D%20df_pre_collapse.loc%5Bpeak_idx%2C%20%22Population%22%5D%0A%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%0A%20%20%20%20%20%20%20%20innovation_death_df%20%3D%20df%5Bdf%5B%22Dependency_Ratio%22%5D%20%3E%3D%20INNOVATION_DEATH_DR%5D%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_df.iloc%5B0%5D%5B%22Year%22%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20innovation_death_df.empty%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Population%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20%23%20---%20Milestone%20Data%20---%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22Global%20Nursing%20Home%20(Dynamic%20Threshold%2C%20Extended)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_pop%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20isinstance(innovation_death_year%2C%20(int%2C%20float))%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20innovation_death_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Dynamic%20Threshold)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Population'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20---%20Plotting%20---%0A%20%20%20%20%20%20%20%20plt.figure(figsize%3D(14%2C%2010))%0A%20%20%20%20%20%20%20%20plt.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Population%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Global%20Population%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%238B0000%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2.5%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Dynamic%20Complexity%20Threshold%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Absolute%20Floor%20(%7BABSOLUTE_MINIMUM_FLOOR%20%2F%201e6%3A.0f%7DM)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20%3C%202.1%20(%7Bint(sub_replacement_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_floor_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20Floor%20(%7Bint(tfr_floor_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20isinstance(innovation_death_year%2C%20(int%2C%20float))%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20plt.title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%201%3A%20Global%20Nursing%20Home%20(with%20Dynamic%20Innovation-Driven%20Threshold%2C%20Extended%20to%202400)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D15%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontweight%3D%22bold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Year%22%2C%20fontsize%3D12)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Population%20(Billions)%22%2C%20fontsize%3D12)%0A%20%20%20%20%20%20%20%20plt.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D9)%0A%20%20%20%20%20%20%20%20plt.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20plt.xlim(START_YEAR%2C%202400)%0A%20%20%20%20%20%20%20%20plt.ylim(0%2C%2011)%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20%23%20Run%20it!%0A%20%20%20%20master_milestones%2C%20master_df%20%3D%20run_master_shredder_simulation()%0A%20%20%20%20master_milestones%0A%20%20%20%20return%20(master_milestones%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(master_milestones%2C%20mo)%3A%0A%20%20%20%20%23%20Create%20markdown%20table%20for%20Global%20Nursing%20Home%20milestones%0A%20%20%20%20def%20milestones_to_table(milestones%2C%20title)%3A%0A%20%20%20%20%20%20%20%20table_md%20%3D%20f%22%23%23%23%20%7Btitle%7D%5Cn%5Cn%7C%20Milestone%20%7C%20Value%20%7C%5Cn%7C-----------%7C-------%7C%5Cn%22%0A%20%20%20%20%20%20%20%20for%20key%2C%20value%20in%20milestones.items()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20table_md%20%2B%3D%20f%22%7C%20%7Bkey%7D%20%7C%20%7Bvalue%7D%20%7C%5Cn%22%0A%20%20%20%20%20%20%20%20return%20table_md%0A%0A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20milestones_to_table(%0A%20%20%20%20%20%20%20%20%20%20%20%20master_milestones%2C%20%22Global%20Nursing%20Home%20Scenario%20Milestones%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%20(milestones_to_table%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%202%3A%20Messy%20Collapse%0A%0A%20%20%20%20Accelerated%20fertility%20decline%20driven%20by%20compounding%20cultural%2Feconomic%20factors.%20When%20population%20falls%20below%20the%20dynamically-reducing%20complexity%20threshold%2C%20civilization%20collapses%20into%20a%2030-year%20transition%20to%20pre-industrial%20conditions.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**TFR%20acceleration**%3A%20Decline%20velocity%20increases%20from%200.0058%20to%20max%200.065%20via%20acceleration%20factor%20~0.0016%2Fyear%C2%B2%0A%20%20%20%20-%20**Post-collapse%20rebound**%3A%2030-year%20linear%20transition%20from%20TFR%200.72%20%E2%86%92%205.5%20and%20modern%20%E2%86%92%203%C3%97%20pre-industrial%20mortality%0A%20%20%20%20-%20**Dynamic%20threshold**%3A%20Reduces%20by%2043.3M%20%C3%97%20(0.8%20-%20DR)%20annually%20pre-collapse%2C%20freezes%20at%20collapse%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%209.28B%20(2050)%20%E2%86%92%20TFR%20floor%202059%20%E2%86%92%20Innovation%20death%202098%20%E2%86%92%20Collapse%202170%20%E2%86%92%20Nadir%200.17B%20(2208).%20Acceleration%20brings%20collapse%20167%20years%20sooner%20than%20gradual%20decline.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20SIMULATION_YEARS%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_accelerated_shredder_simulation()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20TFR_VELOCITY_START%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%0A%20%20%20%20%20%20%20%20pop%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%0A%20%20%20%20%20%20%20%20pop%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%0A%20%20%20%20%20%20%20%20pop%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%0A%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(SIMULATION_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_pop%20%3D%20np.sum(pop)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20for%20collapse%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%20and%20current_pop%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20and%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20(1%20-%20alpha)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20elif%20collapse_year%20and%20transition_counter%20%3E%3D%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr%20-%20current_tfr_velocity)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20tfr%20%3E%20TFR_FLOOR_SECULAR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20min(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%2B%20TFR_ACCELERATION%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20working_age%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dependents%20%3D%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr%20%3D%20dependents%20%2F%20working_age%20if%20working_age%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20for%20innovation%20death%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20innovation_death_year%20is%20None%20and%20dr%20%3E%3D%20INNOVATION_DEATH_DR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dr)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Population%22%3A%20current_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%22%3A%20tfr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR%22%3A%20dr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Population%20dynamics%0A%20%20%20%20%20%20%20%20%20%20%20%20females%20%3D%20pop%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20births%20%3D%20np.sum(females%20*%20ASFR_SHAPE%20*%20tfr)%0A%20%20%20%20%20%20%20%20%20%20%20%20deaths%20%3D%20pop%20*%20current_mr%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B0%5D%20%3D%20births%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B1%3A%5D%20%3D%20pop%5B%3A-1%5D%20-%20deaths%5B%3A-1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20pop%20%3D%20new_pop%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20milestones%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_row%20%3D%20df_pre_collapse.loc%5Bdf_pre_collapse%5B%22Population%22%5D.idxmax()%5D%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20innovation_death_actual_year%20%3D%20df%5Bdf%5B%22DR%22%5D%20%3E%20INNOVATION_DEATH_DR%5D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%0A%20%20%20%20%20%20%20%20%5D.min()%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Population%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22Messy%20Collapse%20(Dynamic%20Threshold)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_row%5B'Population'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Dynamic%20Threshold)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Population'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Plotting%0A%20%20%20%20%20%20%20%20plt.figure(figsize%3D(14%2C%208))%0A%20%20%20%20%20%20%20%20plt.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Population%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%23FF4500%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Population%20(Billion)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Dynamic%20Complexity%20Threshold%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Absolute%20Floor%20(%7BABSOLUTE_MINIMUM_FLOOR%20%2F%201e6%3A.0f%7DM)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20%3C%202.1%20(%7Bint(sub_replacement_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_floor_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20Floor%20(%7Bint(tfr_floor_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20plt.title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%202%3A%20Messy%20Collapse%20(Dynamic%20Threshold)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D15%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontweight%3D%22bold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20plt.xlabel(%22Year%22%2C%20fontsize%3D12)%0A%20%20%20%20%20%20%20%20plt.ylabel(%22Population%20(Billions)%22%2C%20fontsize%3D12)%0A%20%20%20%20%20%20%20%20plt.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D9)%0A%20%20%20%20%20%20%20%20plt.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20plt.xlim(START_YEAR%2C%202300)%0A%20%20%20%20%20%20%20%20plt.ylim(0%2C%2011)%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20accelerated_milestones%2C%20accelerated_df%20%3D%20run_accelerated_shredder_simulation()%0A%20%20%20%20accelerated_milestones%0A%20%20%20%20return%20(accelerated_milestones%2C)%0A%0A%0A%40app.cell%0Adef%20_(accelerated_milestones%2C%20milestones_to_table%2C%20mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20milestones_to_table(%0A%20%20%20%20%20%20%20%20%20%20%20%20accelerated_milestones%2C%20%22Messy%20Collapse%20Scenario%20Milestones%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%203%3A%20Amish%20Crossover%0A%0A%20%20%20%20A%20high-fertility%20fundamentalist%20minority%20(3.5M%20people%2C%20TFR%206.5)%20grows%20while%20the%20secular%20majority%20collapses.%20Tests%20whether%20demographic%20momentum%20can%20outrun%20civilizational%20collapse%20when%20innovation%20delays%20the%20threshold%20breach.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**Two-population%20model**%3A%20Separate%20secular%20(accelerated%20decline)%20and%20fundamentalist%20(high%20TFR)%20populations%0A%20%20%20%20-%20**Secular-only%20collapse%20trigger**%3A%20Complexity%20breach%20occurs%20when%20secular%20population%20%3C%20threshold%20(fundamentalists%20don't%20count)%0A%20%20%20%20-%20**Defection%20dynamics**%3A%2015%25%20%E2%86%92%202%25%20defection%20from%20fundamentalist%20to%20secular%20as%20fund%2Fsec%20ratio%20approaches%201.0%0A%20%20%20%20-%20**Shared%20collapse**%3A%20Both%20populations%20experience%20post-collapse%20mortality%20tripling%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%209.28B%20(2050)%20%E2%86%92%20Secular%20collapse%202171%20%E2%86%92%20Crossover%202184%20%E2%86%92%20Nadir%200.68B%20(2187).%20High-fertility%20subculture%20inherits%20the%20future%20when%20innovation%20delays%20collapse%20by%2073%20years.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20BASE_ATTRITION_RATE%2C%0A%20%20%20%20FUNDAMENTALIST_TFR_VELOCITY%2C%0A%20%20%20%20FUND_POP_0_14%2C%0A%20%20%20%20FUND_POP_15_24%2C%0A%20%20%20%20FUND_POP_25_64%2C%0A%20%20%20%20FUND_POP_65_PLUS%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20MINORITY_ATTRITION_RATE%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20SIMULATION_YEARS%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_FUNDAMENTALIST_FLOOR%2C%0A%20%20%20%20TFR_FUNDAMENTALIST_START%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_crossover_simulation()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%20%20%20%20%20%20%20%20tfr_sec%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20tfr_fund%20%3D%20TFR_FUNDAMENTALIST_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20TFR_VELOCITY_START%20%20%23%20Track%20velocity%20for%20acceleration%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20fundamentalist%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop_fund%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop_fund%5B0%3A15%5D%20%3D%20FUND_POP_0_14%0A%20%20%20%20%20%20%20%20pop_fund%5B15%3A25%5D%20%3D%20FUND_POP_15_24%0A%20%20%20%20%20%20%20%20pop_fund%5B25%3A65%5D%20%3D%20FUND_POP_25_64%0A%20%20%20%20%20%20%20%20pop_fund%5B65%3A101%5D%20%3D%20FUND_POP_65_PLUS%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20secular%20population%20as%20TOTAL%20minus%20fundamentalist%0A%20%20%20%20%20%20%20%20%23%20Using%20the%20pre-calculated%20constants%20minus%20fundamentalist%20populations%0A%20%20%20%20%20%20%20%20pop_sec%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop_sec%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%20-%20FUND_POP_0_14%0A%20%20%20%20%20%20%20%20pop_sec%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%20-%20FUND_POP_15_24%0A%20%20%20%20%20%20%20%20pop_sec%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%20-%20FUND_POP_25_64%0A%20%20%20%20%20%20%20%20pop_sec%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%20-%20FUND_POP_65_PLUS%0A%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(SIMULATION_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_sec%20%3D%20np.sum(pop_sec)%0A%20%20%20%20%20%20%20%20%20%20%20%20current_fund%20%3D%20np.sum(pop_fund)%0A%20%20%20%20%20%20%20%20%20%20%20%20total_pop%20%3D%20current_sec%20%2B%20current_fund%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Check%20for%20collapse%20trigger%20-%20ONLY%20using%20secular%20population%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%20and%20current_sec%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Calculate%20dependency%20ratio%20ONLY%20for%20secular%20population%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_sec%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop_sec%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_sec%20%3D%20np.sum(pop_sec%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop_sec%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_secular%20%3D%20deps_sec%20%2F%20workers_sec%20if%20workers_sec%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Determine%20mortality%20rates%20for%20each%20population%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_sec%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_sec%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_fund%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_sec%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_sec%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_fund%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_sec%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr_fund%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20BUG%20FIX%3A%20Use%20current_tfr_velocity%20instead%20of%20constant%20TFR_VELOCITY_START%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_sec%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr_sec%20-%20current_tfr_velocity)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20tfr_sec%20%3E%20TFR_FLOOR_SECULAR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20min(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%20current_tfr_velocity%20%2B%20TFR_ACCELERATION%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Continuous%20defection%20reduction%20as%20fundamentalists%20approach%20demographic%20parity%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20current_sec%20%3E%200%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fund_sec_ratio%20%3D%20current_fund%20%2F%20current_sec%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ratio_capped%20%3D%20min(fund_sec_ratio%2C%201.0)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20attrition_rate%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20BASE_ATTRITION_RATE%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20(BASE_ATTRITION_RATE%20-%20MINORITY_ATTRITION_RATE)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20*%20ratio_capped%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20attrition_rate%20%3D%20MINORITY_ATTRITION_RATE%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dr_secular)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Secular_Pop%22%3A%20current_sec%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Fund_Pop%22%3A%20current_fund%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Total_Pop%22%3A%20total_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR%22%3A%20dr_secular%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR_Sec%22%3A%20tfr_sec%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR_Fund%22%3A%20tfr_fund%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Attrition_Rate%22%3A%20attrition_rate%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Secular%20population%20dynamics%0A%20%20%20%20%20%20%20%20%20%20%20%20new_sec%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_sec%5B0%5D%20%3D%20np.sum(pop_sec%20%2F%202%20*%20ASFR_SHAPE%20*%20tfr_sec)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_sec%5B1%3A%5D%20%3D%20pop_sec%5B%3A-1%5D%20-%20pop_sec%5B%3A-1%5D%20*%20current_mr_sec%5B%3A-1%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Fundamentalist%20population%20dynamics%0A%20%20%20%20%20%20%20%20%20%20%20%20new_fund%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_fund%5B0%5D%20%3D%20np.sum(pop_fund%20%2F%202%20*%20ASFR_SHAPE%20*%20tfr_fund)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_fund%5B1%3A%5D%20%3D%20pop_fund%5B%3A-1%5D%20-%20pop_fund%5B%3A-1%5D%20*%20current_mr_fund%5B%3A-1%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Defection%20from%20fundamentalist%20to%20secular%20(age%2018)%0A%20%20%20%20%20%20%20%20%20%20%20%20defectors%20%3D%20new_fund%5B18%5D%20*%20attrition_rate%0A%20%20%20%20%20%20%20%20%20%20%20%20new_fund%5B18%5D%20-%3D%20defectors%0A%20%20%20%20%20%20%20%20%20%20%20%20new_sec%5B18%5D%20%2B%3D%20defectors%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20pop_sec%2C%20pop_fund%20%3D%20new_sec%2C%20new_fund%0A%20%20%20%20%20%20%20%20%20%20%20%20tfr_fund%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20TFR_FUNDAMENTALIST_FLOOR%2C%20tfr_fund%20-%20FUNDAMENTALIST_TFR_VELOCITY%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20milestones%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_row%20%3D%20df_pre_collapse.loc%5Bdf_pre_collapse%5B%22Total_Pop%22%5D.idxmax()%5D%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR_Sec%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR_Sec%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20df%5Bdf%5B%22DR%22%5D%20%3E%20INNOVATION_DEATH_DR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Total_Pop%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20crossover_df%20%3D%20df%5Bdf%5B%22Fund_Pop%22%5D%20%3E%20df%5B%22Secular_Pop%22%5D%5D%0A%20%20%20%20%20%20%20%20crossover_year%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20crossover_df.iloc%5B0%5D%5B%22Year%22%5D%20if%20not%20crossover_df.empty%20else%20None%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20valley_duration%20%3D%20int(nadir_row%5B%22Year%22%5D%20-%20peak_row%5B%22Year%22%5D)%0A%20%20%20%20%20%20%20%20valley_depth_pct%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%201%20-%20nadir_row%5B%22Total_Pop%22%5D%20%2F%20peak_row%5B%22Total_Pop%22%5D%0A%20%20%20%20%20%20%20%20)%20*%20100%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22Amish%20Crossover%20(Dynamic%20Threshold)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Crossover%20Year%20(Fund%20%3E%20Sec)%22%3A%20int(crossover_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20crossover_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Secular%20Pop)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Valley%20of%20Death%20Duration%22%3A%20f%22%7Bvalley_duration%7D%20years%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Valley%20Depth%22%3A%20f%22%7Bvalley_depth_pct%3A.1f%7D%25%22%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Plotting%0A%20%20%20%20%20%20%20%20fig%2C%20(ax1%2C%20ax2)%20%3D%20plt.subplots(2%2C%201%2C%20figsize%3D(14%2C%2012))%0A%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Secular_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Secular%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%23FF4500%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Fund_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Fundamentalist%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%23006400%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2.5%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Total_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Total%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Threshold%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Absolute%20Floor%20(%7BABSOLUTE_MINIMUM_FLOOR%20%2F%201e6%3A.0f%7DM)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20if%20crossover_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20crossover_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22-.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.7%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Crossover%20(%7Bint(crossover_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax1.set_title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%203%3A%20Amish%20Crossover%22%2C%20fontsize%3D14%2C%20fontweight%3D%22bold%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.set_ylabel(%22Population%20(Billions)%22)%0A%20%20%20%20%20%20%20%20ax1.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D8)%0A%20%20%20%20%20%20%20%20ax1.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20ax1.set_xlim(START_YEAR%2C%202300)%0A%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%20df%5B%22DR%22%5D%2C%20color%3D%22blue%22%2C%20linewidth%3D2.5%2C%20label%3D%22Secular%20DR%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22red%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20Threshold%20(%7BINNOVATION_DEATH_DR%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.set_xlabel(%22Year%22)%0A%20%20%20%20%20%20%20%20ax2.set_ylabel(%22Dependency%20Ratio%22)%0A%20%20%20%20%20%20%20%20ax2.legend(loc%3D%22upper%20left%22)%0A%20%20%20%20%20%20%20%20ax2.grid(True%2C%20alpha%3D0.3)%0A%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20crossover_milestones%2C%20crossover_df%20%3D%20run_crossover_simulation()%0A%20%20%20%20crossover_milestones%0A%20%20%20%20return%20(crossover_milestones%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(crossover_milestones%2C%20milestones_to_table%2C%20mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20milestones_to_table(%0A%20%20%20%20%20%20%20%20%20%20%20%20crossover_milestones%2C%20%22Amish%20Crossover%20Scenario%20Milestones%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%204%3A%20Healthspan%0A%0A%20%20%20%20Radical%20healthspan%20extension%20(biological%20aging%20reversal)%20arrives%20in%202070%2C%20extending%20productive%20working%20life%20from%20age%2065%20to%2085.%20Tests%20whether%20longer%20working%20lifespans%20can%20buffer%20dependency%20ratios%20enough%20to%20prevent%20or%20delay%20civilizational%20collapse.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**Working%20age%20extension**%3A%20Standard%2015-65%20expands%20to%2015-85%20via%20S-curve%20adoption%20(14%20phases%2C%201%25%20%E2%86%92%2099.5%25)%0A%20%20%20%20-%20**DR%20calculation**%3A%20Dependency%20ratio%20uses%20extended%20working%20population%20when%20healthspan%20adopted%0A%20%20%20%20-%20**Same%20fertility%20collapse**%3A%20TFR%20still%20accelerates%20to%20floor%200.72%20by%202059%20(healthspan%20doesn't%20affect%20fertility)%0A%20%20%20%20-%20**Dynamic%20threshold**%3A%20Continues%20reducing%20by%2043.3M%20%C3%97%20(0.8%20-%20DR)%20while%20DR%20%3C%200.8%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%209.28B%20(2050)%20%E2%86%92%20TFR%20floor%202059%20%E2%86%92%20Complexity%20breach%202218%20%E2%86%92%20Innovation%20death%202224%20%E2%86%92%20Nadir%200.03B%20(2256).%20Healthspan%20delays%20collapse%20by%2048%20years%20but%20cannot%20prevent%20it%20without%20fertility%20intervention.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20ADOPTION_CURVE%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20EXTENDED_WORKING_AGE_END%2C%0A%20%20%20%20EXTENDED_YEARS%2C%0A%20%20%20%20HEALTHSPAN_BREAKTHROUGH_YEAR%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_scurve_healthspan_simulation_refined()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20TFR_VELOCITY_START%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%0A%20%20%20%20%20%20%20%20pop%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%0A%20%20%20%20%20%20%20%20pop%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%0A%20%20%20%20%20%20%20%20pop%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%0A%0A%20%20%20%20%20%20%20%20%23%20EXTENDED%20SIMULATION%3A%20Run%20for%20374%20years%20(2026-2400)%20to%20see%20full%20trajectory%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(EXTENDED_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_pop%20%3D%20np.sum(pop)%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_std%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_std%20%3D%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_baseline%20%3D%20deps_std%20%2F%20workers_std%20if%20workers_std%20%3E%200%20else%200%0A%20%20%20%20%20%20%20%20%20%20%20%20years_since%20%3D%20current_year%20-%20HEALTHSPAN_BREAKTHROUGH_YEAR%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20current_year%20%3C%20HEALTHSPAN_BREAKTHROUGH_YEAR%20or%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20and%20current_year%20%3E%20collapse_year%20%2B%205%0A%20%20%20%20%20%20%20%20%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%200.0%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ADOPTION_CURVE%5Byears_since%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20years_since%20%3C%20len(ADOPTION_CURVE)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%201.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_actual%20%3D%20workers_std%20%2B%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5BSTANDARD_WORKING_AGE_START%3AEXTENDED_WORKING_AGE_END%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20workers_std%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_actual%20%3D%20deps_std%20-%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20deps_std%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20np.sum(pop%5BEXTENDED_WORKING_AGE_END%3A101%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_actual%20%3D%20deps_actual%20%2F%20workers_actual%20if%20workers_actual%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20innovation_death_year%20is%20None%20and%20dr_actual%20%3E%3D%20INNOVATION_DEATH_DR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20current_pop%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr%20-%20current_tfr_velocity)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20tfr%20%3E%20TFR_FLOOR_SECULAR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20min(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%2B%20TFR_ACCELERATION%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dr_actual)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Total_Pop%22%3A%20current_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR%22%3A%20dr_actual%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR_Baseline%22%3A%20dr_baseline%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%22%3A%20tfr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20females%20%3D%20pop%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20births%20%3D%20np.sum(females%20*%20ASFR_SHAPE%20*%20tfr)%0A%20%20%20%20%20%20%20%20%20%20%20%20deaths%20%3D%20pop%20*%20current_mr%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B0%5D%20%3D%20births%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B1%3A%5D%20%3D%20pop%5B%3A-1%5D%20-%20deaths%5B%3A-1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20pop%20%3D%20new_pop%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20milestones%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_row%20%3D%20df_pre_collapse.loc%5Bdf_pre_collapse%5B%22Total_Pop%22%5D.idxmax()%5D%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20innovation_death_actual_year%20%3D%20df%5Bdf%5B%22DR%22%5D%20%3E%20INNOVATION_DEATH_DR%5D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%0A%20%20%20%20%20%20%20%20%5D.min()%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Total_Pop%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22Healthspan%20(Dynamic%20Threshold%2C%20Extended)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Dynamic%20Threshold)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Plotting%0A%20%20%20%20%20%20%20%20fig%2C%20(ax1%2C%20ax2)%20%3D%20plt.subplots(2%2C%201%2C%20figsize%3D(12%2C%2012))%0A%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Total_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%231E90FF%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Global%20Population%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Dynamic%20Complexity%20Threshold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Absolute%20Floor%20(%7BABSOLUTE_MINIMUM_FLOOR%20%2F%201e6%3A.0f%7DM)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20%3C%202.1%20(%7Bint(sub_replacement_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_floor_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20Floor%20(%7Bint(tfr_floor_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax1.set_title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%204%3A%20Healthspan%20with%20Dynamic%20Innovation-Driven%20Threshold%20(Extended%20to%202400)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D14%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontweight%3D%22bold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.set_ylabel(%22Population%20(Billions)%22)%0A%20%20%20%20%20%20%20%20ax1.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D8)%0A%20%20%20%20%20%20%20%20ax1.grid(True%2C%20alpha%3D0.3)%0A%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22DR%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Actual%20DR%20(Healthspan%20%2B%20Automation)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22DR_Baseline%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Baseline%20DR%20(Counterfactual)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22red%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20Threshold%20(%7BINNOVATION_DEATH_DR%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax2.axvline(peak_row%5B%22Year%22%5D%2C%20color%3D%22darkgreen%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%20color%3D%22orange%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(tfr_floor_year%2C%20color%3D%22blue%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%3D150%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3D%22X%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zorder%3D5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(collapse_year%2C%20color%3D%22darkred%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20ax2.axvline(nadir_row%5B%22Year%22%5D%2C%20color%3D%22cyan%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%0A%20%20%20%20%20%20%20%20ax2.set_xlabel(%22Year%22)%0A%20%20%20%20%20%20%20%20ax2.set_ylabel(%22Dependency%20Ratio%22)%0A%20%20%20%20%20%20%20%20ax2.legend(loc%3D%22upper%20left%22)%0A%20%20%20%20%20%20%20%20ax2.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20healthspan_milestones%2C%20healthspan_df%20%3D%20(%0A%20%20%20%20%20%20%20%20run_scurve_healthspan_simulation_refined()%0A%20%20%20%20)%0A%20%20%20%20healthspan_milestones%0A%20%20%20%20return%20(healthspan_milestones%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(healthspan_milestones%2C%20milestones_to_table%2C%20mo)%3A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20milestones_to_table(%0A%20%20%20%20%20%20%20%20%20%20%20%20healthspan_milestones%2C%20%22Healthspan%20Scenario%20Milestones%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%205%3A%20Ectogenesis%20%26%20Healthspan%20Synergy%0A%0A%20%20%20%20Radical%20healthspan%20extension%20(2070)%20combined%20with%20artificial%20womb%20technology%20(ectogenesis%2C%202120)%20adding%2010M%20artificial%20births%20annually.%20The%20only%20scenario%20preventing%20civilizational%20collapse%20entirely.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**Dual%20birth%20sources**%3A%20Natural%20fertility%20(collapsing%20to%200.72)%20%2B%2010M%2Fyear%20ectogenesis%20births%20starting%202120%0A%20%20%20%20-%20**Working%20age%20extension**%3A%2015-85%20via%20healthspan%20S-curve%20(same%20as%20Scenario%204)%0A%20%20%20%20-%20**DR%20calculation**%3A%20Uses%20extended%20working%20population%3B%20never%20reaches%200.8%20threshold%0A%20%20%20%20-%20**No%20collapse**%3A%20Population%20stabilizes%20at%201.06B%20nadir%20(2181)%2C%20never%20breaches%20complexity%20threshold%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%209.28B%20(2050)%20%E2%86%92%20TFR%20floor%202059%20%E2%86%92%20Population%20nadir%201.06B%20(2181)%20%E2%86%92%20Stabilization%20above%20threshold.%20Ectogenesis%20succeeds%20where%20healthspan%20alone%20fails%3B%20industrialized%20reproduction%20prevents%20demographic%20collapse.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20ADOPTION_CURVE%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20ECTOGENESIS_ANNUAL_PRODUCTION%2C%0A%20%20%20%20ECTOGENESIS_START_YEAR%2C%0A%20%20%20%20EXTENDED_WORKING_AGE_END%2C%0A%20%20%20%20HEALTHSPAN_BREAKTHROUGH_YEAR%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20SIMULATION_YEARS%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_ectogenesis_simulation()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20TFR_VELOCITY_START%0A%20%20%20%20%20%20%20%20ecto_annual_production%20%3D%20ECTOGENESIS_ANNUAL_PRODUCTION%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%0A%20%20%20%20%20%20%20%20pop%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%0A%20%20%20%20%20%20%20%20pop%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%0A%20%20%20%20%20%20%20%20pop%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%0A%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(SIMULATION_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_pop%20%3D%20np.sum(pop)%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_std%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_std%20%3D%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_baseline%20%3D%20deps_std%20%2F%20workers_std%20if%20workers_std%20%3E%200%20else%200%0A%20%20%20%20%20%20%20%20%20%20%20%20years_since%20%3D%20current_year%20-%20HEALTHSPAN_BREAKTHROUGH_YEAR%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20current_year%20%3C%20HEALTHSPAN_BREAKTHROUGH_YEAR%20or%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20and%20current_year%20%3E%20collapse_year%20%2B%205%0A%20%20%20%20%20%20%20%20%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%200.0%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ADOPTION_CURVE%5Byears_since%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20years_since%20%3C%20len(ADOPTION_CURVE)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%201.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_actual%20%3D%20workers_std%20%2B%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5BSTANDARD_WORKING_AGE_START%3AEXTENDED_WORKING_AGE_END%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20workers_std%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_actual%20%3D%20deps_std%20-%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20deps_std%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20np.sum(pop%5BEXTENDED_WORKING_AGE_END%3A101%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_actual%20%3D%20deps_actual%20%2F%20workers_actual%20if%20workers_actual%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20innovation_death_year%20is%20None%20and%20dr_actual%20%3E%3D%20INNOVATION_DEATH_DR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20BUG%20FIX%3A%20Collapse%20happens%20when%20pop%20%3C%20threshold%2C%20regardless%20of%20innovation%20death%20status%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20current_pop%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ecto_annual_production%20%3D%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr%20-%20current_tfr_velocity)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20tfr%20%3E%20TFR_FLOOR_SECULAR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20min(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%2B%20TFR_ACCELERATION%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dr_actual)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Total_Pop%22%3A%20current_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR%22%3A%20dr_actual%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR_Baseline%22%3A%20dr_baseline%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%22%3A%20tfr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20females%20%3D%20pop%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20natural_births%20%3D%20np.sum(females%20*%20ASFR_SHAPE%20*%20tfr)%0A%20%20%20%20%20%20%20%20%20%20%20%20total_births%20%3D%20natural_births%20%2B%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ecto_annual_production%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20current_year%20%3E%3D%20ECTOGENESIS_START_YEAR%20and%20(not%20collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%200%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deaths%20%3D%20pop%20*%20current_mr%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B0%5D%20%3D%20total_births%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B1%3A%5D%20%3D%20pop%5B%3A-1%5D%20-%20deaths%5B%3A-1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20pop%20%3D%20new_pop%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_row%20%3D%20df_pre_collapse.loc%5Bdf_pre_collapse%5B%22Total_Pop%22%5D.idxmax()%5D%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20innovation_death_actual_year%20%3D%20df%5Bdf%5B%22DR%22%5D%20%3E%20INNOVATION_DEATH_DR%5D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%0A%20%20%20%20%20%20%20%20%5D.min()%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Total_Pop%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22Ectogenesis%20(Dynamic%20Threshold)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Dynamic%20Threshold)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Plotting%0A%20%20%20%20%20%20%20%20fig%2C%20(ax1%2C%20ax2)%20%3D%20plt.subplots(2%2C%201%2C%20figsize%3D(12%2C%2012))%0A%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Total_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%231E90FF%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Global%20Population%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Dynamic%20Complexity%20Threshold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20ABSOLUTE_MINIMUM_FLOOR%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22black%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Absolute%20Floor%20(%7BABSOLUTE_MINIMUM_FLOOR%20%2F%201e6%3A.0f%7DM)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20%3C%202.1%20(%7Bint(sub_replacement_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_floor_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20Floor%20(%7Bint(tfr_floor_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax1.set_title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%205%3A%20Ectogenesis%20%26%20Healthspan%20with%20Dynamic%20Threshold%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D14%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontweight%3D%22bold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.set_ylabel(%22Population%20(Billions)%22)%0A%20%20%20%20%20%20%20%20ax1.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D8)%0A%20%20%20%20%20%20%20%20ax1.grid(True%2C%20alpha%3D0.3)%0A%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%20df%5B%22DR%22%5D%2C%20color%3D%22blue%22%2C%20linewidth%3D2%2C%20label%3D%22Actual%20DR%22%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22DR_Baseline%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Baseline%20DR%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22red%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20Threshold%20(%7BINNOVATION_DEATH_DR%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax2.axvline(peak_row%5B%22Year%22%5D%2C%20color%3D%22darkgreen%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%20color%3D%22orange%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(tfr_floor_year%2C%20color%3D%22blue%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%3D150%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3D%22X%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zorder%3D5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(collapse_year%2C%20color%3D%22darkred%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20ax2.axvline(nadir_row%5B%22Year%22%5D%2C%20color%3D%22cyan%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%0A%20%20%20%20%20%20%20%20ax2.set_xlabel(%22Year%22)%0A%20%20%20%20%20%20%20%20ax2.set_ylabel(%22Dependency%20Ratio%22)%0A%20%20%20%20%20%20%20%20ax2.legend(loc%3D%22upper%20left%22)%0A%20%20%20%20%20%20%20%20ax2.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20ecto_milestones%2C%20ecto_df%20%3D%20run_ectogenesis_simulation()%0A%20%20%20%20ecto_milestones%0A%20%20%20%20return%20(ecto_milestones%2C)%0A%0A%0A%40app.cell%0Adef%20_(ecto_milestones%2C%20milestones_to_table%2C%20mo)%3A%0A%20%20%20%20mo.md(milestones_to_table(ecto_milestones%2C%20%22Ectogenesis%20Scenario%20Milestones%22))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Scenario%206%3A%20The%20AGI%20Rescue%0A%0A%20%20%20%20Radical%20healthspan%20extension%20(2070)%20combined%20with%20the%20emergence%20of%20Artificial%20General%20Intelligence%20that%20eliminates%20the%20need%20for%20human%20labor%20to%20maintain%20civilization.%20The%20complexity%20threshold%20can%20decline%20to%20zero%E2%80%94no%20minimum%20population%20floor%20required.%0A%0A%20%20%20%20**Novel%20Mechanics%3A**%0A%20%20%20%20-%20**Zero%20minimum%20threshold**%3A%20AGI%20automation%20allows%20%60ABSOLUTE_MINIMUM_FLOOR%20%3D%200%60%20(was%20100M)%0A%20%20%20%20-%20**Same%20healthspan%20mechanics**%3A%20Working%20age%20extends%2015%E2%86%9285%20via%20S-curve%20adoption%20starting%202070%0A%20%20%20%20-%20**Same%20fertility%20collapse**%3A%20TFR%20accelerates%20to%20floor%200.72%20by%202059%20(AGI%20doesn't%20affect%20fertility)%0A%20%20%20%20-%20**Threshold%20dynamics**%3A%20Complexity%20threshold%20can%20reduce%20to%20zero%20as%20innovation%20surplus%20is%20maintained%20indefinitely%20(DR%20never%20reaches%200.8)%0A%0A%20%20%20%20**Key%20Result**%3A%20Peak%209.28B%20(2050)%20%E2%86%92%20TFR%20floor%202059%20%E2%86%92%20Population%20nadir%20~50M%20(2200s)%20%E2%86%92%20Potential%20stabilization%20at%20very%20low%20levels.%20AGI%20eliminates%20the%20hard%20population%20floor%2C%20allowing%20indefinite%20maintenance%20of%20civilization%20with%20minimal%20human%20population.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(%0A%20%20%20%20ADOPTION_CURVE%2C%0A%20%20%20%20ASFR_SHAPE%2C%0A%20%20%20%20AUTOMATION_FACTOR%2C%0A%20%20%20%20EXTENDED_WORKING_AGE_END%2C%0A%20%20%20%20EXTENDED_YEARS%2C%0A%20%20%20%20HEALTHSPAN_BREAKTHROUGH_YEAR%2C%0A%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%2C%0A%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20MR_MODERN%2C%0A%20%20%20%20MR_PRE_INDUSTRIAL%2C%0A%20%20%20%20POP_INITIAL_0_14%2C%0A%20%20%20%20POP_INITIAL_15_24%2C%0A%20%20%20%20POP_INITIAL_25_64%2C%0A%20%20%20%20POP_INITIAL_65_PLUS%2C%0A%20%20%20%20PRE_INDUSTRIAL_TFR%2C%0A%20%20%20%20STANDARD_WORKING_AGE_END%2C%0A%20%20%20%20STANDARD_WORKING_AGE_START%2C%0A%20%20%20%20START_YEAR%2C%0A%20%20%20%20TFR_ACCELERATION%2C%0A%20%20%20%20TFR_FLOOR_SECULAR%2C%0A%20%20%20%20TFR_REPLACEMENT%2C%0A%20%20%20%20TFR_START%2C%0A%20%20%20%20TFR_VELOCITY_START%2C%0A%20%20%20%20TRANSITION_PERIOD%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A)%3A%0A%20%20%20%20def%20run_agi_rescue_simulation()%3A%0A%20%20%20%20%20%20%20%20%23%20---%20Uses%20shared%20constants%20from%20constants%20cell%20---%0A%20%20%20%20%20%20%20%20%23%20Key%20difference%3A%20AGI%20allows%20complexity%20threshold%20to%20reach%20ZERO%0A%0A%20%20%20%20%20%20%20%20AGI_MINIMUM_FLOOR%20%3D%200%20%20%23%20AGI%20eliminates%20the%20minimum%20population%20requirement%0A%0A%20%20%20%20%20%20%20%20%23%20Local%20tracking%20variables%0A%20%20%20%20%20%20%20%20history%20%3D%20%5B%5D%0A%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_START%0A%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20INITIAL_COMPLEXITY_THRESHOLD%0A%20%20%20%20%20%20%20%20collapse_year%20%3D%20None%0A%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20None%0A%20%20%20%20%20%20%20%20transition_counter%20%3D%200%0A%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20TFR_VELOCITY_START%0A%0A%20%20%20%20%20%20%20%20%23%20Initialize%20population%20using%20shared%20constants%0A%20%20%20%20%20%20%20%20pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20pop%5B0%3A15%5D%20%3D%20POP_INITIAL_0_14%0A%20%20%20%20%20%20%20%20pop%5B15%3A25%5D%20%3D%20POP_INITIAL_15_24%0A%20%20%20%20%20%20%20%20pop%5B25%3A65%5D%20%3D%20POP_INITIAL_25_64%0A%20%20%20%20%20%20%20%20pop%5B65%3A101%5D%20%3D%20POP_INITIAL_65_PLUS%0A%0A%20%20%20%20%20%20%20%20%23%20EXTENDED%20SIMULATION%3A%20Run%20for%20374%20years%20(2026-2400)%20to%20see%20full%20trajectory%0A%20%20%20%20%20%20%20%20for%20y%20in%20range(EXTENDED_YEARS)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20current_year%20%3D%20START_YEAR%20%2B%20y%0A%20%20%20%20%20%20%20%20%20%20%20%20current_pop%20%3D%20np.sum(pop)%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_std%20%3D%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_START%3ASTANDARD_WORKING_AGE_END%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_std%20%3D%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%20%2B%20np.sum(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pop%5BSTANDARD_WORKING_AGE_END%3A101%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_baseline%20%3D%20deps_std%20%2F%20workers_std%20if%20workers_std%20%3E%200%20else%200%0A%20%20%20%20%20%20%20%20%20%20%20%20years_since%20%3D%20current_year%20-%20HEALTHSPAN_BREAKTHROUGH_YEAR%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20current_year%20%3C%20HEALTHSPAN_BREAKTHROUGH_YEAR%20or%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20and%20current_year%20%3E%20collapse_year%20%2B%205%0A%20%20%20%20%20%20%20%20%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%200.0%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20adoption_rate%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ADOPTION_CURVE%5Byears_since%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20years_since%20%3C%20len(ADOPTION_CURVE)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%201.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20workers_actual%20%3D%20workers_std%20%2B%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5BSTANDARD_WORKING_AGE_START%3AEXTENDED_WORKING_AGE_END%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20workers_std%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20deps_actual%20%3D%20deps_std%20-%20adoption_rate%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20deps_std%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20np.sum(pop%5B0%3ASTANDARD_WORKING_AGE_START%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20np.sum(pop%5BEXTENDED_WORKING_AGE_END%3A101%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20dr_actual%20%3D%20deps_actual%20%2F%20workers_actual%20if%20workers_actual%20%3E%200%20else%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20innovation_death_year%20is%20None%20and%20dr_actual%20%3E%3D%20INNOVATION_DEATH_DR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20current_pop%20%3C%20complexity_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%20%3D%20current_year%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20transition_counter%20%3C%20TRANSITION_PERIOD%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20transition_counter%20%2B%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%20%3D%20transition_counter%20%2F%20TRANSITION_PERIOD%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20TFR_FLOOR_SECULAR%20%2B%20alpha%20*%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PRE_INDUSTRIAL_TFR%20-%20TFR_FLOOR_SECULAR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%201%20-%20alpha%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%20*%20MR_MODERN%20%2B%20alpha%20*%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20PRE_INDUSTRIAL_TFR%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_PRE_INDUSTRIAL%0A%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_mr%20%3D%20MR_MODERN%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr%20%3D%20max(TFR_FLOOR_SECULAR%2C%20tfr%20-%20current_tfr_velocity)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20tfr%20%3E%20TFR_FLOOR_SECULAR%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%3D%20min(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MAX_TFR_VELOCITY%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20current_tfr_velocity%20%2B%20TFR_ACCELERATION%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Dynamic%20complexity%20threshold%20(only%20reduce%20if%20not%20collapsed)%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20AGI%20allows%20threshold%20to%20reach%20ZERO%20-%20no%20minimum%20floor%0A%20%20%20%20%20%20%20%20%20%20%20%20innovation_surplus%20%3D%20max(0%2C%20INNOVATION_DEATH_DR%20-%20dr_actual)%0A%20%20%20%20%20%20%20%20%20%20%20%20annual_threshold_reduction%20%3D%20AUTOMATION_FACTOR%20*%20innovation_surplus%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%20is%20None%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20%3D%20max(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AGI_MINIMUM_FLOOR%2C%20%20%23%20Can%20go%20to%20ZERO%20with%20AGI%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20complexity_threshold%20-%20annual_threshold_reduction%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20history.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%3A%20current_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Total_Pop%22%3A%20current_pop%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR%22%3A%20dr_actual%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22DR_Baseline%22%3A%20dr_baseline%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%22%3A%20tfr%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity_Threshold%22%3A%20complexity_threshold%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation_Surplus%22%3A%20innovation_surplus%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20females%20%3D%20pop%20%2F%202%0A%20%20%20%20%20%20%20%20%20%20%20%20births%20%3D%20np.sum(females%20*%20ASFR_SHAPE%20*%20tfr)%0A%20%20%20%20%20%20%20%20%20%20%20%20deaths%20%3D%20pop%20*%20current_mr%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%20%3D%20np.zeros(101)%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B0%5D%20%3D%20births%0A%20%20%20%20%20%20%20%20%20%20%20%20new_pop%5B1%3A%5D%20%3D%20pop%5B%3A-1%5D%20-%20deaths%5B%3A-1%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20pop%20%3D%20new_pop%0A%0A%20%20%20%20%20%20%20%20df%20%3D%20pd.DataFrame(history)%0A%0A%20%20%20%20%20%20%20%20%23%20Calculate%20milestones%0A%20%20%20%20%20%20%20%20limit_year%20%3D%20collapse_year%20if%20collapse_year%20else%20df%5B%22Year%22%5D.max()%0A%20%20%20%20%20%20%20%20df_pre_collapse%20%3D%20df%5Bdf%5B%22Year%22%5D%20%3C%3D%20limit_year%5D%0A%20%20%20%20%20%20%20%20peak_row%20%3D%20df_pre_collapse.loc%5Bdf_pre_collapse%5B%22Total_Pop%22%5D.idxmax()%5D%0A%20%20%20%20%20%20%20%20sub_replacement_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%20TFR_REPLACEMENT%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20tfr_floor_year%20%3D%20df%5Bdf%5B%22TFR%22%5D%20%3C%3D%20TFR_FLOOR_SECULAR%5D%5B%22Year%22%5D.min()%0A%20%20%20%20%20%20%20%20innovation_death_actual_year%20%3D%20df%5Bdf%5B%22DR%22%5D%20%3E%20INNOVATION_DEATH_DR%5D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Year%22%0A%20%20%20%20%20%20%20%20%5D.min()%0A%20%20%20%20%20%20%20%20nadir_row%20%3D%20df.loc%5Bdf%5B%22Total_Pop%22%5D.idxmin()%5D%0A%0A%20%20%20%20%20%20%20%20final_threshold%20%3D%20df.iloc%5B-1%5D%5B%22Complexity_Threshold%22%5D%0A%20%20%20%20%20%20%20%20threshold_reduction%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20INITIAL_COMPLEXITY_THRESHOLD%20-%20final_threshold%0A%20%20%20%20%20%20%20%20)%20%2F%201e6%0A%0A%20%20%20%20%20%20%20%20milestones%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%22%3A%20%22AGI%20Rescue%20(Healthspan%20%2B%20AGI%2C%20Extended)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Pre-Collapse%20Peak%20Population%22%3A%20f%22%7Bpeak_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Peak%20Year%22%3A%20int(peak_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Below%202.1%22%3A%20int(sub_replacement_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22TFR%20Hits%200.72%20Floor%22%3A%20int(tfr_floor_year)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Innovation%20Death%20(DR%20%3E%200.8)%22%3A%20int(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22Never%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Complexity%20Breach%20(Dynamic%20Threshold)%22%3A%20int(collapse_year)%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20collapse_year%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Final%20Complexity%20Threshold%22%3A%20f%22%7Bfinal_threshold%20%2F%201e9%3A.2f%7DB%22%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20final_threshold%20%3E%200%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%220%20(AGI%20Eliminates%20Minimum)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Threshold%20Reduction%22%3A%20f%22%7Bthreshold_reduction%3A.0f%7DM%20people%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Population%20Nadir%22%3A%20f%22%7Bnadir_row%5B'Total_Pop'%5D%20%2F%201e9%3A.2f%7DB%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Nadir%20Year%22%3A%20int(nadir_row%5B%22Year%22%5D)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Plotting%0A%20%20%20%20%20%20%20%20fig%2C%20(ax1%2C%20ax2)%20%3D%20plt.subplots(2%2C%201%2C%20figsize%3D(12%2C%2012))%0A%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Total_Pop%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22%239932CC%22%2C%20%20%23%20Dark%20orchid%20for%20AGI%20theme%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D3%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Global%20Population%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Complexity_Threshold%22%5D%20%2F%201e9%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22grey%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.8%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Dynamic%20Complexity%20Threshold%20(AGI%20%E2%86%92%200)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%23%20Note%3A%20No%20absolute%20floor%20line%20since%20AGI%20allows%20threshold%20to%20reach%20zero%0A%0A%20%20%20%20%20%20%20%20%23%20Milestone%20vertical%20lines%20with%20labels%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20peak_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkgreen%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Peak%20(%7Bint(peak_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20%3C%202.1%20(%7Bint(sub_replacement_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tfr_floor_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22TFR%20Floor%20(%7Bint(tfr_floor_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20collapse_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22darkred%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Complexity%20Breach%20(%7Bint(collapse_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20nadir_row%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22cyan%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.6%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Nadir%20(%7Bint(nadir_row%5B'Year'%5D)%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax1.set_title(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Scenario%206%3A%20AGI%20Rescue%20(Healthspan%20%2B%20AGI%2C%20Extended%20to%202400)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontsize%3D14%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20fontweight%3D%22bold%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax1.set_ylabel(%22Population%20(Billions)%22)%0A%20%20%20%20%20%20%20%20ax1.legend(loc%3D%22upper%20right%22%2C%20fontsize%3D8)%0A%20%20%20%20%20%20%20%20ax1.grid(True%2C%20alpha%3D0.3)%0A%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22DR%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22blue%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Actual%20DR%20(Healthspan%20%2B%20AGI)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.plot(%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22Year%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20df%5B%22DR_Baseline%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22orange%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3D%22Baseline%20DR%20(Counterfactual)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20ax2.axhline(%0A%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22red%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20linewidth%3D2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20Threshold%20(%7BINNOVATION_DEATH_DR%7D)%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20ax2.axvline(peak_row%5B%22Year%22%5D%2C%20color%3D%22darkgreen%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(sub_replacement_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20sub_replacement_year%2C%20color%3D%22orange%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(tfr_floor_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(tfr_floor_year%2C%20color%3D%22blue%22%2C%20linestyle%3D%22%3A%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20if%20not%20np.isnan(innovation_death_actual_year)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20linestyle%3D%22--%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D0.5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20innovation_death_actual_year%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20INNOVATION_DEATH_DR%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22purple%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20s%3D150%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20marker%3D%22X%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20zorder%3D5%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20label%3Df%22Innovation%20Death%20(%7Bint(innovation_death_actual_year)%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20if%20collapse_year%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20ax2.axvline(collapse_year%2C%20color%3D%22darkred%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%20%20%20%20%20%20%20%20ax2.axvline(nadir_row%5B%22Year%22%5D%2C%20color%3D%22cyan%22%2C%20linestyle%3D%22--%22%2C%20alpha%3D0.4)%0A%0A%20%20%20%20%20%20%20%20ax2.set_xlabel(%22Year%22)%0A%20%20%20%20%20%20%20%20ax2.set_ylabel(%22Dependency%20Ratio%22)%0A%20%20%20%20%20%20%20%20ax2.legend(loc%3D%22upper%20left%22)%0A%20%20%20%20%20%20%20%20ax2.grid(True%2C%20alpha%3D0.3)%0A%20%20%20%20%20%20%20%20plt.tight_layout()%0A%20%20%20%20%20%20%20%20plt.show()%0A%0A%20%20%20%20%20%20%20%20return%20milestones%2C%20df%0A%0A%0A%20%20%20%20agi_milestones%2C%20agi_df%20%3D%20run_agi_rescue_simulation()%0A%20%20%20%20agi_milestones%0A%20%20%20%20return%20(agi_milestones%2C)%0A%0A%0A%40app.cell%0Adef%20_(agi_milestones%2C%20milestones_to_table%2C%20mo)%3A%0A%20%20%20%20mo.md(milestones_to_table(agi_milestones%2C%20%22AGI%20Rescue%20Scenario%20Milestones%22))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%20Appendix%20A%3A%20Complete%20Scenario%20Results%20Summary%0A%0A%20%20%20%20This%20appendix%20compiles%20all%20scenario%20milestones%20in%20one%20reference%20location%20for%20easy%20comparison%20and%20text%20updating.%0A%0A%20%20%20%20%23%23%20Executive%20Summary%20Table%0A%0A%20%20%20%20%7C%20Scenario%20%7C%20Collapse%3F%20%7C%20Peak%20(B)%20%7C%20Peak%20Year%20%7C%20Breach%20Year%20%7C%20Nadir%20(B)%20%7C%20Nadir%20Year%20%7C%0A%20%20%20%20%7C----------%7C-----------%7C----------%7C-----------%7C-------------%7C-----------%7C------------%7C%0A%20%20%20%20%7C%201.%20Global%20Nursing%20Home%20%7C%20Yes%20%7C%2010.33%20%7C%202084%20%7C%202337%20%7C%200.06%20%7C%202375%20%7C%0A%20%20%20%20%7C%202.%20Messy%20Collapse%20%7C%20Yes%20%7C%209.49%20%7C%202053%20%7C%202177%20%7C%200.16%20%7C%202215%20%7C%0A%20%20%20%20%7C%203.%20Amish%20Crossover%20%7C%20Yes%20%7C%209.49%20%7C%202053%20%7C%202179%20%7C%200.77%20%7C%202191%20%7C%0A%20%20%20%20%7C%204.%20Healthspan%20%7C%20Yes%20%7C%209.49%20%7C%202053%20%7C%202224%20%7C%200.03%20%7C%202262%20%7C%0A%20%20%20%20%7C%205.%20Ectogenesis%20%7C%20**No**%20%7C%209.49%20%7C%202053%20%7C%20N%2FA%20%7C%201.14%20%7C%202189%20%7C%0A%20%20%20%20%7C%206.%20AGI%20Rescue%20%7C%20**No**%20%7C%209.49%20%7C%202053%20%7C%20N%2FA%20%7C%20~0.00%20%7C%202399%20%7C%0A%0A%20%20%20%20**Key%20Finding**%3A%20Only%20Scenarios%205%20(Ectogenesis)%20and%206%20(AGI%20Rescue)%20prevent%20civilizational%20collapse.%20All%20others%20eventually%20breach%20the%20complexity%20threshold.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20Detailed%20Scenario%20Milestones%0A%0A%20%20%20%20%23%23%23%20Scenario%201%3A%20Global%20Nursing%20Home%20(Gradual%20Degrowth)%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20Global%20Nursing%20Home%20(Dynamic%20Threshold%2C%20Extended)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%2010.33B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202084%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202048%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202286%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%202226%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Dynamic%20Threshold)%20%7C%202337%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200.20B%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%201102M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%200.06B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202375%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20Linear%20TFR%20decline%20(0.0058%2Fyear%20constant%20velocity)%20creates%20slower%20trajectory%20than%20accelerated%20scenarios.%20Higher%20peak%20(10.33B%20vs%209.49B)%20due%20to%20delayed%20fertility%20decline.%20Later%20collapse%20(2337%20vs%202177)%20buys%20160%20years%20vs%20Messy%20Collapse%2C%20but%20deeper%20nadir%20(0.06B)%20due%20to%20longer%20pre-collapse%20geriatric%20phase.%20Total%20civilization%20collapse%20still%20inevitable%20without%20intervention.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Scenario%202%3A%20Messy%20Collapse%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20Messy%20Collapse%20(Dynamic%20Threshold)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%209.49B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202053%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202036%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202066%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%202104%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Dynamic%20Threshold)%20%7C%202177%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200.53B%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%20766M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%200.16B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202215%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20TFR%20acceleration%20(0.0016%2Fyear%C2%B2)%20compounds%20decline%20velocity%20from%200.0058%20to%20max%200.065.%20Earlier%20collapse%20(2177)%20reflects%20realistic%20cultural%2Feconomic%20feedback%20loops.%20Shallower%20nadir%20than%20Global%20Nursing%20Home%20due%20to%20younger%20population%20at%20collapse.%2030-year%20transition%20to%20pre-industrial%20conditions%20(TFR%200.72%20to%205.5%2C%20mortality%20triples).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Scenario%203%3A%20Amish%20Crossover%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20Amish%20Crossover%20(Dynamic%20Threshold)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%209.49B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202053%20%7C%0A%20%20%20%20%7C%20Crossover%20Year%20(Fund%20%3E%20Sec)%20%7C%202187%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202036%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202066%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%202104%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Secular%20Pop)%20%7C%202179%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200.53B%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%20766M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%200.77B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202191%20%7C%0A%20%20%20%20%7C%20Valley%20of%20Death%20Duration%20%7C%20138%20years%20%7C%0A%20%20%20%20%7C%20Valley%20Depth%20%7C%2091.9%25%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20Crossover%20occurs%20post-collapse%20(2187%20vs%20breach%20at%202179)%20%E2%80%94%20fundamentalists%20inherit%20a%20collapsed%20world.%20Higher%20nadir%20(0.77B%20vs%200.16B%20in%20Messy%20Collapse)%20due%20to%20high-fertility%20population%20buffer.%20Defection%20dynamics%20reduce%20attrition%20from%2015%25%20to%202%25%20as%20fund%2Fsec%20ratio%20approaches%20parity.%20Valley%20of%20Death%3A%20138-year%20decline%20from%20peak%20to%20nadir%20with%2092%25%20population%20loss.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Scenario%204%3A%20Healthspan%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20Healthspan%20(Dynamic%20Threshold%2C%20Extended)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%209.49B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202053%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202036%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202066%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%202230%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Dynamic%20Threshold)%20%7C%202224%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200.10B%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%201200M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%200.03B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202262%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20Working%20age%20extension%2015-65%20%E2%86%92%2015-85%20via%20S-curve%20adoption%20starting%202070.%2048-year%20delay%20in%20complexity%20breach%20vs%20Messy%20Collapse%20(2224%20vs%202176).%20Deepest%20nadir%20(0.03B)%20due%20to%20extended%20pre-collapse%20geriatric%20phase.%20Cannot%20prevent%20collapse%20without%20fertility%20intervention.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Scenario%205%3A%20Ectogenesis%20%26%20Healthspan%20Synergy%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20Ectogenesis%20(Dynamic%20Threshold)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%209.49B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202053%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202036%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202066%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%20Never%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Dynamic%20Threshold)%20%7C%20N%2FA%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200.10B%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%201200M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%201.14B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202189%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20**Only%20scenario%20preventing%20collapse%20entirely**.%2010M%20annual%20ectogenesis%20births%20(starting%202120)%20stabilizes%20population%20above%20threshold.%20Nadir%20of%201.14B%20(vs%200.03-0.77B%20in%20collapse%20scenarios)%20maintains%20civilization.%20DR%20never%20reaches%200.8%20%E2%80%94%20innovation%20capacity%20preserved%20indefinitely.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Scenario%206%3A%20The%20AGI%20Rescue%0A%0A%20%20%20%20%7C%20Milestone%20%7C%20Value%20%7C%0A%20%20%20%20%7C-----------%7C-------%7C%0A%20%20%20%20%7C%20Scenario%20%7C%20AGI%20Rescue%20(Healthspan%20%2B%20AGI%2C%20Extended)%20%7C%0A%20%20%20%20%7C%20Pre-Collapse%20Peak%20Population%20%7C%209.49B%20%7C%0A%20%20%20%20%7C%20Peak%20Year%20%7C%202053%20%7C%0A%20%20%20%20%7C%20TFR%20Below%202.1%20%7C%202036%20%7C%0A%20%20%20%20%7C%20TFR%20Hits%200.72%20Floor%20%7C%202066%20%7C%0A%20%20%20%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%20Never%20%7C%0A%20%20%20%20%7C%20Complexity%20Breach%20(Dynamic%20Threshold)%20%7C%20N%2FA%20%7C%0A%20%20%20%20%7C%20Final%20Complexity%20Threshold%20%7C%200%20(AGI%20Eliminates%20Minimum)%20%7C%0A%20%20%20%20%7C%20Threshold%20Reduction%20%7C%201300M%20people%20%7C%0A%20%20%20%20%7C%20Population%20Nadir%20%7C%200.00B%20%7C%0A%20%20%20%20%7C%20Nadir%20Year%20%7C%202399%20%7C%0A%0A%20%20%20%20**Key%20Findings**%3A%20AGI%20eliminates%20minimum%20population%20floor%20%E2%80%94%20threshold%20can%20decline%20to%20zero.%20Infinite%20runway%3A%20Civilization%20sustainable%20indefinitely%20regardless%20of%20population%20level.%20Population%20continues%20declining%20to%20near-zero%20levels%20without%20fertility%20intervention.%20Structural%20solution%20vs%20Ectogenesis's%20demographic%20intervention.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Timeline%20of%20Critical%20Events%0A%0A%20%20%20%20%7C%20Year%20%7C%20Event%20%7C%20Scenarios%20Affected%20%7C%0A%20%20%20%20%7C------%7C-------%7C-------------------%7C%0A%20%20%20%20%7C%202036%20%7C%20TFR%20drops%20below%20replacement%20(2.1)%20%7C%20All%20scenarios%20%7C%0A%20%20%20%20%7C%202053%20%7C%20Global%20population%20peaks%20at%209.49B%20%7C%20Scenarios%202-6%20%7C%0A%20%20%20%20%7C%202066%20%7C%20TFR%20hits%20secular%20floor%20(0.72)%20%7C%20Scenarios%202-6%20%7C%0A%20%20%20%20%7C%202070%20%7C%20Healthspan%20breakthrough%20%7C%20Scenarios%204%2C%205%2C%206%20%7C%0A%20%20%20%20%7C%202084%20%7C%20Global%20Nursing%20Home%20peak%20(10.33B)%20%7C%20Scenario%201%20only%20%7C%0A%20%20%20%20%7C%202104%20%7C%20Innovation%20Death%20(DR%20%3E%200.8)%20%7C%20Scenarios%202%2C%203%20%7C%0A%20%20%20%20%7C%202120%20%7C%20Ectogenesis%20begins%20%7C%20Scenario%205%20only%20%7C%0A%20%20%20%20%7C%202177%20%7C%20Messy%20Collapse%20breach%20%7C%20Scenario%202%20%7C%0A%20%20%20%20%7C%202179%20%7C%20Amish%20Crossover%20breach%20%7C%20Scenario%203%20%7C%0A%20%20%20%20%7C%202187%20%7C%20Fundamentalist%20majority%20%7C%20Scenario%203%20%7C%0A%20%20%20%20%7C%202189%20%7C%20Ectogenesis%20nadir%20(1.14B)%20%7C%20Scenario%205%20%7C%0A%20%20%20%20%7C%202191%20%7C%20Amish%20Crossover%20nadir%20(0.77B)%20%7C%20Scenario%203%20%7C%0A%20%20%20%20%7C%202215%20%7C%20Messy%20Collapse%20nadir%20(0.16B)%20%7C%20Scenario%202%20%7C%0A%20%20%20%20%7C%202224%20%7C%20Healthspan%20breach%20%7C%20Scenario%204%20%7C%0A%20%20%20%20%7C%202226%20%7C%20Global%20Nursing%20Home%20innovation%20death%20%7C%20Scenario%201%20%7C%0A%20%20%20%20%7C%202230%20%7C%20Healthspan%20innovation%20death%20%7C%20Scenario%204%20only%20%7C%0A%20%20%20%20%7C%202262%20%7C%20Healthspan%20nadir%20(0.03B)%20%7C%20Scenario%204%20%7C%0A%20%20%20%20%7C%202286%20%7C%20TFR%20hits%20secular%20floor%20(0.72)%20%7C%20Scenario%201%20only%20%7C%0A%20%20%20%20%7C%202337%20%7C%20Global%20Nursing%20Home%20breach%20%7C%20Scenario%201%20%7C%0A%20%20%20%20%7C%202375%20%7C%20Global%20Nursing%20Home%20nadir%20(0.06B)%20%7C%20Scenario%201%20%7C%0A%20%20%20%20%7C%202399%20%7C%20AGI%20nadir%20(~0B)%20%7C%20Scenario%206%20%7C%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Key%20Insight%3A%20Innovation%20Death%20vs.%20Collapse%20Timing%0A%0A%20%20%20%20The%20critical%20question%20is%20not%20just%20*whether*%20innovation%20death%20occurs%2C%20but%20**how%20long%20civilization%20has**%20between%20when%20R%26D%20stalls%20(DR%20%3E%200.8)%20and%20when%20population%20falls%20below%20the%20complexity%20threshold.%0A%0A%20%20%20%20%7C%20Scenario%20%7C%20Innovation%20Death%20Year%20%7C%20Collapse%20Year%20%7C%20Lag%20(Years)%20%7C%20Outcome%20%7C%0A%20%20%20%20%7C----------%7C----------------------%7C---------------%7C-------------%7C---------%7C%0A%20%20%20%20%7C%20Global%20Nursing%20Home%20%7C%202226%20%7C%202337%20%7C%20**111**%20%7C%20Collapse%3B%20long%20delay%20from%20gradual%20TFR%20decline%20%7C%0A%20%20%20%20%7C%20Messy%20Collapse%20%7C%202104%20%7C%202177%20%7C%20**73**%20%7C%20Collapse%3B%20standard%20lag%20%7C%0A%20%20%20%20%7C%20Amish%20Crossover%20%7C%202104%20%7C%202179%20%7C%20**75**%20%7C%20Collapse%3B%20similar%20lag%20despite%20high-fertility%20buffer%20%7C%0A%20%20%20%20%7C%20Healthspan%20%7C%202230%20%7C%202224%20%7C%20**-6**%20%7C%20Collapse%3B%20breach%20precedes%20innovation%20death%20%7C%0A%20%20%20%20%7C%20Ectogenesis%20%7C%20Never%20%7C%20N%2FA%20%7C%20N%2FA%20%7C%20**Survives**%3B%20DR%20never%20reaches%200.8%20%7C%0A%20%20%20%20%7C%20AGI%20Rescue%20%7C%20Never%20%7C%20N%2FA%20%7C%20N%2FA%20%7C%20**Survives**%3B%20threshold%20can%20reach%20zero%20%7C%0A%0A%20%20%20%20**The%20Lag%20Effect**%3A%20In%20most%20scenarios%2C%20there's%20a%20**70-110%20year%20gap**%20between%20innovation%20death%20and%20collapse.%20This%20represents%20the%20period%20where%3A%0A%20%20%20%201.%20Dependency%20ratio%20exceeds%200.8%2C%20stalling%20new%20automation%20R%26D%0A%20%20%20%202.%20Existing%20automation%20keeps%20the%20complexity%20threshold%20at%20whatever%20it%20was%20before%20the%20DR%20exceeded%200.8%20*but*%20no%20new%20automation%20is%20invented%0A%20%20%20%203.%20Eventually%20population%20falls%20below%20the%20threshold%20%E2%86%92%20collapse%0A%0A%20%20%20%20**The%20Healthspan%20Anomaly**%3A%20In%20Scenario%204%2C%20collapse%20(2224)%20precedes%20innovation%20death%20(2230)%20by%206%20years.%20This%20occurs%20because%3A%0A%20%20%20%20-%20Working-age%20extension%20temporarily%20buffers%20DR%0A%20%20%20%20-%20But%20population%20decline%20continues%20unabated%20from%20low%20fertility%0A%20%20%20%20-%20The%20population%20threshold%20is%20breached%20*before*%20the%20geriatric%20population%20grows%20enough%20to%20push%20DR%20%3E%200.8%0A%20%20%20%20-%20Once%20DR%20does%20exceed%200.8%2C%20it's%20already%20too%20late%0A%0A%20%20%20%20**Survival%20Mechanisms**%3A%20Scenarios%205%20and%206%20never%20reach%20innovation%20death%3A%0A%20%20%20%20-%20**Ectogenesis**%3A%20Artificial%20births%20prevent%20population%20from%20declining%20fast%20enough%20to%20raise%20DR%0A%20%20%20%20-%20**AGI**%3A%20Eliminates%20the%20complexity%20floor%20entirely%2C%20making%20the%20threshold%20vs%20population%20relationship%20irrelevant%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
de5cf2167a9bdbf55966620840ff1b35