Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP support for DualNumbers SCC calculations #31

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

corakingdon
Copy link
Collaborator

@corakingdon corakingdon commented Sep 11, 2019

I think DualNumbers magically works, just like you anticipated! (pending on the one small change in Mimi here: mimiframework/Mimi.jl#544)

I started trying to do this with the welfare component for FUND that you started here #21, but I wasn't sure about the units or why the welfare values were negative, so instead I branched off master and added a Discounting component. This component calculates discounted loss in each year, and sums the discounted values in the final timestep for total discounted damages (to use for SCC calcualtion).

Using DualNumbers, the "pulse" component (currently defined in "new_marginaldamages.jl") now just adds a Dual(0, pulse_size) in the desired year to emissions.

Not yet implemented:

  • equity weighting (should be added to the Discounting component)
  • non-zero eta values (should be added to the Discounting component)
  • support for other gases (just needed to modify the functions for adding the pulse)

Design questions:

  • right now I just added a number_type keyword to get_model where the user has to specify the actual DataType, such as Dual{Float64}. Alternatively, we could have get_model support various symbol type keywords for returning different types of MimiFUND models, such as type = :default or type = :dual
  • right now I just added separate compute_scco2_dual and add_marginal_emissions_dual! functions, but these could be incorporated into the existing functions where we could do more sophisticated type checking
  • is there a way to add the pulse without having to add a whole component like I did here?

@codecov-io
Copy link

codecov-io commented Sep 11, 2019

Codecov Report

Merging #31 into master will decrease coverage by 2.09%.
The diff coverage is 6.06%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #31     +/-   ##
=========================================
- Coverage   78.58%   76.48%   -2.1%     
=========================================
  Files          39       39             
  Lines         892      923     +31     
=========================================
+ Hits          701      706      +5     
- Misses        191      217     +26
Impacted Files Coverage Δ
src/new_marginaldamages.jl 65.51% <0%> (-23.9%) ⬇️
src/MimiFUND.jl 100% <100%> (ø) ⬆️
src/components/ImpactSeaLevelRiseComponent.jl 86.9% <0%> (+5.95%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0890e0...b997cb2. Read the comment docs.

@davidanthoff
Copy link
Member

but I wasn't sure about the units or why the welfare values were negative

The negative numbers are correct (higher consumption still increases welfare). The trick is to normalize the marginal SCC estimate you get from the DualNumber with marginal welfare of consumption in the present, and at that point you should have a nice positive SCC. I do think it would be nicer if we can use the welfare component for this instead of a separate discounting component...

Dual(0, pulse_size)

I believe we want to make this Dual(0., 1.), and then after we computed the derivative adjust for pulse size.

is there a way to add the pulse without having to add a whole component like I did here

Maybe just set the parameter to a vector of Dual, and only in one year is the dual component of Dual set to 1?

@corakingdon
Copy link
Collaborator Author

but I wasn't sure about the units or why the welfare values were negative

The negative numbers are correct (higher consumption still increases welfare). The trick is to normalize the marginal SCC estimate you get from the DualNumber with marginal welfare of consumption in the present, and at that point you should have a nice positive SCC. I do think it would be nicer if we can use the welfare component for this instead of a separate discounting component...

So would it be:

scc = m[:welfare, :cum_welfare][end].epsilon / m[:welfare, marginal_welfare][present].value

Dual(0, pulse_size)

I believe we want to make this Dual(0., 1.), and then after we computed the derivative adjust for pulse size.

I have to admit I don't understand why, but we can discuss later!

is there a way to add the pulse without having to add a whole component like I did here

Maybe just set the parameter to a vector of Dual, and only in one year is the dual component of Dual set to 1?

The problem is that the emissions vector is calculated endogenously in the emissions component, and that gets passed to the co2 cycle component, so the pulse has to be added in between.

@davidanthoff
Copy link
Member

So would it be:

I think yes.

The problem is that the emissions vector is calculated endogenously in the emissions component, and that gets passed to the co2 cycle component, so the pulse has to be added in between.

Can't we use the adder component from Mimi for that?

@lrennels lrennels marked this pull request as draft June 3, 2021 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants