File size: 1,788 Bytes
8e9b78d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# src/lcca.py

import logging
from typing import Dict

from src.utils.logger import setup_logger

logger = setup_logger(__name__)


def calculate_LCCA(initial_cost: float, maintenance_costs: Dict[int, float], discount_rate: float, analysis_period: int) -> float:
    """
    Calculate the Life-Cycle Cost Analysis (LCCA) for the pavement.

    :param initial_cost: Initial construction cost.
    :param maintenance_costs: Maintenance costs with year as key.
    :param discount_rate: Annual discount rate (decimal, e.g., 0.03 for 3%).
    :param analysis_period: Number of years to analyze.
    :return: Present value of total lifecycle costs.
    """
    lcc = initial_cost
    logger.info(f"Initial Cost: ${initial_cost:,.2f}")
    for year in range(1, analysis_period + 1):
        maintenance_cost = maintenance_costs.get(year, 0)
        discounted_cost = maintenance_cost / ((1 + discount_rate) ** year)
        lcc += discounted_cost
        if maintenance_cost > 0:
            logger.debug(f"Year {year}: Maintenance Cost ${maintenance_cost:,.2f}, Discounted Cost ${discounted_cost:,.2f}")
    logger.info(f"Total Lifecycle Cost (LCCA): ${lcc:,.2f}")
    return lcc


def perform_LCCA(initial_cost: float, maintenance_costs: Dict[int, float], discount_rate: float, analysis_period: int) -> float:
    """
    Wrapper function to perform LCCA.

    :param initial_cost: Initial construction cost.
    :param maintenance_costs: Maintenance costs with year as key.
    :param discount_rate: Annual discount rate.
    :param analysis_period: Number of years to analyze.
    :return: Present value of total lifecycle costs.
    """
    logger.info("Starting Life-Cycle Cost Analysis (LCCA).")
    return calculate_LCCA(initial_cost, maintenance_costs, discount_rate, analysis_period)