2025年4月6日 星期日

加入影響力因子重新計算水井USR的SROI

1.加入無謂因子(Deadweight) 的程式:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class SROICalculator:
    def __init__(self):
        self.inputs = {}
        self.outcomes = {}

    def add_input(self, item, amount):
        self.inputs[item] = self.inputs.get(item, 0) + amount

    def add_outcome(self, item, amount, deadweight=0):
        adjusted_amount = amount * (1 - deadweight)
        self.outcomes[item] = self.outcomes.get(item, 0) + adjusted_amount

    def calculate_sroi(self):
        total_input = sum(self.inputs.values())
        total_outcome = sum(self.outcomes.values())
        if total_input == 0:
            return float('inf')
        return round((total_outcome - total_input) / total_input, 2)

    def summary(self):
        print("📦 成本投入:")
        for k, v in self.inputs.items():
            print(f"  - {k}: NT${v}")
        print("\n🎯 調整後效益(扣除 Deadweight):")
        for k, v in self.outcomes.items():
            print(f"  - {k}: NT${v}")
        print(f"\n💡 SROI = {self.calculate_sroi()}")

# ✅ 實例:水井村案例模擬
sroi_calc = SROICalculator()

# 📦 成本投入
sroi_calc.add_input("IoT設備與感測器", 120000)
sroi_calc.add_input("水質淨化系統", 80000)
sroi_calc.add_input("教學與培訓費用", 100000)
sroi_calc.add_input("工藝材料與推廣", 50000)

# 🎯 效益(已考量 Deadweight)
sroi_calc.add_outcome("節省水資源成本", 50000, deadweight=0.15)  # 15%
sroi_calc.add_outcome("減碳社會效益(估算)", 70000, deadweight=0.10)  # 10%
sroi_calc.add_outcome("智慧養殖提升產值", 150000, deadweight=0.25)  # 25%
sroi_calc.add_outcome("地方品牌提升與觀光收益", 60000, deadweight=0.40)  # 40%
sroi_calc.add_outcome("居民生活與文化參與提升(估算)", 30000, deadweight=0.35)  # 35%

# ⏱️ 輸出結果
sroi_calc.summary()

執行結果:
📦 成本投入:
  - IoT設備與感測器: NT$120000
  - 水質淨化系統: NT$80000
  - 教學與培訓費用: NT$100000
  - 工藝材料與推廣: NT$50000

🎯 調整後效益(扣除 Deadweight):
  - 節省水資源成本: NT$42500.0
  - 減碳社會效益(估算): NT$63000.0
  - 智慧養殖提升產值: NT$112500.0
  - 地方品牌提升與觀光收益: NT$36000.0
  - 居民生活與文化參與提升(估算): NT$19500.0

💡 SROI = -0.22

2.再加入歸因因子(Attribution)和衰減因子(Drop-off)的程式(以3年為期):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class SROICalculator:
    def __init__(self):
        self.inputs = {}
        self.outcomes = {}

    def add_input(self, item, amount):
        self.inputs[item] = self.inputs.get(item, 0) + amount

    def add_outcome(self, item, amount, deadweight=0, attribution=0, dropoff=0, years=1):
        adjusted_total = 0
        for year in range(years):
            year_factor = (1 - dropoff) ** year
            adjusted = amount * (1 - deadweight) * (1 - attribution) * year_factor
            adjusted_total += adjusted
        self.outcomes[item] = self.outcomes.get(item, 0) + adjusted_total

    def calculate_sroi(self):
        total_input = sum(self.inputs.values())
        total_outcome = sum(self.outcomes.values())
        if total_input == 0:
            return float('inf')
        return round((total_outcome - total_input) / total_input, 2)

    def summary(self):
        print("📦 成本投入:")
        for k, v in self.inputs.items():
            print(f"  - {k}: NT${v}")
        print("\n🎯 調整後效益(扣除 Deadweight、歸因、遞減):")
        for k, v in self.outcomes.items():
            print(f"  - {k}: NT${round(v, 2)}")
        print(f"\n💡 SROI = {self.calculate_sroi()}")


sroi_calc = SROICalculator()

# 📦 成本投入
sroi_calc.add_input("IoT設備與感測器", 120000)
sroi_calc.add_input("水質淨化系統", 80000)
sroi_calc.add_input("教學與培訓費用", 100000)
sroi_calc.add_input("工藝材料與推廣", 50000)

