Comments (7)
Hey Henri!
With only a small modifcation, we can use diagnostic functions like control cost, damages, and final temperature inside JuMP. These are Vector -> scalar
functions, and thereβs a trick for that: https://jump.dev/JuMP.jl/v0.21.1/nlp/#User-defined-functions-with-vector-inputs-1
Using this trick, we can minimize control costs subject to temp[2200] <= T_max
(i.e. overshoot allowed), all using MARGO's diagnostic functions.
But we wonβt be able to use Vector -> Vector
functions, which is needed for the global temperature constraint. You need to write out the cumsum
behaviour like we currently do, but I think it can still be made more concise by partially reusing the diagnostic code.
I wrote a more detailed notebook about it here, which is just the mitigation optimization. To run the notebook, you need to checkout the forward-diffable branch of ClimateMARGO, so I also made a PDF.
Have a look at "Conclusions" on page 6
π jump test margo.jl β‘ Pluto.jl β‘.pdf
https://github.com/fonsp/disorganised-mess/blob/master/jump%20test%20margo.jl
from climatemargo.jl.
I feel like there should be some trick to generalize the clunky cumsum
formulation we have now, even if it has to be done separately for individual Vector -> Vector
operators...
from climatemargo.jl.
The first thing to do is set up some very simple tests of JuMP and see how far we can push the use of functions to simplify the optimization before we break JuMP.
from climatemargo.jl.
Looks like some of this is possible with the user-defined functions API in JuMP. I'm a bit nervous about whether this will extend to the cumsum
implementation of the Green's functions kernels in the energy balance model, since it's not just a combination of elementary functions...
from climatemargo.jl.
Awesome progress @fonsp! I'll take a look at it in the next couple of days!
from climatemargo.jl.
To add to this: JuMP uses forward mode automatic differentiation (dual numbers). This means that it can automatically differentiate our diagnostic functions π, and also user-defined functions π, even though they are a 'black box' from the perspective of ClimateMARGO.jl. As long as they are not 'too complex' (not sure what that means yet), and as long as they accept the more general Real
type instead of the Float64
type, it will work.
If we ever have a user whose custom functions are not auto-diffable, JuMP does not include finite differencing by default, but it seems like we can add that functionality later, either by supplying a finite difference method as the 'derivative', or by switching packages.
from climatemargo.jl.
In the end, I was able to also use Vector->Vector
functions with an additional wrapper function, but the performance impact is very large (~ 10x - 500x slower). I tried lots of things, but I can't figure out exactly why it is this much slower...
If anyone is interested, I can document what I tried. Code is here, here and here.
from climatemargo.jl.
Related Issues (20)
- Consistent mitigation costs HOT 1
- Consistent and correct methods for changing the timestep on the fly. HOT 8
- Add optimization constraints as a submodel in ClimateModel or ClimateModelParameters? HOT 1
- Implement exact solution to two-box energy balance model HOT 2
- Towards a generic MARGO model structure (with abstract submodel types) HOT 1
- Add costs attributed to emissions (e.g. air pollution on human health) and CO2 (e.g. ocean acidification) HOT 3
- Inconsistency about whether `t.==present_year` should be included in `future_mask`. HOT 1
- Moving to ClimateMARGO github organization HOT 3
- TagBot trigger issue HOT 22
- Problems with T_adapt and optimization in 0.2.0 HOT 2
- Stochastic optimization
- Replace PyPlot calls with Plots.jl HOT 5
- Replace "tutorial.ipynb" with a Literate.jl script HOT 1
- Inconsistent naming "M" and "mitigate", nested and flat, struct and Dict HOT 4
- "How do I extract ClimateMARGO.jl data as a csv file?" HOT 4
- Experiment with converting to NLopt instead of JuMP
- Include example of the "policy response process" described in paper HOT 1
- What new feature or storyline would you like to see?
- Multiple equilibria HOT 3
- emissions to concentrations Q (unit_conversions.jl) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from climatemargo.jl.