DICEModel.jl provides a practical, full open-source (using all open-source tools) implementation of the latest version of the Nordhaus’s DICE (Dynamic Integrated Climate-Economy model) model, keeping the model readable, compact and as close as possible to the original (GAMS) code.
This package provides two functions:
-
run_dice_scenario(scenario_name)
[browse code - documentation ] : runs one of the “official” 10 scenarios; -
run_dice(;optimizer,bounds,kwargs...)
[browse code - documentation] : run DICE with custom solver engine (and eventually options), custom variable constraints (bounds) or custom parameters (see Parameters).
In both cases the output (results) is a named tuple. Use keys(results)
to find the available information (or just look at the source code) and results.VARIABLEX
to obtain the values.
A summary of the main results is available on this page.
Example
using Pkg
Pkg.activate(@__DIR__)
Pkg.add(["DICEModel","Plots"]) # run only once, then comment out
using DICEModel, Plots
# CB Optimal scenario...
res_cbopt = run_dice_scenario("cbopt")
# Base scenario...
res_base = run_dice_scenario("base")
# Paris "extended" scenario...
tidx = 1:81
# upper limit to emissions mitigation rate
miuup = @. min( 0.05 + 0.04*(tidx-1) - 0.01*max(0,tidx-5) ,1.00)
res_parisext = run_dice(miuup = miuup) # or simply: run_dice_scenario("parisext")
# Max 2 °C scenario...
res_t2c = run_dice(bounds = Dict("TATM"=>("<=",2.0))) # or simply: run_dice_scenario("t2c")
# Plots
times = res_cbopt.times
# CO2 emissions plot...
plot(times[1:11],res_cbopt.ECO2[1:11],ylim=(0,70), title="CO₂ emissions",ylabel="GtCO₂/yr",label="C/B optimal", color=:blue4, markershape=:circle, markercolor=:white)
plot!(times[1:11],res_base.ECO2[1:11], label="Base", colour=:goldenrod3, markershape=:circle, markercolor=:goldenrod3)
plot!(times[1:11],res_parisext.ECO2[1:11], label="Paris ext", colour=:red, linestyle=:dash)
plot!(times[1:11],res_t2c.ECO2[1:11], label="T < 2 °C", colour=:green, markershape=:cross, markercolor=:green)
# Carbon price plot...
plot(times[1:9],res_cbopt.CPRICE[1:9],ylim=(0,300), title="Carbon price",ylabel="2019\$ / t tCO₂",label="C/B optimal", color=:blue4, markershape=:circle, markercolor=:white)
plot!(times[1:9],res_base.CPRICE[1:9], label="Base", colour=:goldenrod3, markershape=:circle, markercolor=:goldenrod3)
plot!(times[1:9],res_parisext.CPRICE[1:9], label="Paris ext", colour=:red, linestyle=:dash)
plot!(times[1:9],res_t2c.CPRICE[1:9], label="T < 2 °C", colour=:green, markershape=:cross, markercolor=:green)
Other packages or implementations of the DICE model
Other packages, in both Julia and other languages, already implement the DICE model, but often don’t have the same level of readability and compactness as the original GAMS code:
-
DuBois Julia implementation: There are no updates to DICE 2023, and the code divided in many pieces;
-
MIMI framework based implementations (eg. v2016 or v2016R2): There are no updated to DICE 2023, the code is divided in many pieces (different implementation and solver structure)
-
olugovoy implementation in various languages (Julia included): No updates, code looks very “R like”
-
Benet and Akshay MATLAB implementation : Still requires MATLAB, code not readable/compact as GAMS or JuMP
-
Nie and Welch Python implementation : Code not readable/compact as GAMS or JuMP