Skip to content

Commit

Permalink
Merge pull request #417 from SchmidtDSE/add-tax-monte-carlo
Browse files Browse the repository at this point in the history
Add tax to monte carlo.
  • Loading branch information
sampottinger authored Sep 7, 2024
2 parents 65694c3 + dc2a3ef commit eb77b04
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 17 deletions.
2 changes: 1 addition & 1 deletion js/compile_visitor.js_template
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ class CompileVisitor extends toolkit.PlasticsLangVisitor {
return 1 / identifiers.length * valueToDistribute;
};

const isLinearEffective = isLinear || totalTargetsValue == 0;
const isLinearEffective = isLinear || totalTargetsValue <= 0;

const getChange = isLinearEffective ? getChangeLinear : getChangeProportional;

Expand Down
2 changes: 1 addition & 1 deletion js/polymers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ class GhgFinalizer {
const leverName = eolInfo["leverName"];

const volumeFate = regionOut.get(attr);
const fatePercent = volumeFate / totalWaste;
const fatePercent = totalWaste == 0 ? 0 : volumeFate / totalWaste;

const fateExportVolume = fatePercent * totalExportVolume;
const fateImportVolume = fatePercent * totalImportVolume;
Expand Down
4 changes: 3 additions & 1 deletion js/sim_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ class SimPresenter {

return singleFuture.then((x) => getGoals(x.get(self.getYear())))
.then((x) => self._labelGoals(x, label))
.then((x) => x, () => self._executeSingle(label, setupProgram));
.then((x) => x, (err) => {
throw ("Failed on " + label + " with " + err);
});
}

_labelGoals(targets, label) {
Expand Down
2 changes: 1 addition & 1 deletion js/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20240907
20240908
2 changes: 1 addition & 1 deletion pt/consumption_tax.pt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ change percentDecreaseDelay by percentDecreaseEnd over startYearDelay to endYear
# Reduce consumption
var originalConsumption = out.{{ region }}.consumptionPackagingMT;
var reducedConsumption = originalConsumption * percentDecrease;
limit reducedConsumption to [0,];
limit reducedConsumption to [0, out.{{ region }}.consumptionPackagingMT * 0.999];
out.{{ region }}.consumptionPackagingMT = out.{{ region }}.consumptionPackagingMT - reducedConsumption;

# Reduce imports
Expand Down
2 changes: 1 addition & 1 deletion pt/index.json_template
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@
"min": 0,
"max": 5,
"default": {{ region['constants']['packagingTaxMultiplier'] }},
"step": 0.01,
"step": 0.001,
"decimals": 2,
"units": "",
"forcePlus": false,
Expand Down
17 changes: 13 additions & 4 deletions pt/pre_trade.pt
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,35 @@ var newExports = newNet * -1;
limit newImports to [0,];
limit newExports to [0,];

var priorImports = out.{{ region }}.netImportsMT;
var priorExports = out.{{ region }}.netExportsMT;

out.{{ region }}.netImportsMT = newImports;
out.{{ region }}.netExportsMT = newExports;

# Balance goods imports
distribute changeImports across [
var partnerImports = changeImports - priorExports;
limit partnerImports to [0,];

distribute partnerImports across [
{{#each otherRegions}}
out.{{ this }}.netExportsMT{{#unless @last}},{{/unless}}
{{/each}}
] proportionally;

# Propogate into trade partners production
distribute changeImports across [
distribute partnerImports across [
{{#each otherRegions}}
out.{{ this }}.primaryProductionMT by out.{{ this }}.netExportsMT * out.{{ this }}.primaryProductionMT,
out.{{ this }}.secondaryProductionMT by out.{{ this }}.netExportsMT * out.{{ this }}.secondaryProductionMT{{#unless @last}},{{/unless}}
{{/each}}
] proportionally;

# Balance goods exports
distribute changeExports across [
var partnerExports = changeExports - priorImports;
limit partnerExports to [0,];

distribute partnerExports across [
{{#each otherRegions}}
out.{{ this }}.netImportsMT{{#unless @last}},{{/unless}}
{{/each}}
Expand All @@ -78,7 +87,7 @@ var {{ this }}WasteMultiplier = out.{{ this }}.netImportsMT;
{{ this }}WasteMultiplier = {{ this }}WasteMultiplier + out.{{ this }}.netWasteImportMT;
{{/each}}

distribute changeExports across [
distribute partnerExports across [
{{#each otherRegions}}
out.{{ this }}.eolRecyclingMT by out.{{ this }}.eolRecyclingMT * {{ this }}WasteMultiplier,
out.{{ this }}.eolLandfillMT by out.{{ this }}.eolLandfillMT * {{ this }}WasteMultiplier,
Expand Down
6 changes: 6 additions & 0 deletions pt/simulation.pt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ in.rowRecyclingCost = in.rowRecyclingCost * (draw uniformly from 0.9 to 1.1);
in.rowIncinerationCost = in.rowIncinerationCost * (draw uniformly from 0.9 to 1.1);
in.rowLandfillCost = in.rowLandfillCost * (draw uniformly from 0.9 to 1.1);

# Tax response
in.chinaTaxMultiplier = draw uniformly from 0.087 to 0.088;
in.eu30TaxMultiplier = draw uniformly from 0.559 to 0.580;
in.naftaTaxMultiplier = draw uniformly from 0.111 to 0.125;
in.rowTaxMultiplier = draw uniformly from 0.221 to 0.240;

# == Apply BAU sampling ==
in.chinaPreConsumptionMultiplier = 100; # Enable China consumption offset
in.eu30PreConsumptionMultiplier = 100; # Enable EU30 consumption offset
Expand Down
8 changes: 4 additions & 4 deletions regions.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"incerationCost": 151,
"landfillCost": 126,
"packagingTaxPower": 1.14,
"packagingTaxMultiplier": 0.09,
"packagingTaxMultiplier": 0.087,
"percentRecyclingYieldLoss": 20,
"percentReuseExhaustion": 12,
"percentIncinerationPlastic": 12,
Expand Down Expand Up @@ -107,7 +107,7 @@
"incerationCost": 292,
"landfillCost": 225,
"packagingTaxPower": 0.12,
"packagingTaxMultiplier": 0.56,
"packagingTaxMultiplier": 0.564,
"percentRecyclingYieldLoss": 20,
"percentReuseExhaustion": 12,
"percentIncinerationPlastic": 11.5,
Expand Down Expand Up @@ -170,7 +170,7 @@
"incerationCost": 221,
"landfillCost": 175,
"packagingTaxPower": 0.83,
"packagingTaxMultiplier": 0.12,
"packagingTaxMultiplier": 0.122,
"percentRecyclingYieldLoss": 20,
"percentReuseExhaustion": 12,
"percentIncinerationPlastic": 12,
Expand Down Expand Up @@ -233,7 +233,7 @@
"incerationCost": 99,
"landfillCost": 74,
"packagingTaxPower": 0.83,
"packagingTaxMultiplier": 0.12,
"packagingTaxMultiplier": 0.222,
"percentRecyclingYieldLoss": 20,
"percentReuseExhaustion": 12,
"percentIncinerationPlastic": 12,
Expand Down
5 changes: 3 additions & 2 deletions service_worker_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ const OLD_CACHES = [
"GlobalPlasticsTool_20240903",
"GlobalPlasticsTool_20240904",
"GlobalPlasticsTool_20240905",
"GlobalPlasticsTool_20240906"
"GlobalPlasticsTool_20240906",
"GlobalPlasticsTool_20240907"
];
const CACHE_NAME = "GlobalPlasticsTool_20240907";
const CACHE_NAME = "GlobalPlasticsTool_20240908";
const ESSENTIAL_FILES = [
"/css/README.md",
"/css/base.css",
Expand Down
2 changes: 1 addition & 1 deletion template/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ <h2>Table of Contents</h2>
<a class="tab-trigger" href="#about-privacy">Privacy</a> / <a class="tab-trigger" href="#about-license">Terms</a> / <a class="tab-trigger" href="/~https://github.com/SchmidtDSE/plastics-prototype">Open Source</a> / <a class="tab-trigger" href="#about-contact">Contact</a> / <a class="tab-trigger" href="#toc">Table of Contents</a> / <a class="tab-trigger" href="#settings">Accessibility</a> / <a class="tab-trigger" href="#about-publication">Cite Us</a>
</footer>

<input type="hidden" id="version-number" value="20240907">
<input type="hidden" id="version-number" value="20240908">

<dialog id="add-dialog">
<form>
Expand Down

0 comments on commit eb77b04

Please sign in to comment.