# 🎯 效益:含 Deadweight、Attribution、Drop-off、years
sroi_calc.add_outcome("節省水資源成本", 50000, deadweight=0.15, attribution=0.1, dropoff=0.05, years=3)
sroi_calc.add_outcome("減碳社會效益(估算)", 70000, deadweight=0.10, attribution=0.1, dropoff=0.05, years=3)
sroi_calc.add_outcome("智慧養殖提升產值", 150000, deadweight=0.25, attribution=0.15, dropoff=0.1, years=3)
sroi_calc.add_outcome("地方品牌提升與觀光收益", 60000, deadweight=0.4, attribution=0.2, dropoff=0.1, years=3)
sroi_calc.add_outcome("居民生活與文化參與提升(估算)", 30000, deadweight=0.35, attribution=0.15, dropoff=0.05, years=3)

# ⏱️ 輸出結果
sroi_calc.summary()

執行結果:
📦 成本投入:
  - IoT設備與感測器: NT$120000
  - 水質淨化系統: NT$80000
  - 教學與培訓費用: NT$100000
  - 工藝材料與推廣: NT$50000

🎯 調整後效益(扣除 Deadweight、歸因、遞減):
  - 節省水資源成本: NT$109108.12
  - 減碳社會效益(估算): NT$161736.75
  - 智慧養殖提升產值: NT$259143.75
  - 地方品牌提升與觀光收益: NT$78048.0
  - 居民生活與文化參與提升(估算): NT$47280.19

💡 SROI = 0.87

3.再加入移轉因子(Displacement),其程式如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class SROICalculator:
    def __init__(self):
        self.inputs = {}
        self.outcomes = {}

    def add_input(self, item, amount):
        self.inputs[item] = self.inputs.get(item, 0) + amount

    def add_outcome(self, item, amount, deadweight=0, attribution=0, displacement=0, dropoff=0, years=1):
        adjusted_total = 0
        for year in range(years):
            year_factor = (1 - dropoff) ** year
            adjusted = amount * (1 - deadweight) * (1 - attribution) * (1 - displacement) * year_factor
            adjusted_total += adjusted
        self.outcomes[item] = self.outcomes.get(item, 0) + adjusted_total

    def calculate_sroi(self):
        total_input = sum(self.inputs.values())
        total_outcome = sum(self.outcomes.values())
        if total_input == 0:
            return float('inf')
        return round((total_outcome - total_input) / total_input, 2)

    def summary(self):
        print("📦 成本投入:")
        for k, v in self.inputs.items():
            print(f"  - {k}: NT${v}")
        print("\n🎯 調整後效益(扣除 Deadweight、歸因、移轉、遞減):")
        for k, v in self.outcomes.items():
            print(f"  - {k}: NT${round(v, 2)}")
        print(f"\n💡 SROI = {self.calculate_sroi()}")

sroi_calc = SROICalculator()

# 📦 成本投入
sroi_calc.add_input("IoT設備與感測器", 120000)
sroi_calc.add_input("水質淨化系統", 80000)
sroi_calc.add_input("教學與培訓費用", 100000)
sroi_calc.add_input("工藝材料與推廣", 50000)

# 🎯 效益(含 Deadweight、Attribution、Displacement、Drop-off、Years)
sroi_calc.add_outcome("節省水資源成本", 50000, deadweight=0.15, attribution=0.1, displacement=0.0, dropoff=0.05, years=3)
sroi_calc.add_outcome("減碳社會效益(估算)", 70000, deadweight=0.10, attribution=0.1, displacement=0.0, dropoff=0.05, years=3)
sroi_calc.add_outcome("智慧養殖提升產值", 150000, deadweight=0.25, attribution=0.15, displacement=0.05, dropoff=0.1, years=3)
sroi_calc.add_outcome("地方品牌提升與觀光收益", 60000, deadweight=0.4, attribution=0.2, displacement=0.3, dropoff=0.1, years=3)
sroi_calc.add_outcome("居民生活與文化參與提升", 30000, deadweight=0.35, attribution=0.15, displacement=0.0, dropoff=0.05, years=3)

# ⏱️ 輸出結果
sroi_calc.summary()

執行結果:
📦 成本投入:
  - IoT設備與感測器: NT$120000
  - 水質淨化系統: NT$80000
  - 教學與培訓費用: NT$100000
  - 工藝材料與推廣: NT$50000

🎯 調整後效益(扣除 Deadweight、歸因、移轉、遞減):
  - 節省水資源成本: NT$109108.12
  - 減碳社會效益(估算): NT$161736.75
  - 智慧養殖提升產值: NT$246186.56
  - 地方品牌提升與觀光收益: NT$54633.6
  - 居民生活與文化參與提升: NT$47280.19

💡 SROI = 0.77

沒有留言:

張貼留言