-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_COIN_009_valueOfCO2_welfare.py
373 lines (256 loc) · 23.6 KB
/
run_COIN_009_valueOfCO2_welfare.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 12 14:53:40 2020
@author: kcaldeira
"""
from plot_utilities import *
from io_utilities import *
import cProfile
from DICE_diffeqs import DICE_instance
#%%
# starting point has learning curve of 10 k$ at 10,000 tCO2, and a learning rate of 12% per doubling.
if __name__ == "__main__":
#initCostList = [10000,8000,6300,5000,4000,3200,2500,2000,1600,1300,1000,800,630,500,400,320,250,200,160,130,100,80,63,50,40,32,25,20,16,13,10]
#initCostList = [8900,7100,5600,4500,3500,2800,2200,1800,1400,1100,890,710,560,450,350,280,220,180,140,110,89,71,56,45,35,28,22,18,14,11,7900,790,79]
#initCostList = [28,22,18,14,11,7900,790,79]
#rampOpts = ['0by2050','welfare','max']
#rampOpts = ['max']
shiftOpts = ['shift']
#shiftOpts = ["shift"]
#initCostList = [1,0.8,0.6,0.4,0.2,0]
#initCostList = np.insert(np.round(10.**-np.arange(0,2.05,0.05),6),0,10)
#initCostList = np.round(10.**-np.arange(1.75,2.05,0.05),6)
#initCostList = np.array([10])
initCostList = [10.,1.]
initCostRef = 1.0
rampOpts = ['welfare']
#rampOpts = ['0by2050']
#rateOptDic = {"20pct":0.2630344058337938,"15pct":0.1634987322828795,"12pct":0.15055967657538144,"10pct":0.13750352374993496}
rateOptDic = {"10pct":0.13750352374993496}
maxEval = 200000
initAmounts = [1e-6]
#cumETotInitList = [0,0.01,0.03,0.1,0.3,1,3,10,30,100]
cumETotInitList = [0,100,50,20,70,40,80,10,30,60,90,150,200]
#initCostList = [1.e4,9.e3,8.e3,7.e3,6.e3,5.e3,4.e3,3.e3,2.e3,1.5e3,1.e3,900,800,700,600,500,400,300,200,100,50,0,1.e20]
#initCostList = [1e4,1e3,1e2]
#initCostList = [1.e20,1.e4,1.e3,100,0]
#initCostList = [1.e20,1.e3,900,800,700,600,500,400,300,200,100,50,0]
dt0 = 1.
for initCost in initCostList:
for shiftOpt in shiftOpts:
for initAmt in initAmounts:
for rateOpt in rateOptDic.keys():
if shiftOpt == 'shift':
initAmount = initAmt
else:
if initCost > 0:
initAmount = initAmt*(initCost/initCostRef)**(-1./rateOptDic[rateOpt])
else:
initAmount = 1.e80
sdt = [0,dt0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,170,200,240,260,280,300]
for rampOpt in rampOpts:
if rampOpt == '0by2050':
# allow for savings rate discontinuity at 30 in ramp case
sdt = [0,dt0,10,20,29.9999,30,40,50,60,70,80,90,100,110,120,130,140,150,170,200,240,260,280,300]
# assumes years 0, 1, 5, 10, 15, 20 ,25, 39
limLower = [0.,0.03333333333333333333,0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1.,
1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.]
limUpper = limLower
elif rampOpt == 'max':
limLower = 1.0
limUpper = limLower
else:
limLower = 0.0
limUpper = 1.0
# note that the miu = 0 case is identical to the one technology miu = 0 case.
for cumETotInit in cumETotInitList:
caseName = 'COIN_009_initAbate_'+str(cumETotInit)+"_"+str(initCost)+'_'+str(initAmt)+'_'+shiftOpt+'_'+rampOpt+'_'+str(maxEval)
# If no arg is given, run vanilla DICE
print (caseName)
resultCentral = DICE_instance(
COINmode = True, # simple version
dt = dt0, # dt time step for integration
nTechs = 2, # number of technologies considered
decisionTimes =[0,dt0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,170,200,240,260,280,300], # times for miu decisions
# NOTE: <decisionTimes> are also the times assumed for specified limits on miu
#limMiuLower = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], # lower limit on miu values (= sum across all techs)
limMiuLower = limLower,
#limMiuLower = [0.,0.,0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1.,
# 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.],
#limMiuLower = 0, # can be scalar or vector of len(decisionTimes)
limMiuUpper = limUpper, # upper limit on miu values (= sum across all techs)
#limMiuUpper = [1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2], # upper limit on miu values (= sum across all techs)
#limMiuUpper = 1.0, # can be scalar or vector of len(decisionTimes)
optSavings = True, # True means to optimize on savings rate, False means to use default value (different for COINmode)
savingDecisionTimes =sdt, # times for miu decisions
decisionInterpOrder = 1, # 0 = step function, 1 = linear, 2 = spline savings only
cumETotInit = - cumETotInit, # give the system some CO2 to start with
techLearningCurve = [False,True], # does this technology have a learning curve (True) or a specified cost function (False)
# NOTE: <learningCurveTech> must have a length of <nTechs>
techInitCost = [0.2,initCost], # Initial cost for learning curve. Must be same shape as nTechs.
#techInitCost = [550, 1e4], # Initial cost for learning curve. Must be same shape as nTechs.
# If no learning curve, then this value is the initial backstop cost (pback)
techInitAmount = [0,initAmount], # Initial cost for learning curve. Must be same shape as nTechs, but value if no learning curve is unimportant
techLearningRate = [0.005,rateOptDic[rateOpt]], # 10% per doubling (1 + 0.10)**-1. Must be same shape as nTechs.
#techLearningRate = [0.005050763379468082, 0.23446525363702297], # 15% per doubling. Must be same shape as nTechs.
# techLearningRate = [0.005050763379468082, 0.18442457113742744], # 12% per doubling. Must be same shape as nTechs.
# If no learning curve, then value is fractional cost improvement per year
firstUnitFractionalCost = [0.0,0.5], # Marginal cost at miuX = 0 compared to marginal cost at miuX = 1.
utilityOption = 1, # utilityOption == 0 --> DICE utility function; 1 --> assume consumption == utility
prstp = 0.03, # pure rate of time preference (0.015 is DICE default ; for default, just comment out and don't define )
parallel = 15, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
#parallel = 1, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
maxeval = maxEval, # maxeval maximum number of iterations for solver
#maxeval = 100, # maxeval maximum number of iterations for solver
FOCUS = 100, # FOCUS parameter for midaco solver
damageCostRatio = 1.0, # scaling on climate damage
abatementCostRatio = 1.0 # scaling on abatement costs (multiplies costs above for all techs)
)
pickle_results('../dice-diffeqs_analyze/output',caseName,filter_dic(resultCentral.out))
write_CSV_from_pickle('../dice-diffeqs_analyze/output',caseName)
"""
#initCostList = [10000,8000,6300,5000,4000,3200,2500,2000,1600,1300,1000,800,630,500,400,320,250,200,160,130,100,80,63,50,40,32,25,20,16,13,10]
#initCostList = [8900,7100,5600,4500,3500,2800,2200,1800,1400,1100,890,710,560,450,350,280,220,180,140,110,89,71,56,45,35,28,22,18,14,11,7900,790,79]
#initCostList = [28,22,18,14,11,7900,790,79]
#rampOpts = ['0by2050','welfare','max']
#rampOpts = ['max']
#shiftOpts = ['shift','follow']
shiftOpts = ["shift"]
#initCostList = [1,0.8,0.6,0.4,0.2,0]
#initCostList = np.insert(np.round(10.**-np.arange(0,2.05,0.05),6),0,10)
#initCostList = np.round(10.**-np.arange(1.05,2.05,0.05),6)
#initCostList = np.array([10])
initCostList = [10.0]
initCostRef = 1.0
#rampOpts = ['welfare',"max","0by2050"]
rampOpts = ['no-abate']
#rateOptDic = {"20pct":0.2630344058337938,"15pct":0.1634987322828795,"12pct":0.15055967657538144,"10pct":0.13750352374993496}
rateOptDic = {"10pct":0.13750352374993496}
maxEval = 100000
initAmounts = [1e-6]
#initCostList = [1.e4,9.e3,8.e3,7.e3,6.e3,5.e3,4.e3,3.e3,2.e3,1.5e3,1.e3,900,800,700,600,500,400,300,200,100,50,0,1.e20]
#initCostList = [1e4,1e3,1e2]
#initCostList = [1.e20,1.e4,1.e3,100,0]
#initCostList = [1.e20,1.e3,900,800,700,600,500,400,300,200,100,50,0]
for initCost in initCostList:
for shiftOpt in shiftOpts:
for initAmt in initAmounts:
for rateOpt in rateOptDic.keys():
if shiftOpt == 'shift':
initAmount = initAmt
else:
if initCost > 0:
initAmount = initAmt*(initCost/initCostRef)**(-1./rateOptDic[rateOpt])
else:
initAmount = 1.e80
for rampOpt in rampOpts:
if rampOpt == '0by2050':
limLower = [0.,0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1.,
1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.]
limUpper = limLower
elif rampOpt == 'max':
limLower = 1.0
limUpper = limLower
elif rampOpt == 'no-abate':
limUpper = 0.0
limLower = 0.0
else:
limLower = 0.0
limUpper = 1.0
# note that the miu = 0 case is identical to the one technology miu = 0 case.
caseName = 'COIN_004_'+rateOpt+"_"+str(initCost)+'_'+str(initAmt)+'_'+shiftOpt+'_'+rampOpt+'_'+str(maxEval)
# If no arg is given, run vanilla DICE
print (caseName)
resultCentral = DICE_instance(
COINmode = True, # simple version
dt = 1, # dt time step for integration
nTechs = 2, # number of technologies considered
decisionTimes =[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,170,200,240,260,280,300], # times for miu decisions
# NOTE: <decisionTimes> are also the times assumed for specified limits on miu
#limMiuLower = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], # lower limit on miu values (= sum across all techs)
limMiuLower = limLower,
#limMiuLower = [0.,0.,0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1.,
# 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.],
#limMiuLower = 0, # can be scalar or vector of len(decisionTimes)
limMiuUpper = limUpper, # upper limit on miu values (= sum across all techs)
#limMiuUpper = [1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2], # upper limit on miu values (= sum across all techs)
#limMiuUpper = 1.0, # can be scalar or vector of len(decisionTimes)
optSavings = True, # True means to optimize on savings rate, False means to use default value (different for COINmode)
#savingDecisionTimes =[0,20,40,60,80,100,140,200,260,280,300], # times for savings rate decisions
#savingDecisionTimes =[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,170,200,240,260,280,300], # times for miu decisions
#savingDecisionTimes =[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,170,200,240,260,280,300], # times for miu decisions
savingDecisionTimes =[0,5,10,20,30,45,60,90,120,150,200,240,260,280,290,300], # times for miu decisions
#savingDecisionTimes =[0,30,60,90,120,150,200,260,280,300], # times for miu decisions
techLearningCurve = [False,True], # does this technology have a learning curve (True) or a specified cost function (False)
# NOTE: <learningCurveTech> must have a length of <nTechs>
techInitCost = [0.2,initCost], # Initial cost for learning curve. Must be same shape as nTechs.
#techInitCost = [550, 1e4], # Initial cost for learning curve. Must be same shape as nTechs.
# If no learning curve, then this value is the initial backstop cost (pback)
techInitAmount = [0,initAmount], # Initial cost for learning curve. Must be same shape as nTechs, but value if no learning curve is unimportant
techLearningRate = [0.005,rateOptDic[rateOpt]], # 10% per doubling (1 + 0.10)**-1. Must be same shape as nTechs.
#techLearningRate = [0.005050763379468082, 0.23446525363702297], # 15% per doubling. Must be same shape as nTechs.
# techLearningRate = [0.005050763379468082, 0.18442457113742744], # 12% per doubling. Must be same shape as nTechs.
# If no learning curve, then value is fractional cost improvement per year
firstUnitFractionalCost = [0.0,0.5], # Marginal cost at miuX = 0 compared to marginal cost at miuX = 1.
utilityOption = 1, # utilityOption == 0 --> DICE utility function; 1 --> assume consumption == utility
prstp = 0.03, # pure rate of time preference (0.015 is DICE default ; for default, just comment out and don't define )
parallel = 15, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
#parallel = 1, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
maxeval = maxEval, # maxeval maximum number of iterations for solver
#maxeval = 100, # maxeval maximum number of iterations for solver
FOCUS = 100, # FOCUS parameter for midaco solver
damageCostRatio = 1.0, # scaling on climate damage
abatementCostRatio = 1.0 # scaling on abatement costs (multiplies costs above for all techs)
)
pickle_results('../dice-diffeqs_analyze/output',caseName,filter_dic(resultCentral.out))
write_CSV_from_pickle('../dice-diffeqs_analyze/output',caseName)
#----------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------
caseName = 'COIN_004noDamage_'+rateOpt+"_"+str(initCost)+'_'+str(initAmt)+'_'+shiftOpt+'_'+rampOpt+'_'+str(maxEval)
# If no arg is given, run vanilla DICE
print (caseName)
resultCentral = DICE_instance(
COINmode = True, # simple version
dt = 1, # dt time step for integration
nTechs = 2, # number of technologies considered
decisionTimes =[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,170,200,240,260,280,300], # times for miu decisions
# NOTE: <decisionTimes> are also the times assumed for specified limits on miu
#limMiuLower = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], # lower limit on miu values (= sum across all techs)
limMiuLower = limLower,
#limMiuLower = [0.,0.,0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334, 1.,
# 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.],
#limMiuLower = 0, # can be scalar or vector of len(decisionTimes)
limMiuUpper = limUpper, # upper limit on miu values (= sum across all techs)
#limMiuUpper = [1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2,1.2], # upper limit on miu values (= sum across all techs)
#limMiuUpper = 1.0, # can be scalar or vector of len(decisionTimes)
optSavings = True, # True means to optimize on savings rate, False means to use default value (different for COINmode)
#savingDecisionTimes =[0,20,40,60,80,100,140,200,260,280,300], # times for savings rate decisions
#savingDecisionTimes =[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,170,200,240,260,280,300], # times for miu decisions
#savingDecisionTimes =[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,170,200,240,260,280,300], # times for savings rate decisions
savingDecisionTimes =[0,5,10,20,30,45,60,90,120,150,200,240,260,280,290,300], # times for savings rate decisions
#savingDecisionTimes =[0,30,60,90,120,150,200,260,280,300], # times for savings rate decisions
techLearningCurve = [False,True], # does this technology have a learning curve (True) or a specified cost function (False)
# NOTE: <learningCurveTech> must have a length of <nTechs>
techInitCost = [0.2,initCost], # Initial cost for learning curve. Must be same shape as nTechs.
#techInitCost = [550, 1e4], # Initial cost for learning curve. Must be same shape as nTechs.
# If no learning curve, then this value is the initial backstop cost (pback)
techInitAmount = [0,initAmount], # Initial cost for learning curve. Must be same shape as nTechs, but value if no learning curve is unimportant
techLearningRate = [0.005,rateOptDic[rateOpt]], # 10% per doubling (1 + 0.10)**-1. Must be same shape as nTechs.
#techLearningRate = [0.005050763379468082, 0.23446525363702297], # 15% per doubling. Must be same shape as nTechs.
# techLearningRate = [0.005050763379468082, 0.18442457113742744], # 12% per doubling. Must be same shape as nTechs.
# If no learning curve, then value is fractional cost improvement per year
firstUnitFractionalCost = [0.0,0.5], # Marginal cost at miuX = 0 compared to marginal cost at miuX = 1.
utilityOption = 1, # utilityOption == 0 --> DICE utility function; 1 --> assume consumption == utility
prstp = 0.03, # pure rate of time preference (0.015 is DICE default ; for default, just comment out and don't define )
parallel = 15, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
#parallel = 1, # number of cores to use, 0 or 1 is single core; Serial: 0 or 1, Parallel: 2,3,4,5,6,7,8...
maxeval = maxEval, # maxeval maximum number of iterations for solver
#maxeval = 100, # maxeval maximum number of iterations for solver
FOCUS = 100, # FOCUS parameter for midaco solver
damageCostRatio = 0.0, # scaling on climate damage
abatementCostRatio = 1.0 # scaling on abatement costs (multiplies costs above for all techs)
)
pickle_results('../dice-diffeqs_analyze/output',caseName,filter_dic(resultCentral.out))
write_CSV_from_pickle('../dice-diffeqs_analyze/output',caseName)
"""
# %%