@@ -98,90 +98,84 @@ def poll_costs(
9898 else :
9999 # The period `p` for an investment cost is its vintage `v`.
100100 key = (cast ('Region' , r ), cast ('Period' , p ), cast ('Technology' , t ), cast ('Vintage' , p ))
101- if CostType .INVEST in entries .get (key , {}):
102- entries [key ][CostType .D_INVEST ] += discounted_cost
103- entries [key ][CostType .INVEST ] += undiscounted_cost
104- else :
105- entries [key ].update (
106- {CostType .D_INVEST : discounted_cost , CostType .INVEST : undiscounted_cost }
107- )
101+ entry = entries [key ]
102+ entry [CostType .D_INVEST ] = entry .get (CostType .D_INVEST , 0.0 ) + discounted_cost
103+ entry [CostType .INVEST ] = entry .get (CostType .INVEST , 0.0 ) + undiscounted_cost
108104
109105 for r , p , t in model .cost_fixed_eos_period_rpt :
110106 fixed_cost = value (cost_fixed_eos .period_cost (model , r , p , t ))
111107 if fixed_cost < epsilon :
112108 continue
113109
114- undiscounted_fixed_cost = fixed_cost * value (model .period_length [p ])
115- discounted_fixed_cost = costs .fixed_or_variable_cost (
110+ ud_fixed = float ( fixed_cost * value (model .period_length [p ]) )
111+ d_fixed = costs .fixed_or_variable_cost (
116112 1 ,
117113 fixed_cost ,
118114 value (model .period_length [p ]),
119115 global_discount_rate = global_discount_rate ,
120116 p_0 = p_0 ,
121117 p = p ,
122118 )
119+ d_fixed = float (value (d_fixed ))
123120
124121 if '-' in r :
125122 exchange_costs .add_cost_record (
126123 r ,
127124 period = p ,
128125 tech = t ,
129126 vintage = p ,
130- cost = float ( value ( discounted_fixed_cost )) ,
127+ cost = d_fixed ,
131128 cost_type = CostType .D_FIXED ,
132129 )
133130 exchange_costs .add_cost_record (
134131 r ,
135132 period = p ,
136133 tech = t ,
137134 vintage = p ,
138- cost = float ( undiscounted_fixed_cost ) ,
135+ cost = ud_fixed ,
139136 cost_type = CostType .FIXED ,
140137 )
141138 else :
142- entries [r , p , t , p ].update (
143- {
144- CostType .D_FIXED : float (value (discounted_fixed_cost )),
145- CostType .FIXED : float (undiscounted_fixed_cost ),
146- }
147- )
139+ key = (cast ('Region' , r ), cast ('Period' , p ), cast ('Technology' , t ), cast ('Vintage' , p ))
140+ entry = entries [key ]
141+ entry [CostType .D_FIXED ] = entry .get (CostType .D_FIXED , 0.0 ) + d_fixed
142+ entry [CostType .FIXED ] = entry .get (CostType .FIXED , 0.0 ) + ud_fixed
148143
149- for r , p , t in model .cost_fixed_eos_period_rpt :
144+ for r , p , t in model .cost_variable_eos_period_rpt :
150145 variable_cost = value (cost_variable_eos .period_cost (model , r , p , t ))
151146 if variable_cost < epsilon :
152147 continue
153148
154- undiscounted_variable_cost = variable_cost * value (model .period_length [p ])
155- discounted_variable_cost = costs .fixed_or_variable_cost (
149+ ud_variable = float ( variable_cost * value (model .period_length [p ]) )
150+ d_variable = costs .fixed_or_variable_cost (
156151 1 ,
157152 variable_cost ,
158153 value (model .period_length [p ]),
159154 global_discount_rate = global_discount_rate ,
160155 p_0 = p_0 ,
161156 p = p ,
162157 )
158+ d_variable = float (value (d_variable ))
163159
164160 if '-' in r :
165161 exchange_costs .add_cost_record (
166162 r ,
167163 period = p ,
168164 tech = t ,
169165 vintage = p ,
170- cost = float ( value ( discounted_variable_cost )) ,
166+ cost = d_variable ,
171167 cost_type = CostType .D_VARIABLE ,
172168 )
173169 exchange_costs .add_cost_record (
174170 r ,
175171 period = p ,
176172 tech = t ,
177173 vintage = p ,
178- cost = float ( undiscounted_variable_cost ) ,
174+ cost = ud_variable ,
179175 cost_type = CostType .VARIABLE ,
180176 )
181177 else :
182- entries [r , p , t , p ].update (
183- {
184- CostType .D_VARIABLE : float (value (discounted_variable_cost )),
185- CostType .VARIABLE : float (undiscounted_variable_cost ),
186- }
187- )
178+ key = (cast ('Region' , r ), cast ('Period' , p ), cast ('Technology' , t ), cast ('Vintage' , p ))
179+ entry = entries [key ]
180+ entry [CostType .D_VARIABLE ] = entry .get (CostType .D_VARIABLE , 0.0 ) + d_variable
181+ entry [CostType .VARIABLE ] = entry .get (CostType .VARIABLE , 0.0 ) + ud_variable
0 commit comments