Skip to content

Commit

Permalink
Merge branch 'main' into kaibranch. Manually resolve conflicts:
Browse files Browse the repository at this point in the history
	src/main/java/org/tub/vsp/bvwp/computation/Modifications.java
	src/main/java/org/tub/vsp/bvwp/data/container/analysis/RailAnalysisDataContainer.java
	src/main/java/org/tub/vsp/bvwp/data/container/analysis/StreetAnalysisDataContainer.java
  • Loading branch information
kainagel committed Jul 15, 2024
2 parents fd99dc2 + 2dd9538 commit db4b96e
Show file tree
Hide file tree
Showing 25 changed files with 1,386 additions and 530 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/tub/vsp/bvwp/JSoupUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public static Double parseDoubleOrElseNull(String s) {
}
}

public static Double parseDoubleOrElseThrow(String s) {
try {
return parseDouble(s);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}

public static Optional<Element> getTableByKeyAndContainedText(Document document, String cssClass,
String textToContain) {
return getTableByCssKeyAndPredicate(document, cssClass, (e) -> anyRowContainsText(e, textToContain));
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import org.tub.vsp.bvwp.scraping.StreetScraper;

import java.util.List;
import java.util.Map;

public class RunCsvWriting {
public static void main(String[] args) {
String filePath = "../../shared-svn/";
Map<String, Double> constructionCostsByProject = BvwpUtils.getConstructionCostsFromTudFile(filePath );
// Map<String, Double> constructionCostsByProject = BvwpUtils.getConstructionCostsFromTudFile(filePath );

List<StreetAnalysisDataContainer> allStreetBaseData =
new StreetScraper().extractAllLocalBaseData("./data/street/all", "A", ".*", "")
.stream()
.map(s -> new StreetAnalysisDataContainer(s,
constructionCostsByProject.get(s.getProjectInformation().getProjectNumber())))
.map(s -> new StreetAnalysisDataContainer(s, 0))
.toList();

StreetCsvWriter csvWriter = new StreetCsvWriter("output/street_data.csv");
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/tub/vsp/bvwp/computation/Modifications.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
public record Modifications(double co2Price, double mehrFzkm, double constructionCostFactor, double discountCorrFact, double emobCorrFact) {

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.*642/700;
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.
Expand All @@ -31,6 +34,6 @@ public record Modifications(double co2Price, double mehrFzkm, double constructio
public static final Modifications NO_CHANGE = new Modifications(co2PriceBVWP, 0., 1, 1, 1. );

@Override public String toString() {
return "[co2Price=" + co2Price + "; mehrFzkm=" + mehrFzkm + "]";
return "[co2Price=" + co2Price + "; mehrFzkm=" + mehrFzkm + "; constructionCostFactor" + constructionCostFactor + "; discountCorrFact" + discountCorrFact + "; emobCorrFact=" + emobCorrFact + "]";
}
}
23 changes: 21 additions & 2 deletions src/main/java/org/tub/vsp/bvwp/data/Headers.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,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_680";
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}
*/
Expand Down Expand Up @@ -143,6 +158,10 @@ public final class Headers{
public static final String NKV_ELTTIME_CARBON2000_INVCOSTTUD = "NKV_elTtime_carbon2000_invcostTud";
public static final String CO2_ELTTIME = "CO2[Mt] bei Straßenmehrverkehr+";

public static final String DAUER_PLANUNG = "Planungsdauer_jahre";
public static final String DAUER_BAU = "Baudauer_jahre";
public static final String DAUER_BETRIEB = "Betriebsdauer_jahre";

public static String capped5Of( String str ) {
int cap=5;
return cappedOf( cap, str );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import java.util.List;
import java.util.SequencedMap;

import static org.tub.vsp.bvwp.computation.Modifications.NO_CHANGE;
import static org.tub.vsp.bvwp.computation.Modifications.co2Price700;
import static org.tub.vsp.bvwp.data.container.analysis.StreetAnalysisDataContainer.INFLATION_Factor2022to2012;
import static org.tub.vsp.bvwp.computation.Modifications.*;


public class RailAnalysisDataContainer {
Expand Down Expand Up @@ -58,10 +56,11 @@ private void addComputations() {
entries.put(Headers.B_PER_KM, baseDataContainer.getCostBenefitAnalysis().getOverallBenefit().overall() / baseDataContainer.getProjectInformation().getLength() );

entries.put(Headers.NKV_ORIG, NkvCalculatorRail.calculateNkv( NO_CHANGE, baseDataContainer ) );

entries.put(Headers.NKV_CO2, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) );
entries.put(Headers.NKV_CO2_700_EN, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) );
entries.put(Headers.NKV_CARBON700ptpr0, NkvCalculatorRail.calculateNkv(new Modifications(co2Price700, 0., 1, 1, 1. ), baseDataContainer ) );
entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1, 1. ), baseDataContainer ) );
entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( co2Price2000, 0, 1, 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 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class StreetAnalysisDataContainer {
private final SequencedMap<String, Double> entries = new LinkedHashMap<>();
private final List<String> remarks = new ArrayList<>();
private final double constructionCostTud;
static final double INFLATION_Factor2022to2012 = 0.917; // Zinse Wert von 2020 auf BVWP Zeitpunkt 2012 ab.

public StreetAnalysisDataContainer(StreetBaseDataContainer streetBaseDataContainer, double investmentCostNew ) {
this.streetBaseData = streetBaseDataContainer;
Expand Down Expand Up @@ -93,12 +92,30 @@ private void addComputations() {
entries.put(Headers.NKV_ORIG, nkvCalculator.calculateNkv( NO_CHANGE ) );
entries.put(Headers.NKV_CO2, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1, 1. ) ) );
entries.put(Headers.NKV_CO2_700_EN, nkvCalculator.calculateNkv( new Modifications( co2Price700, 0., 1, 1, 1. ) ) );
entries.put(Headers.NKV_CO2_2000_EN, nkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1, 1, 1. ) ) );
entries.put(Headers.NKV_CO2_2000_EN, nkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, 1, 1, 1. ) ) );
entries.put(Headers.NKV_EL03, nkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1, 1, 1. ) ) );
// entries.put(Headers.NKV_EL03_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, constructionCostFactor ) ) );
// entries.put(Headers.NKV_EL03_CARBON700ptpr0_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( discountCorr*co2Price700, addtlFzkmBeyondPrinsEl03, constructionCostFactor ) ) );
// entries.put(Headers.NKV_EL03_CARBON700ptpr0, nkvCalculator.calculateNkv( new Modifications( discountCorr*co2Price700, addtlFzkmBeyondPrinsEl03, 1. ) ) );
// 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., 1. ), streetBaseData ) );
entries.put(Headers.NKV_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0, 1.5, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, 0, 2, 1. , 1.), streetBaseData ) );

//Investitionskosten und CO2 Preis ändern sich
entries.put(Headers.NKV_CO2_700_INVCOSTTUD_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, constructionCostFactor, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_CO2_700_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, 1.5, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_CO2_700_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2Price700, 0, 2, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_CO2_2000_INVCOSTTUD_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, constructionCostFactor, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_CO2_2000_INVCOST150_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, 1.5, 1. , 1.), streetBaseData ) );
entries.put(Headers.NKV_CO2_2000_INVCOST200_EN, NkvCalculator.calculateNkv( new Modifications( co2Price2000, 0, 2, 1. , 1.), streetBaseData ) );

//
entries.put(Headers.ADDTL_PKWKM_EL03, addtlFzkmFromElasticity03 );
// entries.put(Headers.CO2_COST_ORIG, Math.max( 1., nkvCalculator.calculateCost_CO2( NO_CHANGE, streetBaseData ) ) );
Expand Down Expand Up @@ -130,7 +147,8 @@ private void addComputations() {
entries.put(Headers.CO2_ELTTIME, nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmFromTtime, 1, 1, 1. ) ) );

entries.put( Headers.NKV_ELTTIME_CARBON2000_INVCOSTTUD, nkvCalculator.calculateNkv(
new Modifications( 2000 * INFLATION_Factor2022to2012, addtlFzkmFromTtime, constructionCostFactor, 1, 1. ) ) );
new Modifications(
co2Price2000, addtlFzkmFromTtime, constructionCostFactor, 1, 1. ) ) );

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 " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class StreetBaseDataContainer {
private StreetProjectInformationDataContainer projectInformation;
private StreetPhysicalEffectDataContainer physicalEffect;
private StreetCostBenefitAnalysisDataContainer costBenefitAnalysis;
private StreetEnvironmentalDataContainer environmentalCriteria;

public String getUrl() {
return url;
Expand Down Expand Up @@ -45,6 +46,15 @@ public StreetBaseDataContainer setCostBenefitAnalysis(StreetCostBenefitAnalysisD
return this;
}

public StreetEnvironmentalDataContainer getEnvironmentalCriteria() {
return environmentalCriteria;
}

public StreetBaseDataContainer setEnvironmentalCriteria(StreetEnvironmentalDataContainer environmentalCriteria) {
this.environmentalCriteria = environmentalCriteria;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -55,25 +65,18 @@ public boolean equals(Object o) {
}

StreetBaseDataContainer that = (StreetBaseDataContainer) o;

if (!Objects.equals(url, that.url)) {
return false;
}
if (!Objects.equals(projectInformation, that.projectInformation)) {
return false;
}
if (!Objects.equals(physicalEffect, that.physicalEffect)) {
return false;
}
return Objects.equals(costBenefitAnalysis, that.costBenefitAnalysis);
return Objects.equals(url, that.url) && Objects.equals(projectInformation, that.projectInformation) && Objects.equals(physicalEffect,
that.physicalEffect) && Objects.equals(costBenefitAnalysis, that.costBenefitAnalysis) && Objects.equals(environmentalCriteria,
that.environmentalCriteria);
}

@Override
public int hashCode() {
int result = url != null ? url.hashCode() : 0;
result = 31 * result + (projectInformation != null ? projectInformation.hashCode() : 0);
result = 31 * result + (physicalEffect != null ? physicalEffect.hashCode() : 0);
result = 31 * result + (costBenefitAnalysis != null ? costBenefitAnalysis.hashCode() : 0);
int result = Objects.hashCode(url);
result = 31 * result + Objects.hashCode(projectInformation);
result = 31 * result + Objects.hashCode(physicalEffect);
result = 31 * result + Objects.hashCode(costBenefitAnalysis);
result = 31 * result + Objects.hashCode(environmentalCriteria);
return result;
}
}
Loading

0 comments on commit db4b96e

Please sign in to comment.