Skip to content

Commit

Permalink
Improve performance in MarginalDamage3
Browse files Browse the repository at this point in the history
MarginalDamage3 now runs the model only for those years for which it
needs output.
  • Loading branch information
davidanthoff committed Nov 7, 2013
1 parent 87775de commit 9a898e2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Fund/MarginalDamage3.cs
Expand Up @@ -31,7 +31,9 @@ public MarginalDamage3()

public double Start()
{
var f1 = FundModel.GetModel(storeFullVariablesByDefault: false);
int yearsToRun = EmissionYear.Value + YearsToAggregate;

var f1 = FundModel.GetModel(storeFullVariablesByDefault: false, years: yearsToRun);
f1["impactwaterresources"].Variables["water"].StoreOutput = true;
f1["ImpactForests"].Variables["forests"].StoreOutput = true;
f1["ImpactHeating"].Variables["heating"].StoreOutput = true;
Expand All @@ -57,9 +59,9 @@ public double Start()
var result1 = f1.Run(Parameters);

var i_output1 = new ModelOutput();
i_output1.Load(result1);
i_output1.Load(result1, years: yearsToRun);

var f2 = FundModel.GetModel(storeFullVariablesByDefault: false);
var f2 = FundModel.GetModel(storeFullVariablesByDefault: false, years: yearsToRun);
f2["impactwaterresources"].Variables["water"].StoreOutput = true;
f2["ImpactForests"].Variables["forests"].StoreOutput = true;
f2["ImpactHeating"].Variables["heating"].StoreOutput = true;
Expand Down Expand Up @@ -108,7 +110,7 @@ public double Start()
var result2 = f2.Run(Parameters);

var i_output2 = new ModelOutput();
i_output2.Load(result2);
i_output2.Load(result2, years: yearsToRun);

// Take out growth effect effect of run 2 by transforming
// the damage from run 2 into % of GDP of run 2, and then
Expand Down

0 comments on commit 9a898e2

Please sign in to comment.