Skip to content

Commit

Permalink
Merge pull request #37 from raddleverse/harmonize-scc-changes
Browse files Browse the repository at this point in the history
Update Repo to Include Updates Made for SCC
  • Loading branch information
tonyewong authored May 19, 2022
2 parents 002b725 + 4fa8a0c commit 9d9c3fa
Show file tree
Hide file tree
Showing 3 changed files with 404 additions and 357 deletions.
8 changes: 7 additions & 1 deletion src/ciam.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ function initciam(xsc, params, initparams, m::Model; fixed::Bool = true, t::Int
end
end

# set the VSL parameter to missings as a dummy and set vsl to be calculated
# endogenously
dummy_vsl = Array{Union{Missing, Float64}}(missing, length(dim_keys(m, :time)), length(dim_keys(m, :ciam_country)))
update_param!(m, :slrcost, :vsl_ciam_country, dummy_vsl)
update_param!(m, :slrcost, :vsl_exogenous, false)

# Set the rest of the parameters - to use update_leftover_params! we need To
# specific the component as well as the parameter name
params_dict = Dict()
Expand Down Expand Up @@ -92,7 +98,7 @@ function get_model(;initfile::Union{String, Nothing} = nothing, fixed::Bool=true

set_dimension!(m, :time, t)
set_dimension!(m, :adaptPers, length(params["at"]))
set_dimension!(m, :regions, xsc[2])
set_dimension!(m, :ciam_country, xsc[2])
set_dimension!(m, :segments, xsc[3])

if GAMSmatch
Expand Down
40 changes: 30 additions & 10 deletions src/slrcost.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ using Mimi
rsigA = Parameter(index = [segments]) # rsigA in GAMS code
rsigB = Parameter(index = [segments]) # rsigB in GAMS code


# ---Storm damage parameters---
floodmortality = Parameter() # Flood deaths as percent of exposed population; (Jonkman Vrijling 2008) (0.01)

# We make VSL an exogenously calculated variable for each region,
# and `vsl` is then simply pulled from `vsl_ciam_country`
vsl_ciam_country = Parameter(index = [time, ciam_country], unit = "million US\$2010/yr") # Value of statistical life (million 2010$)
# if TRUE, then VSL is exogenously calculated for each country and set in vsl_ciam_country, then each segment is set by looking up its country
# if FALSE, then VSL is endogenously calculated using vslel and vslmult as well as other endogenous socioeconomics for each segment
vsl_exogenous = Parameter{Bool}(default=true)

vsl_ciam_country = Parameter(index = [time, ciam_country], unit = "million US\$2010/yr") # Value of statistical life (million 2010$) (only used for exogenous calculation of vsl)
vslel = Parameter(default = 0.5) # Elasticity of vsl (0.5) (only used for endogenous calculation of vsl)
vslmult = Parameter(default = 216) # multiplier on USA GDP (216)(only used for endogenous calculation of vsl)

vsl = Variable(index = [time, segments], unit = "million US\$2010/yr") # Value of statistical life (million 2010$)

# ---Wetland Loss Parameters---
Expand Down Expand Up @@ -256,9 +260,6 @@ using Mimi
end
v.areaparams[m, :] = [p.area1[m] p.area2[m] p.area3[m] p.area4[m] p.area5[m] p.area6[m] p.area7[m] p.area8[m] p.area9[m] p.area10[m] p.area11[m] p.area12[m] p.area13[m] p.area14[m] p.area15[m]]

# Calculate vsl - pull VSL from vsl_ciam_country parameter for the proper region
v.vsl[t, m] = p.vsl_ciam_country[ti1, rgn_ind]

# Greenland segments are treated differently (RFF Model does not include Greenland)
if isgreenland(m, p.xsc)::Int == 1
v.ypc_seg[t, m] = 22642 * 1.01^1 # FLAG: assumes t is an index (1-20)
Expand All @@ -270,6 +271,17 @@ using Mimi
v.landvalue[t, m] = min(v.coastland[t, m], (v.land_appr[t, rgn_ind] * v.landdata[rgn_ind]))
end

# Calculate VSL
if p.vsl_exogenous
v.vsl[t, m] = p.vsl_ciam_country[ti1, rgn_ind] # pull VSL from vsl_ciam_country parameter for the proper region
else # endogenous calculation of VSL
if isgreenland(m, p.xsc)::Int == 1 # Greenland segments are treated differently
v.vsl[t, m] = 1e-6 * p.vslmult * p.ypcc[ti1, p.rgn_ind_usa] * (v.ypc_seg[t, m] / p.ypcc[ti1, p.rgn_ind_usa])^p.vslel
else
v.vsl[t, m] = 1e-6 * p.vslmult * p.ypcc[ti1, p.rgn_ind_usa] * (p.ypcc[t, rgn_ind] / p.ypcc[ti1, p.rgn_ind_usa])^p.vslel
end
end

v.capital[t, m] = p.kgdp * v.ypc_seg[t, m] * v.popdens_seg[t, m] * 1e-6
v.coastArea[t, m] = calcCoastArea(view(v.areaparams, m, :), p.lslr[t, m])

Expand All @@ -286,9 +298,6 @@ using Mimi
# v.popdens_seg[ti,m]=p.popdens_seg_merkens[ti,m]
end

# Calculate vsl - pull VSL from vsl_ciam_country parameter for the proper region
v.vsl[ti, m] = p.vsl_ciam_country[ti, rgn_ind]

# Special treatment for Greenland segments
if isgreenland(m, p.xsc)::Int == 1
v.ypc_seg[ti, m] = 22642 * 1.01^i # FLAG: assumes i is an index (1-20)
Expand All @@ -302,6 +311,17 @@ using Mimi

end

# Calculate VSL
if p.vsl_exogenous
v.vsl[ti, m] = p.vsl_ciam_country[ti, rgn_ind]
else # endogenously calculate VSL
if isgreenland(m, p.xsc)::Int == 1 # Special treatment for Greenland segments
v.vsl[ti, m] = 1e-6 * p.vslmult * p.ypcc[ti, p.rgn_ind_usa] * (v.ypc_seg[ti, m] / p.ypcc[ti, p.rgn_ind_usa])^p.vslel
else
v.vsl[ti, m] = 1e-6 * p.vslmult * p.ypcc[ti, p.rgn_ind_usa] * (p.ypcc[ti, rgn_ind] / p.ypcc[ti, p.rgn_ind_usa])^p.vslel
end
end

v.capital[ti, m] = p.kgdp * v.ypc_seg[ti, m] * v.popdens_seg[ti, m] * 1e-6
v.coastArea[ti, m] = calcCoastArea(view(v.areaparams, m, :), p.lslr[ti, m])
v.wetlandloss[tim1, m] = min(1, (localrate(p.lslr[tim1, m], p.lslr[ti, m], p.tstep) / p.wmaxrate)^2)
Expand Down
Loading

0 comments on commit 9d9c3fa

Please sign in to comment.