Skip to content

Commit

Permalink
put elasticity values into column headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kainagel committed Mar 14, 2024
1 parent 17b579b commit 0498987
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 101 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/tub/vsp/bvwp/RunCsvWriting.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void main(String[] args) {
List<StreetAnalysisDataContainer> allStreetBaseData =
new StreetScraper().extractAllLocalBaseData("./data/street/all", "A", ".*")
.stream()
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) )
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) )
.toList();

StreetCsvWriter csvWriter = new StreetCsvWriter("output/street_data.csv");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tub/vsp/bvwp/RunLocalCsvScraping.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void main(String[] args) {
logger.info("Starting scraping");
List<StreetAnalysisDataContainer> allStreetBaseData = scraper.extractAllLocalBaseData("./data/street", "A", ".*" )
.stream()
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) )
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) )
.toList();

logger.info("Writing csv");
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/org/tub/vsp/bvwp/data/Headers.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public final class Headers{
*/
public static final String ADDTL_LANE_KM = "addtl_lane_km";
/**
* = {@link #ADDTL_PKWKM_NEU} - {@link #ADDTL_PKWKM_ORIG}
* = {@link #ADDTL_PKWKM_EL03} - {@link #ADDTL_PKWKM_ORIG}
*/
public static final String ADDTL_PKWKM_DIFF = "addtl_pkwkm_diff";
public static final String ADDTL_PKWKM_EL03_DIFF = "addtl_pkwkm_el03_diff";
/**
* Der "induzierte" (Mehr-)Verkehr laut PRINS.
*/
Expand All @@ -19,7 +19,7 @@ public final class Headers{
* Mehrverkehr auf Pkw, den das Projekt erzeugt, laut unserer eigenen Abschätzung. Wird immer mal mit anderen Elastizitäten gerechnet, so
* dass sich die Werte immer mal ändern.
*/
public static final String ADDTL_PKWKM_NEU = "addtl_pkwkm_new";
public static final String ADDTL_PKWKM_EL03 = "addtl_pkwkm_el03";
/**
* Mehrverkehr auf Pkw, den das Projekt erzeugt, laut PRINS.
*/
Expand Down Expand Up @@ -83,37 +83,37 @@ public final class Headers{
/**
* min( 5 , {@link #NKV_ORIG} )
*/
public static final String NKV_ORIG_CAPPED5 = "NKV_orig_capped";
public static final String NKV_ORIG_CAPPED5 = "NKV_orig_capped5";
/**
* 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_680_EN = "BCR_co2_680";
/**
* {@link #NKV_INDUZ_CO2215_CONSTRUCTION} - {@link #NKV_ORIG}
* {@link #NKV_EL03_CO2_215_CONSTRUCTION} - {@link #NKV_ORIG}
*/
public static final String NKV_DIFF = "nkvDiff";
public static final String NKV_EL03_DIFF = "NKV_el03_Diff";
/**
* Neues NKV bei erhöhter Abschätzung für Mehrverkehr.
*/
public static final String NKV_INDUZ = "NKV_induz";
public static final String NKV_EL03 = "NKV_el03";
/**
* Neues NKV mit höherem Mehrverkehr, CO2-Preis 215, sowie höheren Investitionskosten.
*/
public static final String NKV_INDUZ_CO2215_CONSTRUCTION = "NKV_induzCo2215Invkosten";
public static final String NKV_EL03_CO2_215_CONSTRUCTION = "NKV_el03Co2_215Invkosten";
/**
* min( 5, {@link #NKV_INDUZ_CO2215_CONSTRUCTION})
* min( 5, {@link #NKV_EL03_CO2_215_CONSTRUCTION})
*/
public static final String NKV_INDUZ_CO2215_CONSTRUCTION_CAPPED5 = "NKV_induzCo2215Invkosten_capped5";
public static final String NKV_EL03_CO2_215_CONSTRUCTION_CAPPED5 = "NKV_el03Co2_215Invkosten_capped5";
/**
* Neues NKV mit höherem Mehrverkehr, höherem CO2-Preis, höheren Investitionskosten.
*/
public static final String NKV_INDUZ_CO2_CONSTRUCTION = "NKV_induzCo2Invkosten";
public static final String NKV_EL03_CO2_CONSTRUCTION = "NKV_el03Co2Invkosten";
/**
* min( 5, {@link #NKV_INDUZ_CO2_CONSTRUCTION} )
* min( 5, {@link #NKV_EL03_CO2_CONSTRUCTION} )
*/
public static final String NKV_INDUZ_CO2_CONSTRUCTION_CAPPED5 = "NKV_induzCo2Invkosten_capped5";
public static final String NKV_EL03_CO2_CONSTRUCTION_CAPPED5 = "NKV_el03Co2Invkosten_capped5";
public static final String NKV_INDUZ_CO2_EN = "BCR_induzCo2";
public static final String NKV_INDUZ_EN = "BCR_induz";
public static final String NKV_NO_CHANGE_EN = "BCR";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,23 @@
public class StreetAnalysisDataContainer {
Logger logger = LogManager.getLogger(StreetAnalysisDataContainer.class);
private final StreetBaseDataContainer streetBaseData;
private final double elasticity;
private final double constructionCostFactor;
private final SequencedMap<String, Double> entries = new LinkedHashMap<>();
private final List<String> remarks = new ArrayList<>();

public StreetAnalysisDataContainer( StreetBaseDataContainer streetBaseDataContainer, double elasticity, double constructionCostFactor ) {
public StreetAnalysisDataContainer( StreetBaseDataContainer streetBaseDataContainer, double constructionCostFactor ) {
this.streetBaseData = streetBaseDataContainer;
this.elasticity = elasticity;
this.constructionCostFactor = constructionCostFactor;
logger.info(this.streetBaseData.getUrl() );
this.addComputations();
}

private void addComputations() {
// double fzkm_induz = streetBaseDataContainer.getPhysicalEffect().getVehicleKilometers().induced();
// double addtlFzkmFromElasticity = 4. * fzkm_induz;
// if (addtlFzkmFromElasticity == 0.) {
// double addtlFzkmFromElasticity03 = 4. * fzkm_induz;
// if (addtlFzkmFromElasticity03 == 0.) {
// double fzkm = streetBaseDataContainer.getPhysicalEffect().getVehicleKilometers().overall();
// addtlFzkmFromElasticity = 4. * fzkm;
// addtlFzkmFromElasticity03 = 4. * fzkm;
// }
// yyyyyy die obige Rechnung muss schlussendlich genauer sein ... zusätzliche Spurkm / 60000 * 0.6 *
// Jahresfahrleistung_AB
Expand Down Expand Up @@ -94,11 +92,11 @@ private void addComputations() {

entries.put( Headers.ADDTL_LANE_KM, additionalLaneKm );

double addtlFzkmFromElasticity = additionalLaneKm / ComputationKN.LANE_KM_AB * elasticity * ComputationKN.FZKM_AB;
final double addtlFzkmBeyondPRINS = addtlFzkmFromElasticity - streetBaseData.getPhysicalEffect().getVehicleKilometers().overall();
// (this is formulated such that addtlFzkmBeyondPRINS=0 means the original additional Fzkm)
double addtlFzkmFromElasticity03 = additionalLaneKm / ComputationKN.LANE_KM_AB * 0.3 * ComputationKN.FZKM_AB;
final double addtlFzkmBeyondPrinsEl03 = addtlFzkmFromElasticity03 - streetBaseData.getPhysicalEffect().getVehicleKilometers().overall();
// (this is formulated such that addtlFzkmBeyondPrinsEl03=0 means the original additional Fzkm)

// logger.info("addtlFzkmBeyondPRINS=" + addtlFzkmBeyondPRINS);
// logger.info("addtlFzkmBeyondPrinsEl03=" + addtlFzkmBeyondPrinsEl03);
// entries.put("cost/km", streetBaseDataContainer.getCostBenefitAnalysis().getCost().overallCosts() /
// streetBaseDataContainer.getProjectInformation().getLength() );
// entries.put("rz", streetBaseDataContainer.getPhysicalEffect().getTravelTimes().overall());
Expand All @@ -109,14 +107,14 @@ private void addComputations() {
entries.put(Headers.NKV_CO2, NkvCalculator.calculateNkv( new Modifications(co2Price680, 0., 1 ), streetBaseData ) );
entries.put(Headers.NKV_CO2_680_EN, NkvCalculator.calculateNkv( new Modifications(co2Price680, 0., 1 ), streetBaseData ) );
entries.put(Headers.NKV_CO2_2000_EN, NkvCalculator.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 0, 1 ), streetBaseData ) );
entries.put(Headers.NKV_INDUZ, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPRINS, 1 ), streetBaseData ) );
entries.put(Headers.NKV_INDUZ_CO2215_CONSTRUCTION,
NkvCalculator.calculateNkv( new Modifications( 215, addtlFzkmBeyondPRINS, constructionCostFactor ), streetBaseData ) );
entries.put(Headers.NKV_INDUZ_CO2_CONSTRUCTION, NkvCalculator.calculateNkv( new Modifications( co2Price680, addtlFzkmBeyondPRINS, constructionCostFactor ), streetBaseData ) );
entries.put(Headers.ADDTL_PKWKM_NEU, addtlFzkmFromElasticity );
entries.put(Headers.NKV_EL03, NkvCalculator.calculateNkv( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ), streetBaseData ) );
entries.put(Headers.NKV_EL03_CO2_215_CONSTRUCTION,
NkvCalculator.calculateNkv( new Modifications( 215, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), streetBaseData ) );
entries.put(Headers.NKV_EL03_CO2_CONSTRUCTION, NkvCalculator.calculateNkv( new Modifications( co2Price680, addtlFzkmBeyondPrinsEl03, constructionCostFactor ), 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_NEU,
Math.max( 1., NkvCalculator.calculateCost_CO2( new Modifications( co2PriceBVWP, addtlFzkmBeyondPRINS, 1 ), streetBaseData ) ) );
Math.max( 1., NkvCalculator.calculateCost_CO2( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ), streetBaseData ) ) );
// ("max(1,...)" so that they become visible on logplot. find other solution!

if ( streetBaseData.getProjectInformation().getProjectNumber().contains("A1-G50-NI" )) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static Figure createFigureNkvByPriority( Axis xAxis, int plotWidth, Table table,
Figure figure2;
String yName = Headers.NKV_ORIG;
String y3Name = Headers.NKV_CO2_680_EN;
String y2Name = Headers.NKV_INDUZ_CO2_CONSTRUCTION;
String y2Name = Headers.NKV_EL03_CO2_CONSTRUCTION;

Axis yAxis = Axis.builder()
// .type( Axis.Type.LOG ) // wirft NKV < 0 raus!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static void main(String[] args) throws IOException {
List<StreetAnalysisDataContainer> allStreetBaseData = scraper
.extractAllLocalBaseData("./data/street/all2", "A", ".*")
.stream()
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 0.6, 1. ) )
.map( streetBaseDataContainer -> new StreetAnalysisDataContainer( streetBaseDataContainer, 1. ) )
.toList();

logger.info("Writing csv");
Expand All @@ -73,8 +73,8 @@ public static void main(String[] args) throws IOException {
// table = table.where( table.numberColumn( Headers.NKV_INDUZ_CO2 ).isLessThan( 2.) );

table.addColumns(table.numberColumn(Headers.NKV_ORIG )
.subtract(table.numberColumn(Headers.NKV_INDUZ_CO2_CONSTRUCTION ) ).setName(
Headers.NKV_DIFF ));
.subtract(table.numberColumn(Headers.NKV_EL03_CO2_CONSTRUCTION ) ).setName(
Headers.NKV_EL03_DIFF ) );

// final Table newTable = table.selectColumns( "nkvDiff", Headers.COST_OVERALL );
// LinearModel winsModel = OLS.fit( Formula.lhs("nkvDiff" ), newTable.smile().toDataFrame() );
Expand Down Expand Up @@ -147,15 +147,15 @@ public static void main(String[] args) throws IOException {
Table tableCo2_680_Kl1 = table.where(table.numberColumn(Headers.NKV_CO2_680_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_INDUZ_CO2_CONSTRUCTION ).isLessThan(1. ) );
table.numberColumn(Headers.NKV_EL03_CO2_CONSTRUCTION ).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_INDUZ_CO2_CONSTRUCTION, count, mean, stdDev, min, max )
tableIndCo2kl1.summarize(Headers.NKV_EL03_CO2_CONSTRUCTION, count, mean, stdDev, min, max )
.by(Headers.EINSTUFUNG ) );

System.out.println(BvwpUtils.SEPARATOR);
Expand Down
Loading

0 comments on commit 0498987

Please sign in to comment.