[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FJPFM5HZTNH56DHATA6H4H":3,"skill-same:01M6FJPFM5HZTNH56DHATA6H4H":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":24,"linkOnly":25,"markdownContent":26,"markdownBody":27,"frontMatter":28,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M6FJPFM5HZTNH56DHATA6H4H","cwicr-escalation",null,"Apply price escalation to CWICR estimates over time. Calculate inflation adjustments, material price indices, and labor rate increases.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fcwicr-escalation\u002FSKILL.md",[],[18,19,20,21,22,23],"escalation","cwicr escalation","calculate","time","material","price","2026-11-10 10:12:30",false,"---\r\nslug: \"cwicr-escalation\"\r\ndisplay_name: \"CWICR Escalation\"\r\ndescription: \"Apply price escalation to CWICR estimates over time. Calculate inflation adjustments, material price indices, and labor rate increases.\"\r\n---\r\n\r\n# CWICR Escalation Calculator\r\n\r\n## Business Case\r\n\r\n### Problem Statement\r\nConstruction costs change over time:\r\n- Inflation affects all costs\r\n- Material prices fluctuate\r\n- Labor rates increase annually\r\n- Long projects need escalation\r\n\r\n### Solution\r\nTime-based cost escalation using historical indices, projected rates, and category-specific escalation factors.\r\n\r\n### Business Value\r\n- **Future pricing** - Estimate costs at construction time\r\n- **Budget planning** - Account for inflation\r\n- **Contract pricing** - Escalation clauses\r\n- **Historical analysis** - Adjust past costs to current\r\n\r\n## Technical Implementation\r\n\r\n```python\r\nimport pandas as pd\r\nimport numpy as np\r\nfrom typing import Dict, Any, List, Optional, Tuple\r\nfrom dataclasses import dataclass\r\nfrom datetime import datetime, date\r\nfrom dateutil.relativedelta import relativedelta\r\nfrom enum import Enum\r\n\r\n\r\nclass EscalationType(Enum):\r\n    \"\"\"Types of escalation.\"\"\"\r\n    LABOR = \"labor\"\r\n    MATERIAL = \"material\"\r\n    EQUIPMENT = \"equipment\"\r\n    GENERAL = \"general\"\r\n\r\n\r\n@dataclass\r\nclass EscalationIndex:\r\n    \"\"\"Escalation index for a period.\"\"\"\r\n    period: str  # YYYY-MM\r\n    labor_index: float\r\n    material_index: float\r\n    equipment_index: float\r\n    general_index: float\r\n\r\n\r\n@dataclass\r\nclass EscalationResult:\r\n    \"\"\"Result of escalation calculation.\"\"\"\r\n    base_cost: float\r\n    base_date: date\r\n    target_date: date\r\n    months: int\r\n    escalation_rate: float\r\n    escalation_amount: float\r\n    escalated_cost: float\r\n    by_category: Dict[str, Dict[str, float]]\r\n\r\n\r\n# Historical escalation rates (annual %)\r\nHISTORICAL_RATES = {\r\n    2020: {'labor': 2.5, 'material': 1.8, 'equipment': 1.5, 'general': 2.0},\r\n    2021: {'labor': 3.2, 'material': 8.5, 'equipment': 2.0, 'general': 4.5},\r\n    2022: {'labor': 4.5, 'material': 12.0, 'equipment': 3.5, 'general': 7.0},\r\n    2023: {'labor': 4.0, 'material': 5.0, 'equipment': 3.0, 'general': 4.0},\r\n    2024: {'labor': 3.5, 'material': 3.0, 'equipment': 2.5, 'general': 3.0},\r\n    2025: {'labor': 3.0, 'material': 2.5, 'equipment': 2.0, 'general': 2.5},\r\n}\r\n\r\n# Material-specific escalation factors\r\nMATERIAL_ESCALATION = {\r\n    'steel': 1.20,      # Higher volatility\r\n    'lumber': 1.30,     # High volatility\r\n    'concrete': 0.90,   # Lower volatility\r\n    'copper': 1.25,     # Commodity driven\r\n    'aluminum': 1.15,\r\n    'plastic': 1.10,\r\n    'glass': 0.95,\r\n    'default': 1.00\r\n}\r\n\r\n\r\nclass CWICREscalation:\r\n    \"\"\"Calculate cost escalation over time.\"\"\"\r\n\r\n    def __init__(self,\r\n                 cwicr_data: pd.DataFrame = None,\r\n                 custom_rates: Dict[int, Dict[str, float]] = None):\r\n        self.cost_data = cwicr_data\r\n        self.rates = custom_rates or HISTORICAL_RATES\r\n        if cwicr_data is not None:\r\n            self._index_data()\r\n\r\n    def _index_data(self):\r\n        \"\"\"Index cost data.\"\"\"\r\n        if 'work_item_code' in self.cost_data.columns:\r\n            self._code_index = self.cost_data.set_index('work_item_code')\r\n        else:\r\n            self._code_index = None\r\n\r\n    def get_rate(self,\r\n                  year: int,\r\n                  category: EscalationType = EscalationType.GENERAL) -> float:\r\n        \"\"\"Get escalation rate for year and category.\"\"\"\r\n        year_rates = self.rates.get(year, self.rates.get(max(self.rates.keys())))\r\n        return year_rates.get(category.value, year_rates.get('general', 3.0))\r\n\r\n    def calculate_compound_factor(self,\r\n                                   base_date: date,\r\n                                   target_date: date,\r\n                                   category: EscalationType = EscalationType.GENERAL) -> float:\r\n        \"\"\"Calculate compound escalation factor between dates.\"\"\"\r\n\r\n        if target_date \u003C= base_date:\r\n            return 1.0\r\n\r\n        factor = 1.0\r\n        current = base_date\r\n\r\n        while current \u003C target_date:\r\n            year = current.year\r\n            annual_rate = self.get_rate(year, category) \u002F 100\r\n\r\n            # Calculate months in this year\r\n            year_end = date(year + 1, 1, 1)\r\n            if target_date \u003C year_end:\r\n                months = (target_date.year - current.year) * 12 + target_date.month - current.month\r\n            else:\r\n                months = (year_end.year - current.year) * 12 + year_end.month - current.month\r\n\r\n            # Apply monthly compound rate\r\n            monthly_rate = (1 + annual_rate) ** (1\u002F12) - 1\r\n            factor *= (1 + monthly_rate) ** months\r\n\r\n            current = year_end\r\n\r\n        return factor\r\n\r\n    def escalate_cost(self,\r\n                       base_cost: float,\r\n                       base_date: date,\r\n                       target_date: date,\r\n                       cost_breakdown: Dict[str, float] = None) -> EscalationResult:\r\n        \"\"\"Escalate cost from base date to target date.\"\"\"\r\n\r\n        if cost_breakdown is None:\r\n            cost_breakdown = {\r\n                'labor': base_cost * 0.40,\r\n                'material': base_cost * 0.45,\r\n                'equipment': base_cost * 0.15\r\n            }\r\n\r\n        months = (target_date.year - base_date.year) * 12 + target_date.month - base_date.month\r\n\r\n        # Escalate each category\r\n        by_category = {}\r\n        total_escalated = 0\r\n\r\n        for category, amount in cost_breakdown.items():\r\n            esc_type = EscalationType.LABOR if category == 'labor' else \\\r\n                       EscalationType.MATERIAL if category == 'material' else \\\r\n                       EscalationType.EQUIPMENT if category == 'equipment' else \\\r\n                       EscalationType.GENERAL\r\n\r\n            factor = self.calculate_compound_factor(base_date, target_date, esc_type)\r\n            escalated = amount * factor\r\n            escalation = escalated - amount\r\n\r\n            by_category[category] = {\r\n                'base': round(amount, 2),\r\n                'factor': round(factor, 4),\r\n                'escalated': round(escalated, 2),\r\n                'escalation': round(escalation, 2)\r\n            }\r\n\r\n            total_escalated += escalated\r\n\r\n        total_escalation = total_escalated - base_cost\r\n        esc_rate = (total_escalation \u002F base_cost * 100) if base_cost > 0 else 0\r\n\r\n        return EscalationResult(\r\n            base_cost=round(base_cost, 2),\r\n            base_date=base_date,\r\n            target_date=target_date,\r\n            months=months,\r\n            escalation_rate=round(esc_rate, 2),\r\n            escalation_amount=round(total_escalation, 2),\r\n            escalated_cost=round(total_escalated, 2),\r\n            by_category=by_category\r\n        )\r\n\r\n    def escalate_estimate(self,\r\n                           items: List[Dict[str, Any]],\r\n                           base_date: date,\r\n                           target_date: date) -> Dict[str, Any]:\r\n        \"\"\"Escalate entire estimate.\"\"\"\r\n\r\n        escalated_items = []\r\n        total_base = 0\r\n        total_escalated = 0\r\n\r\n        for item in items:\r\n            code = item.get('work_item_code', item.get('code'))\r\n            qty = item.get('quantity', 0)\r\n\r\n            # Get costs from CWICR\r\n            labor = 0\r\n            material = 0\r\n            equipment = 0\r\n\r\n            if self._code_index is not None and code in self._code_index.index:\r\n                wi = self._code_index.loc[code]\r\n                labor = float(wi.get('labor_cost', 0) or 0) * qty\r\n                material = float(wi.get('material_cost', 0) or 0) * qty\r\n                equipment = float(wi.get('equipment_cost', 0) or 0) * qty\r\n\r\n            base = labor + material + equipment\r\n            breakdown = {'labor': labor, 'material': material, 'equipment': equipment}\r\n\r\n            result = self.escalate_cost(base, base_date, target_date, breakdown)\r\n\r\n            escalated_items.append({\r\n                'code': code,\r\n                'base_cost': result.base_cost,\r\n                'escalated_cost': result.escalated_cost,\r\n                'escalation': result.escalation_amount\r\n            })\r\n\r\n            total_base += base\r\n            total_escalated += result.escalated_cost\r\n\r\n        return {\r\n            'items': escalated_items,\r\n            'total_base': round(total_base, 2),\r\n            'total_escalated': round(total_escalated, 2),\r\n            'total_escalation': round(total_escalated - total_base, 2),\r\n            'escalation_rate': round((total_escalated - total_base) \u002F total_base * 100, 2) if total_base > 0 else 0,\r\n            'base_date': base_date,\r\n            'target_date': target_date\r\n        }\r\n\r\n    def project_future_costs(self,\r\n                              base_cost: float,\r\n                              base_date: date,\r\n                              years_forward: int = 5,\r\n                              annual_rate: float = None) -> pd.DataFrame:\r\n        \"\"\"Project costs for multiple future years.\"\"\"\r\n\r\n        projections = []\r\n        current = base_cost\r\n\r\n        for i in range(years_forward + 1):\r\n            target = base_date + relativedelta(years=i)\r\n            year = target.year\r\n\r\n            if annual_rate is None:\r\n                rate = self.get_rate(year)\r\n            else:\r\n                rate = annual_rate\r\n\r\n            if i > 0:\r\n                current = current * (1 + rate \u002F 100)\r\n\r\n            projections.append({\r\n                'Year': year,\r\n                'Date': target,\r\n                'Annual Rate': f\"{rate}%\",\r\n                'Projected Cost': round(current, 2),\r\n                'Cumulative Escalation': round(current - base_cost, 2),\r\n                'Cumulative %': round((current - base_cost) \u002F base_cost * 100, 1)\r\n            })\r\n\r\n        return pd.DataFrame(projections)\r\n\r\n    def de_escalate_cost(self,\r\n                          current_cost: float,\r\n                          current_date: date,\r\n                          base_date: date,\r\n                          category: EscalationType = EscalationType.GENERAL) -> Dict[str, Any]:\r\n        \"\"\"De-escalate current cost back to base date.\"\"\"\r\n\r\n        factor = self.calculate_compound_factor(base_date, current_date, category)\r\n        base_cost = current_cost \u002F factor\r\n\r\n        return {\r\n            'current_cost': round(current_cost, 2),\r\n            'current_date': current_date,\r\n            'base_date': base_date,\r\n            'de_escalation_factor': round(1 \u002F factor, 4),\r\n            'base_cost': round(base_cost, 2),\r\n            'category': category.value\r\n        }\r\n\r\n    def export_escalation(self,\r\n                          result: EscalationResult,\r\n                          output_path: str) -> str:\r\n        \"\"\"Export escalation to Excel.\"\"\"\r\n\r\n        with pd.ExcelWriter(output_path, engine='openpyxl') as writer:\r\n            # Summary\r\n            summary_df = pd.DataFrame([{\r\n                'Base Cost': result.base_cost,\r\n                'Base Date': result.base_date,\r\n                'Target Date': result.target_date,\r\n                'Months': result.months,\r\n                'Escalation Rate': f\"{result.escalation_rate}%\",\r\n                'Escalation Amount': result.escalation_amount,\r\n                'Escalated Cost': result.escalated_cost\r\n            }])\r\n            summary_df.to_excel(writer, sheet_name='Summary', index=False)\r\n\r\n            # By Category\r\n            cat_df = pd.DataFrame([\r\n                {\r\n                    'Category': cat,\r\n                    'Base': data['base'],\r\n                    'Factor': data['factor'],\r\n                    'Escalated': data['escalated'],\r\n                    'Escalation': data['escalation']\r\n                }\r\n                for cat, data in result.by_category.items()\r\n            ])\r\n            cat_df.to_excel(writer, sheet_name='By Category', index=False)\r\n\r\n        return output_path\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom datetime import date\r\n\r\n# Initialize escalation calculator\r\nesc = CWICREscalation()\r\n\r\n# Escalate single cost\r\nresult = esc.escalate_cost(\r\n    base_cost=1000000,\r\n    base_date=date(2024, 1, 1),\r\n    target_date=date(2026, 6, 1)\r\n)\r\n\r\nprint(f\"Base Cost: ${result.base_cost:,.2f}\")\r\nprint(f\"Escalated: ${result.escalated_cost:,.2f}\")\r\nprint(f\"Escalation: {result.escalation_rate}%\")\r\n```\r\n\r\n## Common Use Cases\r\n\r\n### 1. Project Future Costs\r\n```python\r\nprojections = esc.project_future_costs(\r\n    base_cost=5000000,\r\n    base_date=date.today(),\r\n    years_forward=5\r\n)\r\nprint(projections)\r\n```\r\n\r\n### 2. Escalate Estimate\r\n```python\r\ncwicr = pd.read_parquet(\"ddc_cwicr_en.parquet\")\r\nesc = CWICREscalation(cwicr)\r\n\r\nitems = [\r\n    {'work_item_code': 'CONC-001', 'quantity': 150},\r\n    {'work_item_code': 'STRL-002', 'quantity': 25}\r\n]\r\n\r\nescalated = esc.escalate_estimate(\r\n    items,\r\n    base_date=date(2024, 1, 1),\r\n    target_date=date(2025, 12, 1)\r\n)\r\n```\r\n\r\n### 3. De-escalate Historical Cost\r\n```python\r\nbase_cost = esc.de_escalate_cost(\r\n    current_cost=1200000,\r\n    current_date=date(2024, 6, 1),\r\n    base_date=date(2020, 1, 1)\r\n)\r\nprint(f\"2020 equivalent: ${base_cost['base_cost']:,.2f}\")\r\n```\r\n\r\n## Resources\r\n- **GitHub**: [OpenConstructionEstimate-DDC-CWICR](https:\u002F\u002Fgithub.com\u002Fdatadrivenconstruction\u002FOpenConstructionEstimate-DDC-CWICR)\r\n- **DDC Book**: Chapter 3.1 - Cost Escalation Methods\r\n","# CWICR Escalation Calculator\r\n\r\n## Business Case\r\n\r\n### Problem Statement\r\nConstruction costs change over time:\r\n- Inflation affects all costs\r\n- Material prices fluctuate\r\n- Labor rates increase annually\r\n- Long projects need escalation\r\n\r\n### Solution\r\nTime-based cost escalation using historical indices, projected rates, and category-specific escalation factors.\r\n\r\n### Business Value\r\n- **Future pricing** - Estimate costs at construction time\r\n- **Budget planning** - Account for inflation\r\n- **Contract pricing** - Escalation clauses\r\n- **Historical analysis** - Adjust past costs to current\r\n\r\n## Technical Implementation\r\n\r\n```python\r\nimport pandas as pd\r\nimport numpy as np\r\nfrom typing import Dict, Any, List, Optional, Tuple\r\nfrom dataclasses import dataclass\r\nfrom datetime import datetime, date\r\nfrom dateutil.relativedelta import relativedelta\r\nfrom enum import Enum\r\n\r\n\r\nclass EscalationType(Enum):\r\n    \"\"\"Types of escalation.\"\"\"\r\n    LABOR = \"labor\"\r\n    MATERIAL = \"material\"\r\n    EQUIPMENT = \"equipment\"\r\n    GENERAL = \"general\"\r\n\r\n\r\n@dataclass\r\nclass EscalationIndex:\r\n    \"\"\"Escalation index for a period.\"\"\"\r\n    period: str  # YYYY-MM\r\n    labor_index: float\r\n    material_index: float\r\n    equipment_index: float\r\n    general_index: float\r\n\r\n\r\n@dataclass\r\nclass EscalationResult:\r\n    \"\"\"Result of escalation calculation.\"\"\"\r\n    base_cost: float\r\n    base_date: date\r\n    target_date: date\r\n    months: int\r\n    escalation_rate: float\r\n    escalation_amount: float\r\n    escalated_cost: float\r\n    by_category: Dict[str, Dict[str, float]]\r\n\r\n\r\n# Historical escalation rates (annual %)\r\nHISTORICAL_RATES = {\r\n    2020: {'labor': 2.5, 'material': 1.8, 'equipment': 1.5, 'general': 2.0},\r\n    2021: {'labor': 3.2, 'material': 8.5, 'equipment': 2.0, 'general': 4.5},\r\n    2022: {'labor': 4.5, 'material': 12.0, 'equipment': 3.5, 'general': 7.0},\r\n    2023: {'labor': 4.0, 'material': 5.0, 'equipment': 3.0, 'general': 4.0},\r\n    2024: {'labor': 3.5, 'material': 3.0, 'equipment': 2.5, 'general': 3.0},\r\n    2025: {'labor': 3.0, 'material': 2.5, 'equipment': 2.0, 'general': 2.5},\r\n}\r\n\r\n# Material-specific escalation factors\r\nMATERIAL_ESCALATION = {\r\n    'steel': 1.20,      # Higher volatility\r\n    'lumber': 1.30,     # High volatility\r\n    'concrete': 0.90,   # Lower volatility\r\n    'copper': 1.25,     # Commodity driven\r\n    'aluminum': 1.15,\r\n    'plastic': 1.10,\r\n    'glass': 0.95,\r\n    'default': 1.00\r\n}\r\n\r\n\r\nclass CWICREscalation:\r\n    \"\"\"Calculate cost escalation over time.\"\"\"\r\n\r\n    def __init__(self,\r\n                 cwicr_data: pd.DataFrame = None,\r\n                 custom_rates: Dict[int, Dict[str, float]] = None):\r\n        self.cost_data = cwicr_data\r\n        self.rates = custom_rates or HISTORICAL_RATES\r\n        if cwicr_data is not None:\r\n            self._index_data()\r\n\r\n    def _index_data(self):\r\n        \"\"\"Index cost data.\"\"\"\r\n        if 'work_item_code' in self.cost_data.columns:\r\n            self._code_index = self.cost_data.set_index('work_item_code')\r\n        else:\r\n            self._code_index = None\r\n\r\n    def get_rate(self,\r\n                  year: int,\r\n                  category: EscalationType = EscalationType.GENERAL) -> float:\r\n        \"\"\"Get escalation rate for year and category.\"\"\"\r\n        year_rates = self.rates.get(year, self.rates.get(max(self.rates.keys())))\r\n        return year_rates.get(category.value, year_rates.get('general', 3.0))\r\n\r\n    def calculate_compound_factor(self,\r\n                                   base_date: date,\r\n                                   target_date: date,\r\n                                   category: EscalationType = EscalationType.GENERAL) -> float:\r\n        \"\"\"Calculate compound escalation factor between dates.\"\"\"\r\n\r\n        if target_date \u003C= base_date:\r\n            return 1.0\r\n\r\n        factor = 1.0\r\n        current = base_date\r\n\r\n        while current \u003C target_date:\r\n            year = current.year\r\n            annual_rate = self.get_rate(year, category) \u002F 100\r\n\r\n            # Calculate months in this year\r\n            year_end = date(year + 1, 1, 1)\r\n            if target_date \u003C year_end:\r\n                months = (target_date.year - current.year) * 12 + target_date.month - current.month\r\n            else:\r\n                months = (year_end.year - current.year) * 12 + year_end.month - current.month\r\n\r\n            # Apply monthly compound rate\r\n            monthly_rate = (1 + annual_rate) ** (1\u002F12) - 1\r\n            factor *= (1 + monthly_rate) ** months\r\n\r\n            current = year_end\r\n\r\n        return factor\r\n\r\n    def escalate_cost(self,\r\n                       base_cost: float,\r\n                       base_date: date,\r\n                       target_date: date,\r\n                       cost_breakdown: Dict[str, float] = None) -> EscalationResult:\r\n        \"\"\"Escalate cost from base date to target date.\"\"\"\r\n\r\n        if cost_breakdown is None:\r\n            cost_breakdown = {\r\n                'labor': base_cost * 0.40,\r\n                'material': base_cost * 0.45,\r\n                'equipment': base_cost * 0.15\r\n            }\r\n\r\n        months = (target_date.year - base_date.year) * 12 + target_date.month - base_date.month\r\n\r\n        # Escalate each category\r\n        by_category = {}\r\n        total_escalated = 0\r\n\r\n        for category, amount in cost_breakdown.items():\r\n            esc_type = EscalationType.LABOR if category == 'labor' else \\\r\n                       EscalationType.MATERIAL if category == 'material' else \\\r\n                       EscalationType.EQUIPMENT if category == 'equipment' else \\\r\n                       EscalationType.GENERAL\r\n\r\n            factor = self.calculate_compound_factor(base_date, target_date, esc_type)\r\n            escalated = amount * factor\r\n            escalation = escalated - amount\r\n\r\n            by_category[category] = {\r\n                'base': round(amount, 2),\r\n                'factor': round(factor, 4),\r\n                'escalated': round(escalated, 2),\r\n                'escalation': round(escalation, 2)\r\n            }\r\n\r\n            total_escalated += escalated\r\n\r\n        total_escalation = total_escalated - base_cost\r\n        esc_rate = (total_escalation \u002F base_cost * 100) if base_cost > 0 else 0\r\n\r\n        return EscalationResult(\r\n            base_cost=round(base_cost, 2),\r\n            base_date=base_date,\r\n            target_date=target_date,\r\n            months=months,\r\n            escalation_rate=round(esc_rate, 2),\r\n            escalation_amount=round(total_escalation, 2),\r\n            escalated_cost=round(total_escalated, 2),\r\n            by_category=by_category\r\n        )\r\n\r\n    def escalate_estimate(self,\r\n                           items: List[Dict[str, Any]],\r\n                           base_date: date,\r\n                           target_date: date) -> Dict[str, Any]:\r\n        \"\"\"Escalate entire estimate.\"\"\"\r\n\r\n        escalated_items = []\r\n        total_base = 0\r\n        total_escalated = 0\r\n\r\n        for item in items:\r\n            code = item.get('work_item_code', item.get('code'))\r\n            qty = item.get('quantity', 0)\r\n\r\n            # Get costs from CWICR\r\n            labor = 0\r\n            material = 0\r\n            equipment = 0\r\n\r\n            if self._code_index is not None and code in self._code_index.index:\r\n                wi = self._code_index.loc[code]\r\n                labor = float(wi.get('labor_cost', 0) or 0) * qty\r\n                material = float(wi.get('material_cost', 0) or 0) * qty\r\n                equipment = float(wi.get('equipment_cost', 0) or 0) * qty\r\n\r\n            base = labor + material + equipment\r\n            breakdown = {'labor': labor, 'material': material, 'equipment': equipment}\r\n\r\n            result = self.escalate_cost(base, base_date, target_date, breakdown)\r\n\r\n            escalated_items.append({\r\n                'code': code,\r\n                'base_cost': result.base_cost,\r\n                'escalated_cost': result.escalated_cost,\r\n                'escalation': result.escalation_amount\r\n            })\r\n\r\n            total_base += base\r\n            total_escalated += result.escalated_cost\r\n\r\n        return {\r\n            'items': escalated_items,\r\n            'total_base': round(total_base, 2),\r\n            'total_escalated': round(total_escalated, 2),\r\n            'total_escalation': round(total_escalated - total_base, 2),\r\n            'escalation_rate': round((total_escalated - total_base) \u002F total_base * 100, 2) if total_base > 0 else 0,\r\n            'base_date': base_date,\r\n            'target_date': target_date\r\n        }\r\n\r\n    def project_future_costs(self,\r\n                              base_cost: float,\r\n                              base_date: date,\r\n                              years_forward: int = 5,\r\n                              annual_rate: float = None) -> pd.DataFrame:\r\n        \"\"\"Project costs for multiple future years.\"\"\"\r\n\r\n        projections = []\r\n        current = base_cost\r\n\r\n        for i in range(years_forward + 1):\r\n            target = base_date + relativedelta(years=i)\r\n            year = target.year\r\n\r\n            if annual_rate is None:\r\n                rate = self.get_rate(year)\r\n            else:\r\n                rate = annual_rate\r\n\r\n            if i > 0:\r\n                current = current * (1 + rate \u002F 100)\r\n\r\n            projections.append({\r\n                'Year': year,\r\n                'Date': target,\r\n                'Annual Rate': f\"{rate}%\",\r\n                'Projected Cost': round(current, 2),\r\n                'Cumulative Escalation': round(current - base_cost, 2),\r\n                'Cumulative %': round((current - base_cost) \u002F base_cost * 100, 1)\r\n            })\r\n\r\n        return pd.DataFrame(projections)\r\n\r\n    def de_escalate_cost(self,\r\n                          current_cost: float,\r\n                          current_date: date,\r\n                          base_date: date,\r\n                          category: EscalationType = EscalationType.GENERAL) -> Dict[str, Any]:\r\n        \"\"\"De-escalate current cost back to base date.\"\"\"\r\n\r\n        factor = self.calculate_compound_factor(base_date, current_date, category)\r\n        base_cost = current_cost \u002F factor\r\n\r\n        return {\r\n            'current_cost': round(current_cost, 2),\r\n            'current_date': current_date,\r\n            'base_date': base_date,\r\n            'de_escalation_factor': round(1 \u002F factor, 4),\r\n            'base_cost': round(base_cost, 2),\r\n            'category': category.value\r\n        }\r\n\r\n    def export_escalation(self,\r\n                          result: EscalationResult,\r\n                          output_path: str) -> str:\r\n        \"\"\"Export escalation to Excel.\"\"\"\r\n\r\n        with pd.ExcelWriter(output_path, engine='openpyxl') as writer:\r\n            # Summary\r\n            summary_df = pd.DataFrame([{\r\n                'Base Cost': result.base_cost,\r\n                'Base Date': result.base_date,\r\n                'Target Date': result.target_date,\r\n                'Months': result.months,\r\n                'Escalation Rate': f\"{result.escalation_rate}%\",\r\n                'Escalation Amount': result.escalation_amount,\r\n                'Escalated Cost': result.escalated_cost\r\n            }])\r\n            summary_df.to_excel(writer, sheet_name='Summary', index=False)\r\n\r\n            # By Category\r\n            cat_df = pd.DataFrame([\r\n                {\r\n                    'Category': cat,\r\n                    'Base': data['base'],\r\n                    'Factor': data['factor'],\r\n                    'Escalated': data['escalated'],\r\n                    'Escalation': data['escalation']\r\n                }\r\n                for cat, data in result.by_category.items()\r\n            ])\r\n            cat_df.to_excel(writer, sheet_name='By Category', index=False)\r\n\r\n        return output_path\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom datetime import date\r\n\r\n# Initialize escalation calculator\r\nesc = CWICREscalation()\r\n\r\n# Escalate single cost\r\nresult = esc.escalate_cost(\r\n    base_cost=1000000,\r\n    base_date=date(2024, 1, 1),\r\n    target_date=date(2026, 6, 1)\r\n)\r\n\r\nprint(f\"Base Cost: ${result.base_cost:,.2f}\")\r\nprint(f\"Escalated: ${result.escalated_cost:,.2f}\")\r\nprint(f\"Escalation: {result.escalation_rate}%\")\r\n```\r\n\r\n## Common Use Cases\r\n\r\n### 1. Project Future Costs\r\n```python\r\nprojections = esc.project_future_costs(\r\n    base_cost=5000000,\r\n    base_date=date.today(),\r\n    years_forward=5\r\n)\r\nprint(projections)\r\n```\r\n\r\n### 2. Escalate Estimate\r\n```python\r\ncwicr = pd.read_parquet(\"ddc_cwicr_en.parquet\")\r\nesc = CWICREscalation(cwicr)\r\n\r\nitems = [\r\n    {'work_item_code': 'CONC-001', 'quantity': 150},\r\n    {'work_item_code': 'STRL-002', 'quantity': 25}\r\n]\r\n\r\nescalated = esc.escalate_estimate(\r\n    items,\r\n    base_date=date(2024, 1, 1),\r\n    target_date=date(2025, 12, 1)\r\n)\r\n```\r\n\r\n### 3. De-escalate Historical Cost\r\n```python\r\nbase_cost = esc.de_escalate_cost(\r\n    current_cost=1200000,\r\n    current_date=date(2024, 6, 1),\r\n    base_date=date(2020, 1, 1)\r\n)\r\nprint(f\"2020 equivalent: ${base_cost['base_cost']:,.2f}\")\r\n```\r\n\r\n## Resources\r\n- **GitHub**: [OpenConstructionEstimate-DDC-CWICR](https:\u002F\u002Fgithub.com\u002Fdatadrivenconstruction\u002FOpenConstructionEstimate-DDC-CWICR)\r\n- **DDC Book**: Chapter 3.1 - Cost Escalation Methods\r\n",{"slug":5,"description":7,"display_name":29},"CWICR Escalation","main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Fdatadrivenconstruction\u002Fcwicr-escalation",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add kbarbel640-del\u002Fskills --skill cwicr-escalation",{"tool":43,"command":44},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill cwicr-escalation",{"tool":46,"command":47},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill cwicr-escalation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fcwicr-escalation\u002FSKILL.md",true,[51],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"_meta.json","REFERENCE","参考文档",300,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fcwicr-escalation\u002F_meta.json",[58,84,108,126,131,151],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":24},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83],"crowd prompting","prompting","api","with","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":24},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[91,67,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,72,107],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":24},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[],[115,116,117,118,119,120,121,68,122,105,107,123,67,124,125],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":127,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":24},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[118,117,116,115,125,120,121,68,119,105,107,122,123,67,124],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":24},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[138,139,140,141,142,143,144,145,146,147,148,149,150],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":24},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[],[158,159,160,161,68,162,163,30,164,123,165,166,167,168,169,81,170,171,172],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]