From 32fb9087bdbaf82c5bc50514fa162efcb9b36621 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 12 Jun 2024 13:38:18 +0200 Subject: [PATCH 1/7] change path --- .../java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index fac5a43..0c96c4c 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -63,7 +63,7 @@ public static void main(String[] args) throws IOException{ // yyyy man könnte (sollte?) den table in den StreetAnalysisDataContainer mit hinein geben, und die Werte gleich dort eintragen. kai, feb'24 List allStreetBaseData = scraper - .extractAllLocalBaseData("./data/street/all2", "A", ".*", "") + .extractAllLocalBaseData("./data/street/all", "A", ".*", "") .stream() .map(streetBaseDataContainer -> new StreetAnalysisDataContainer(streetBaseDataContainer, 0. From 4ecee594805b8119044f61f287eff3a96bbb0504 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 12 Jun 2024 13:57:07 +0200 Subject: [PATCH 2/7] Versuch einer trennenden Grafik --- .../org/tub/vsp/bvwp/users/kmt/FiguresKMT.java | 18 +++++++++++++++++- .../bvwp/users/kmt/RunLocalCsvScrapingKMT.java | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java index 8368171..305b4b3 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java @@ -177,7 +177,6 @@ static Figure createFigureCO2(Axis xAxis, int plotWidth, Table table, String xNa .width( plotWidth ) .build(); - Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) ) .name( yName ) .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() ) @@ -252,4 +251,21 @@ static Figure createFigureNkvChange(int plotWidth, Table table, String xName, St return new Figure( layout, cbrOverCbrTrace, diagonale, horizontalCbr1, verticalCbr1 ); } + + + /** Idee um eine Trennung zu erzeugen... Noch nicht optimal + * @param title + * @return + */ + static Figure createTextFigure(String title){ + + Layout layout = Layout.builder( title ) + .yAxis(Axis.builder().visible(false).build()) + .xAxis(Axis.builder().visible(false).build()) + .width( 1) + .height(1) + .build(); + + return new Figure(layout); + } } diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 0c96c4c..5b233b6 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -117,6 +117,7 @@ public static void main(String[] args) throws IOException{ String pageKMT = MultiPlotUtils.pageTop() + System.lineSeparator() + figureNkv.asJavascript("plot1") + System.lineSeparator() + +// FiguresKMT.createTextFigure("Neuer Abschnitt").asJavascript("plot2") + System.lineSeparator() + //Test um mal eine Trennung zu erzeugen... vlt doch anders machen figureCostByPriority.asJavascript("plot2") + System.lineSeparator() + figureNkvByPriority.asJavascript("plot3")+System.lineSeparator() + figureCO2Benefit.asJavascript("plot4") + System.lineSeparator() + From b954f329e3743cf388c394efa8f8838b16519e0b Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 12 Jun 2024 15:14:00 +0200 Subject: [PATCH 3/7] some refactoring --- .../tub/vsp/bvwp/users/kmt/FiguresKMT.java | 2 +- .../users/kmt/RunLocalCsvScrapingKMT.java | 232 ++++++++++-------- 2 files changed, 136 insertions(+), 98 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java index 305b4b3..5c545eb 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java @@ -213,7 +213,7 @@ static Figure createFigureNkvChange(int plotWidth, Table table, String xName, St .title( yName ) .build(); - Layout layout = Layout.builder( xName ) + Layout layout = Layout.builder( yName + " over " +xName ) .xAxis( xAxis ) .yAxis( yAxis ) .width( plotWidth ) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 5b233b6..1f3b693 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -104,114 +104,152 @@ public static void main(String[] args) throws IOException{ Axis xAxis = xAxisBuilder.title(xNameKMT).build(); final int plotWidth = 1400; - Figure figureNkv = FiguresKMT.createFigureNkv(xAxis, plotWidth, table, xNameKMT); - Figure figureCostByPriority = FiguresKMT.createFigureCostByPriority(plotWidth, table, Headers.INVCOST_ORIG ); - Figure figureNkvByPriority = FiguresKMT.createFigureNkvByPriority(xAxis, plotWidth, table, Headers.INVCOST_ORIG ); - Figure figureCO2Benefit = FiguresKMT.createFigureCO2(xAxis, plotWidth, table, xNameKMT); - Figure figureNkvChangeCo2_680 = FiguresKMT.createFigureNkvChange(plotWidth, table, - Headers.NKV_ORIG, Headers.NKV_CO2_700_EN ); - Figure figureNkvChangeInduz_2000 = FiguresKMT.createFigureNkvChange(plotWidth, table, - Headers.NKV_ORIG, Headers.NKV_CO2_2000_EN ); + kmtPlots_old(xAxis, plotWidth, table, xNameKMT); + } + + calculationsAndTableWriting(table); + } + + private static void calculationsAndTableWriting(Table table) { + // === Some calculations + + Comparator comparator = (o1, o2) -> { + Einstufung p1 = Einstufung.valueOf(o1.getString(Headers.EINSTUFUNG ) ); + Einstufung p2 = Einstufung.valueOf(o2.getString(Headers.EINSTUFUNG ) ); + return p1.compareTo(p2); + }; + table = table.sortOn(comparator); + NumberFormat format = NumberFormat.getCompactNumberInstance(); + format.setMaximumFractionDigits(0); + table.numberColumn(Headers.CO2_COST_EL03 ).setPrintFormatter(format, "n/a" ); + + //Projekte, die bereits vor Änderung NKV <1 haben + Table tableBaseKl1 = table.where(table.numberColumn(Headers.NKV_ORIG ).isLessThan(1. ) ); + Table tableCo2_680_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_700_EN ).isLessThan(1. ) ); + Table tableCo2_2000_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_2000_EN).isLessThan(1.)); + Table tableIndCo2kl1 = table.where( + table.numberColumn(Headers.NKV_EL03_CARBON215_INVCOSTTUD ).isLessThan(1. ) ); + + { //-- von KN + System.out.println(BvwpUtils.SEPARATOR); + System.out.println(table.summarize(Headers.NKV_ORIG, count, mean, stdDev, min, max ) + .by(Headers.EINSTUFUNG ) ); + System.out.println(System.lineSeparator() + "Davon NKV < 1:"); + System.out.println( + tableIndCo2kl1.summarize(Headers.NKV_EL03_CARBON215_INVCOSTTUD, count, mean, stdDev, min, max ) + .by(Headers.EINSTUFUNG ) ); + + System.out.println(BvwpUtils.SEPARATOR); + System.out.println( + table.summarize(Headers.INVCOST_ORIG, sum, mean, stdDev, min, max ) + .by(Headers.EINSTUFUNG ) ); + System.out.println(System.lineSeparator() + "Davon NKV < 1:"); + System.out.println( + tableIndCo2kl1.summarize(Headers.INVCOST_ORIG, sum, mean, stdDev, min, max ) + .by(Headers.EINSTUFUNG ) ); + + System.out.println(BvwpUtils.SEPARATOR); + System.out.println( + table.summarize( + Headers.CO2_COST_EL03, sum, mean, stdDev, min, max ).by(Headers.EINSTUFUNG ) ); + System.out.println(System.lineSeparator() + "Davon NKV < 1:"); + System.out.println( + tableIndCo2kl1.summarize(Headers.CO2_COST_EL03, sum, mean, stdDev, min, max ) + .by(Headers.EINSTUFUNG ) ); + } + + { + //KMT + System.out.println(BvwpUtils.SEPARATOR); + System.out.println("### KMT ###"); + System.out.println(BvwpUtils.SEPARATOR); + System.out.println("All projects"); + System.out.println(table.summarize(Headers.NKV_ORIG, count ).apply() ); + + System.out.println(BvwpUtils.SEPARATOR); + System.out.println(BvwpUtils.SEPARATOR); + Table kmtTable = Table.create("Projects with BCR < 1"); + kmtTable.addColumns(DoubleColumn.create("#Projects" + , new double[]{table.rowCount() + } + )); + kmtTable.addColumns(DoubleColumn.create("Base" + , new double[]{tableBaseKl1.rowCount()} + )); + kmtTable.addColumns(DoubleColumn.create("CO2_680" + , new double[]{tableCo2_680_Kl1.rowCount()} + )); + kmtTable.addColumns(DoubleColumn.create("Co2_2000" + , new double[]{tableCo2_2000_Kl1.rowCount()} + )); +// kmtTable.addColumns(DoubleColumn.create("CO2_Induced" +// , new double[]{tableIndCo2kl1.rowCount()} +// )); + System.out.println(kmtTable.print()); + } + } + + private static void kmtPlots_old(Axis xAxis, int plotWidth, Table table, String xNameKMT) + throws IOException { + Figure figureNkv = FiguresKMT.createFigureNkv(xAxis, plotWidth, table, xNameKMT); + Figure figureCostByPriority = FiguresKMT.createFigureCostByPriority(plotWidth, table, Headers.INVCOST_ORIG ); + Figure figureNkvByPriority = FiguresKMT.createFigureNkvByPriority(xAxis, plotWidth, table, Headers.INVCOST_ORIG ); + Figure figureCO2Benefit = FiguresKMT.createFigureCO2(xAxis, plotWidth, table, xNameKMT); + Figure figureNkvChangeCo2_680 = FiguresKMT.createFigureNkvChange(plotWidth, table, + Headers.NKV_ORIG, Headers.NKV_CO2_700_EN ); + Figure figureNkvChangeInduz_2000 = FiguresKMT.createFigureNkvChange(plotWidth, table, + Headers.NKV_ORIG, Headers.NKV_CO2_2000_EN ); // Figure figureNkvChangeInduzCo2 = Figures.createFigureNkvChange(plotWidth, table, // Headers.NKV_NO_CHANGE, Headers.NKV_INDUZ_CO2); - String pageKMT = MultiPlotUtils.pageTop() + System.lineSeparator() + - figureNkv.asJavascript("plot1") + System.lineSeparator() + + String pageKMT = MultiPlotUtils.pageTop() + System.lineSeparator() + + figureNkv.asJavascript("plot1") + System.lineSeparator() + // FiguresKMT.createTextFigure("Neuer Abschnitt").asJavascript("plot2") + System.lineSeparator() + //Test um mal eine Trennung zu erzeugen... vlt doch anders machen - figureCostByPriority.asJavascript("plot2") + System.lineSeparator() + - figureNkvByPriority.asJavascript("plot3")+System.lineSeparator() + - figureCO2Benefit.asJavascript("plot4") + System.lineSeparator() + - figureNkvChangeCo2_680.asJavascript("plot5") + System.lineSeparator() + - figureNkvChangeInduz_2000.asJavascript("plot6") + System.lineSeparator() + + figureCostByPriority.asJavascript("plot2") + System.lineSeparator() + + figureNkvByPriority.asJavascript("plot3")+System.lineSeparator() + + figureCO2Benefit.asJavascript("plot4") + System.lineSeparator() + + figureNkvChangeCo2_680.asJavascript("plot5") + System.lineSeparator() + + figureNkvChangeInduz_2000.asJavascript("plot6") + System.lineSeparator() + // figureNkvChangeInduzCo2.asJavascript("plot7") + System.lineSeparator() + - MultiPlotUtils.pageBottom; + MultiPlotUtils.pageBottom; - File outputFileKMT = Paths.get("multiplotKMT.html").toFile(); + File outputFileKMT = Paths.get("multiplotKMT.html").toFile(); - try (FileWriter fileWriter = new FileWriter(outputFileKMT)) { - fileWriter.write(pageKMT); - } + try (FileWriter fileWriter = new FileWriter(outputFileKMT)) { + fileWriter.write(pageKMT); + } - new Browser().browse(outputFileKMT); - } + new Browser().browse(outputFileKMT); + } + private static void kmtPlots_Co2values(Axis xAxis, int plotWidth, Table table, String xNameKMT) + throws IOException { + Figure figureNkv = FiguresKMT.createFigureNkv(xAxis, plotWidth, table, xNameKMT); + Figure figureCostByPriority = FiguresKMT.createFigureCostByPriority(plotWidth, table, Headers.INVCOST_ORIG ); + Figure figureNkvByPriority = FiguresKMT.createFigureNkvByPriority(xAxis, plotWidth, table, Headers.INVCOST_ORIG ); + Figure figureCO2Benefit = FiguresKMT.createFigureCO2(xAxis, plotWidth, table, xNameKMT); + Figure figureNkvChangeCo2_680 = FiguresKMT.createFigureNkvChange(plotWidth, table, Headers.NKV_ORIG, Headers.NKV_CO2_700_EN ); + Figure figureNkvChangeInduz_2000 = FiguresKMT.createFigureNkvChange(plotWidth, table, Headers.NKV_ORIG, Headers.NKV_CO2_2000_EN ); - // === Some calculations - - Comparator comparator = (o1, o2) -> { - Einstufung p1 = Einstufung.valueOf(o1.getString(Headers.EINSTUFUNG ) ); - Einstufung p2 = Einstufung.valueOf(o2.getString(Headers.EINSTUFUNG ) ); - return p1.compareTo(p2); - }; - table = table.sortOn(comparator); - NumberFormat format = NumberFormat.getCompactNumberInstance(); - format.setMaximumFractionDigits(0); - table.numberColumn(Headers.CO2_COST_EL03 ).setPrintFormatter(format, "n/a" ); - - //Projekte, die bereits vor Änderung NKV <1 haben - Table tableBaseKl1 = table.where(table.numberColumn(Headers.NKV_ORIG ).isLessThan(1. ) ); - Table tableCo2_680_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_700_EN ).isLessThan(1. ) ); - Table tableCo2_2000_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_2000_EN).isLessThan(1.)); - Table tableIndCo2kl1 = table.where( - table.numberColumn(Headers.NKV_EL03_CARBON215_INVCOSTTUD ).isLessThan(1. ) ); - - { //-- von KN - System.out.println(BvwpUtils.SEPARATOR); - System.out.println(table.summarize(Headers.NKV_ORIG, count, mean, stdDev, min, max ) - .by(Headers.EINSTUFUNG ) ); - System.out.println(System.lineSeparator() + "Davon NKV < 1:"); - System.out.println( - tableIndCo2kl1.summarize(Headers.NKV_EL03_CARBON215_INVCOSTTUD, count, mean, stdDev, min, max ) - .by(Headers.EINSTUFUNG ) ); - - System.out.println(BvwpUtils.SEPARATOR); - System.out.println( - table.summarize(Headers.INVCOST_ORIG, sum, mean, stdDev, min, max ) - .by(Headers.EINSTUFUNG ) ); - System.out.println(System.lineSeparator() + "Davon NKV < 1:"); - System.out.println( - tableIndCo2kl1.summarize(Headers.INVCOST_ORIG, sum, mean, stdDev, min, max ) - .by(Headers.EINSTUFUNG ) ); - - System.out.println(BvwpUtils.SEPARATOR); - System.out.println( - table.summarize( - Headers.CO2_COST_EL03, sum, mean, stdDev, min, max ).by(Headers.EINSTUFUNG ) ); - System.out.println(System.lineSeparator() + "Davon NKV < 1:"); - System.out.println( - tableIndCo2kl1.summarize(Headers.CO2_COST_EL03, sum, mean, stdDev, min, max ) - .by(Headers.EINSTUFUNG ) ); - } - { - //KMT - System.out.println(BvwpUtils.SEPARATOR); - System.out.println("### KMT ###"); - System.out.println(BvwpUtils.SEPARATOR); - System.out.println("All projects"); - System.out.println(table.summarize(Headers.NKV_ORIG, count ).apply() ); - - System.out.println(BvwpUtils.SEPARATOR); - System.out.println(BvwpUtils.SEPARATOR); - Table kmtTable = Table.create("Projects with BCR < 1"); - kmtTable.addColumns(DoubleColumn.create("#Projects" - , new double[]{table.rowCount() - } - )); - kmtTable.addColumns(DoubleColumn.create("Base" - , new double[]{tableBaseKl1.rowCount()} - )); - kmtTable.addColumns(DoubleColumn.create("CO2_680" - , new double[]{tableCo2_680_Kl1.rowCount()} - )); - kmtTable.addColumns(DoubleColumn.create("Co2_2000" - , new double[]{tableCo2_2000_Kl1.rowCount()} - )); -// kmtTable.addColumns(DoubleColumn.create("CO2_Induced" -// , new double[]{tableIndCo2kl1.rowCount()} -// )); - System.out.println(kmtTable.print()); - } + String page = MultiPlotUtils.pageTop() + System.lineSeparator() + + figureNkv.asJavascript("plot1") + System.lineSeparator() + +// FiguresKMT.createTextFigure("Neuer Abschnitt").asJavascript("plot2") + System.lineSeparator() + //Test um mal eine Trennung zu erzeugen... vlt doch anders machen + figureCostByPriority.asJavascript("plot2") + System.lineSeparator() + + figureNkvByPriority.asJavascript("plot3")+System.lineSeparator() + + figureCO2Benefit.asJavascript("plot4") + System.lineSeparator() + + figureNkvChangeCo2_680.asJavascript("plot5") + System.lineSeparator() + + figureNkvChangeInduz_2000.asJavascript("plot6") + System.lineSeparator() + +// figureNkvChangeInduzCo2.asJavascript("plot7") + System.lineSeparator() + + MultiPlotUtils.pageBottom; + + File outputFile = Paths.get("EWGT_CO2-Values.html").toFile(); + + try (FileWriter fileWriter = new FileWriter(outputFile)) { + fileWriter.write(page); } + new Browser().browse(outputFile); + } + } From f7f4f70a45e22bd9460915d9756f5d8253b78f5f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 12 Jun 2024 15:17:05 +0200 Subject: [PATCH 4/7] cleanup --- .../bvwp/users/kmt/RunLocalCsvScrapingKMT.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 1f3b693..88b69eb 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -75,31 +75,19 @@ public static void main(String[] args) throws IOException{ StreetCsvWriter csvWriter = new StreetCsvWriter("output/street_data.csv"); Table table = csvWriter.writeCsv(allStreetBaseData); -// table = table.where( table.numberColumn( Headers.NKV_INDUZ_CO2 ).isLessThan( 2.) ); table.addColumns(table.numberColumn(Headers.NKV_ORIG ) .subtract(table.numberColumn(Headers.NKV_EL03_CARBON215_INVCOSTTUD ) ).setName( Headers.NKV_EL03_DIFF ) ); -// final Table newTable = table.selectColumns( "nkvDiff", Headers.COST_OVERALL ); -// LinearModel winsModel = OLS.fit( Formula.lhs("nkvDiff" ), newTable.smile().toDataFrame() ); -// System.out.println( winsModel ); -// System.exit(-1); - // === - - { //KMT + { //Plotting and table preparation String xNameKMT; Axis.AxisBuilder xAxisBuilder = Axis.builder(); { xNameKMT = Headers.CO2_COST_EL03; xAxisBuilder.type(Type.LINEAR); } -// { -// xNameKMT = Headers.NKV_INDUZ_CO2; -// xAxisBuilder -// // .type( Axis.Type.LOG ) -// .autoRange( Axis.AutoRange.REVERSED ); -// } + table = table.sortDescendingOn(xNameKMT); Axis xAxis = xAxisBuilder.title(xNameKMT).build(); final int plotWidth = 1400; From 3bf1db0b8c35a16b4d2922115a522894e70bda97 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Thu, 13 Jun 2024 10:10:35 +0200 Subject: [PATCH 5/7] =?UTF-8?q?bei=20normaler=20CO2=20Preis=20Berechnung?= =?UTF-8?q?=20sollte=20NICHT=20auch=20noch=20die=20Diskontierungsproblemat?= =?UTF-8?q?ik=20mit=20ber=C3=BCcksichtigt=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/container/analysis/StreetAnalysisDataContainer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java index 71b2737..072f6a7 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java @@ -79,8 +79,8 @@ private void addComputations() { entries.put(Headers.NKV_ORIG, NkvCalculator.calculateNkv( NO_CHANGE, streetBaseData ) ); entries.put(Headers.NKV_CO2, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1.75 ), streetBaseData ) ); - entries.put(Headers.NKV_CO2_700_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1.75 ), streetBaseData ) ); - entries.put(Headers.NKV_CARBON700, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1.75 ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_700_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1. ), streetBaseData ) ); +// entries.put(Headers.NKV_CARBON700, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1. ), streetBaseData ) ); entries.put(Headers.NKV_CO2_2000_EN, NkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2020to2012, 0, 1, 1. ), streetBaseData ) ); entries.put(Headers.NKV_EL03, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ), streetBaseData ) ); entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1. ), streetBaseData ) ); From 3f2a9afb603dd6aafb0a613b080ac1b1f5645ae8 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Thu, 13 Jun 2024 10:35:32 +0200 Subject: [PATCH 6/7] add columns for EWGT Paper (Co2costs x investCost modifications). Some refactoring --- .../vsp/bvwp/computation/Modifications.java | 6 ++++++ .../java/org/tub/vsp/bvwp/data/Headers.java | 19 +++++++++++++++-- .../analysis/RailAnalysisDataContainer.java | 4 ++-- .../analysis/StreetAnalysisDataContainer.java | 21 ++++++++++++++++--- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java b/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java index 7fae078..d894d38 100644 --- a/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java +++ b/src/main/java/org/tub/vsp/bvwp/computation/Modifications.java @@ -4,17 +4,23 @@ import org.apache.logging.log4j.Logger; public record Modifications(double co2Price, double mehrFzkm, double constructionCostFactor, double nonCo2BenefitsFactor) { + + //TODO nonCo2BenefitsFactor is not used in the codebase private static final Logger log = LogManager.getLogger(Modifications.class); + public static final double INFLATION_Factor2020to2012 = 0.917; // Zinse Wert von 2020 auf BVWP Zeitpunkt 2012 ab. public static final double co2PriceBVWP = 145.; public static final double co2Price700 = 642.; // (700 sind die Klimakosten von in 2030 erzeugten CO2-Emissionen, zum Preisstand 2020. Rückgerechnet nach 2012 führt das zu 642.) + public static final double co2Price2000 = 2000 * INFLATION_Factor2020to2012; + // (2000 als Annahme für die Klimakosten von in 2030 erzeugten CO2-Emissionen, zum Preisstand 2020. Rückgerechnet nach 2012) /** * Wie {@link #co2Price700}, aber mit 1% Zeitpräferenzrate. */ public static final double co2Price215 = 197.; + // public static final double co2Price680 = 623.; // (haben wir früher mal verwendet) // € 623 (in 2012) corresponds to € 680 in 2020 including the inflation. diff --git a/src/main/java/org/tub/vsp/bvwp/data/Headers.java b/src/main/java/org/tub/vsp/bvwp/data/Headers.java index bc7a819..24d88a9 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/Headers.java +++ b/src/main/java/org/tub/vsp/bvwp/data/Headers.java @@ -92,8 +92,23 @@ public final class Headers{ * NKV bei erhöhtem CO2-Preis (welchem?). */ public static final String NKV_CO2 = "NKV_co2"; - public static final String NKV_CO2_2000_EN = "BCR_co2_2000"; - public static final String NKV_CO2_700_EN = "BCR_co2_700"; + public static final String NKV_CO2_2000_EN = "BCR_co2_2000"; //2000 Euro/t -> muss dann noch nach 2012 umgerechnet werden + public static final String NKV_CO2_700_EN = "BCR_co2_700"; //700 Euro/t lt UBA für 2030 (Preisstand 2020) -> muss dann noch nach 2012 umgerechnet werden + /** + * NKV bei erhöhten Investitionskosten (welchen?). + */ + public static final String NKV_INVCOSTTUD_EN = "BCR_invcostTud"; // Projektspezifische erhöhte Investitionskosten (siehe TUD-Liste) + public static final String NKV_INVCOST150_EN = "BCR_invcost150"; //50% höhere Investmentcosts + public static final String NKV_INVCOST200_EN = "BCR_invcost200"; //doppelte Investmentcosts + /** + * NKV bei erhöhten Investitionskosten (welchen?) in Kombination mit erhöhtem CO2-Preis. + */ + public static final String NKV_CO2_2000_INVCOSTTUD_EN = "BCR_co2_2000_invcostTud"; // Projektspezifische erhöhte Investitionskosten (siehe TUD-Liste) + public static final String NKV_CO2_2000_INVCOST150_EN = "BCR_co2_2000_invcost150"; //50% höhere Investmentcosts + public static final String NKV_CO2_2000_INVCOST200_EN = "BCR_co2_2000_invcost200"; //doppelte Investmentcosts + public static final String NKV_CO2_700_INVCOSTTUD_EN = "BCR_co2_700_invcostTud"; // Projektspezifische erhöhte Investitionskosten (siehe TUD-Liste) + public static final String NKV_CO2_700_INVCOST150_EN = "BCR_co2_700_invcost150"; //50% höhere Investmentcosts + public static final String NKV_CO2_700_INVCOST200_EN = "BCR_co2_700_invcost200"; //doppelte Investmentcosts /** * {@link #NKV_EL03_CARBON215_INVCOSTTUD} - {@link #NKV_ORIG} */ diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java index 8e41c98..ace4965 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java @@ -14,8 +14,8 @@ import java.util.SequencedMap; import static org.tub.vsp.bvwp.computation.Modifications.NO_CHANGE; +import static org.tub.vsp.bvwp.computation.Modifications.co2Price2000; import static org.tub.vsp.bvwp.computation.Modifications.co2Price700; -import static org.tub.vsp.bvwp.data.container.analysis.StreetAnalysisDataContainer.INFLATION_Factor2020to2012; public class RailAnalysisDataContainer { @@ -61,7 +61,7 @@ private void addComputations() { entries.put(Headers.NKV_CO2, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer)); entries.put(Headers.NKV_CO2_700_EN, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer)); entries.put(Headers.NKV_CARBON700, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1.), baseDataContainer)); - entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( 2000 * INFLATION_Factor2020to2012, 0, 1, 1 ), baseDataContainer ) ); + entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( co2Price2000, 0, 1, 1 ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03, NkvCalculatorRail.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, NkvCalculatorRail.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1. ), baseDataContainer ) ); // entries.put(Headers.NKV_EL03_CARBON700tpr0_INVCOSTTUD, NkvCalculatorRail.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1.75 ), baseDataContainer ) ); diff --git a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java index 072f6a7..aa70899 100644 --- a/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java +++ b/src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java @@ -22,7 +22,6 @@ public class StreetAnalysisDataContainer { private final SequencedMap entries = new LinkedHashMap<>(); private final List remarks = new ArrayList<>(); private final double constructionCostTud; - static final double INFLATION_Factor2020to2012 = 0.917; // Zinse Wert von 2020 auf BVWP Zeitpunkt 2012 ab. public StreetAnalysisDataContainer(StreetBaseDataContainer streetBaseDataContainer, double investmentCostNew ) { this.streetBaseData = streetBaseDataContainer; @@ -81,13 +80,28 @@ private void addComputations() { entries.put(Headers.NKV_CO2, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1.75 ), streetBaseData ) ); entries.put(Headers.NKV_CO2_700_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1. ), streetBaseData ) ); // entries.put(Headers.NKV_CARBON700, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1. ), streetBaseData ) ); - entries.put(Headers.NKV_CO2_2000_EN, NkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2020to2012, 0, 1, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_2000_EN, NkvCalculator.calculateNkv( new Modifications( + co2Price2000, 0, 1, 1. ), streetBaseData ) ); entries.put(Headers.NKV_EL03, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ), streetBaseData ) ); entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1. ), streetBaseData ) ); entries.put(Headers.NKV_EL03_CARBON700tpr0_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor, 1.75 ), streetBaseData ) ); entries.put(Headers.NKV_EL03_CARBON700tpr0, NkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, 1., 1.75 ), streetBaseData ) ); // entries.put(Headers.NKV_EL03_CO2_INVCOST50, NkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), streetBaseData ) ); + //Für EWGT Paper KMT + //Nur Investitionskosten ändern sich + entries.put(Headers.NKV_INVCOSTTUD_EN, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0, constructionCostFactor, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0, 1.5, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0, 2, 1. ), streetBaseData ) ); + + //Investitionskosten und CO2 Preis ändern sich + entries.put(Headers.NKV_CO2_700_INVCOSTTUD_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, constructionCostFactor, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_700_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, 1.5, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_700_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, 2, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_2000_INVCOSTTUD_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, constructionCostFactor, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_2000_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, 1.5, 1. ), streetBaseData ) ); + entries.put(Headers.NKV_CO2_2000_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, 2, 1. ), streetBaseData ) ); + entries.put(Headers.ADDTL_PKWKM_EL03, addtlFzkmFromElasticity03 ); entries.put(Headers.CO2_COST_ORIG, Math.max( 1., NkvCalculator.calculateCost_CO2( NO_CHANGE, streetBaseData ) ) ); entries.put(Headers.CO2_COST_EL03, Math.max( 1., NkvCalculator.calculateCost_CO2( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1. ), streetBaseData ) ) ); @@ -101,7 +115,8 @@ private void addComputations() { entries.put( Headers.NKV_ELTTIME_CARBON215_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmFromTtime, constructionCostFactor, 1. ), streetBaseData ) ); entries.put( Headers.NKV_ELTTIME_CARBON700TPR0_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( co2Price700, addtlFzkmFromTtime, constructionCostFactor, 1.75 ), streetBaseData ) ); - entries.put( Headers.NKV_ELTTIME_CARBON2000_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2020to2012, addtlFzkmFromTtime, constructionCostFactor, 1.75 ), streetBaseData ) ); + entries.put( Headers.NKV_ELTTIME_CARBON2000_INVCOSTTUD, NkvCalculator.calculateNkv( new Modifications( + co2Price2000, addtlFzkmFromTtime, constructionCostFactor, 1.75 ), streetBaseData ) ); if ( streetBaseData.getProjectInformation().getProjectNumber().contains("A1-G50-NI" )) { this.remarks.add("Eher geringer Benefit pro km ... erzeugt dann ueber die El pro km relativ viel Verkehr " + From 93274e00161869462117bb762446770a2f75ca6c Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Thu, 13 Jun 2024 15:37:25 +0200 Subject: [PATCH 7/7] use TUD cost settings in calculations --- .../org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java index 88b69eb..d0c57be 100644 --- a/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java +++ b/src/main/java/org/tub/vsp/bvwp/users/kmt/RunLocalCsvScrapingKMT.java @@ -66,8 +66,8 @@ public static void main(String[] args) throws IOException{ .extractAllLocalBaseData("./data/street/all", "A", ".*", "") .stream() .map(streetBaseDataContainer -> new StreetAnalysisDataContainer(streetBaseDataContainer, - 0. -// constructionCostsByProject.get(streetBaseDataContainer.getProjectInformation().getProjectNumber()) +// 0. + constructionCostsByProject.get(streetBaseDataContainer.getProjectInformation().getProjectNumber()) )) .toList();