Skip to content

Commit

Permalink
Merge pull request #36 from matsim-vsp/kmt_nkvPaper
Browse files Browse the repository at this point in the history
Kmt nkv paper
  • Loading branch information
kt86 authored Sep 13, 2024
2 parents fc4733d + bff822f commit cd85677
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/tub/vsp/bvwp/computation/NkvCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public static Double calculateNkv(Modifications modifications, StreetBaseDataCon

private static Optional<Amounts> amountsFromStreetBaseData(StreetBaseDataContainer streetBaseDataContainer) {

StreetPhysicalEffectDataContainer.Effect tt = streetBaseDataContainer.getPhysicalEffect().getTravelTimes();
StreetPhysicalEffectDataContainer.Effect tt = streetBaseDataContainer.getPhysicalEffect().getTravelTimesPV();

StreetPhysicalEffectDataContainer.Effect vkm = streetBaseDataContainer.getPhysicalEffect()
.getVehicleKilometers();
.getVehicleKilometersPV();

VehicleEmissions vehicleEmissions = streetBaseDataContainer.getPhysicalEffect().getEmissionsDataContainer()
.emissions().get(Emission.CO2);
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/tub/vsp/bvwp/data/Headers.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class Headers{
* = {@link #ADDTL_PKWKM_EL03} - {@link #ADDTL_PKWKM_ORIG}
*/
public static final String ADDTL_PKWKM = "zusätzliche Pkw-km";
public static final String ADDTL_LKWKM = "zusätzliche Lkw-km";
public static final String ADDTL_PKWKM_EL03_DIFF = "addtl_pkwkm_el03_diff";
/**
* Der "induzierte" (Mehr-)Verkehr laut PRINS.
Expand All @@ -26,9 +27,12 @@ public final class Headers{
/**
* Mehrverkehr auf Pkw, den das Projekt erzeugt, laut PRINS.
*/
//Personenverkehr
public static final String ADDTL_PKWKM_ORIG = ADDTL_PKWKM + " in PRINS";
public static final String ADDTL_PKWKM_FROM_TTIME = ADDTL_PKWKM + " aus Reisezeitgewinnen";
public static final String ADDTL_PKWKM_FROM_TTIME_DIFF = "addtl_pkwkm_from_ttime_diff";
//Güterverkehr
public static final String ADDTL_LKWKM_ORIG = ADDTL_LKWKM + " in PRINS";

/**
* So etwas wie "Neubau", "Knotenpunkt(projekt)", Erweiterung auf 6 oder 8 Spuren.
Expand Down Expand Up @@ -89,7 +93,7 @@ public final class Headers{
/**
* min( 5 , {@link #NKV_ORIG} )
*/
public static final String NKV_ORIG = "NKV BVWP 2030";
public static final String NKV_ORIG_CAPPED5 = "NKV_orig_capped5";
/**
* NKV bei erhöhtem CO2-Preis (welchem?).
*/
Expand Down Expand Up @@ -141,6 +145,9 @@ public final class Headers{
/**
* Originales NKV.
*/
public static final String NKV_ORIG = "NKV BVWP 2030";
public static final String NKV_ORIG_EN = "BCR_original";

/**
* Dies ist da, damit "bubble size" als Funktion der Einstufung geplottet werden kann.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void addComputations() {
entries.put( Headers.ADDTL_LANE_KM, additionalLaneKm );

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

// logger.info("addtlFzkmBeyondPrinsEl03=" + addtlFzkmBeyondPrinsEl03);
Expand All @@ -90,11 +90,12 @@ private void addComputations() {
NkvCalculator nkvCalculator = new NkvCalculator( streetBaseData );

entries.put(Headers.NKV_ORIG, nkvCalculator.calculateNkv( NO_CHANGE ) );
entries.put(Headers.NKV_ORIG_EN, 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( 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_CARBON215_INVCOSTTUD, nkvCalculator.calculateNkv( new Modifications( co2Price215, addtlFzkmBeyondPrinsEl03, 1,1,1. ) ) );
// 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 ) );
Expand All @@ -119,12 +120,12 @@ private void addComputations() {
//
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.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1 ) ) ) );
entries.put(Headers.CO2_COST_EL03, Math.max( 1., nkvCalculator.calculateCo2_t( new Modifications( co2PriceBVWP, addtlFzkmBeyondPrinsEl03, 1,1,1 ) ) ) );
// ("max(1,...)" so that they become visible on logplot. find other solution!
entries.put(Headers.INVCOST_TUD, this.constructionCostTud );

double AVERAGE_SPEED_OF_ADDITIONAL_TRAVEL = 50; // km/h
double addtlFzkmFromTtime = - streetBaseData.getPhysicalEffect().getVehicleHours().overall() * AVERAGE_SPEED_OF_ADDITIONAL_TRAVEL;
double addtlFzkmFromTtime = - streetBaseData.getPhysicalEffect().getVehicleHoursPV().overall() * AVERAGE_SPEED_OF_ADDITIONAL_TRAVEL;
entries.put( Headers.ADDTL_PKWKM_FROM_TTIME, addtlFzkmFromTtime );

// Beiträge einzeln:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

public class StreetPhysicalEffectDataContainer {
private StreetEmissionsDataContainer emissionsDataContainer;
private Effect travelTimes;
private Effect vehicleKilometers;
private Effect vehicleHours;
private Effect travelTimesPV;
private Effect vehicleKilometersPV; //Personenverkehr
private Effect vehicleHoursPV; //Personenverkehr
//KMT braucht für das EWGT Paper auch die ckm im GV um Gesamtsumme bilden zu können.
private Double vehicleKilometersGV; //Güterverkehr

public StreetEmissionsDataContainer getEmissionsDataContainer() {
return emissionsDataContainer;
Expand All @@ -23,20 +25,28 @@ public StreetPhysicalEffectDataContainer setEmissionsDataContainer(StreetEmissio
return this;
}

public Effect getTravelTimes() {
return travelTimes;
public Effect getTravelTimesPV() {
return travelTimesPV;
}

public void setTravelTimes(Effect travelTimes) {
this.travelTimes = travelTimes;
public void setTravelTimesPV(Effect travelTimesPV) {
this.travelTimesPV = travelTimesPV;
}

public Effect getVehicleKilometers() {
return vehicleKilometers;
public Effect getVehicleKilometersPV() {
return vehicleKilometersPV;
}

public void setVehicleKilometers(Effect vehicleKilometers) {
this.vehicleKilometers = vehicleKilometers;
public Double getVehicleKilometersGV() {
return vehicleKilometersGV;
}

public void setVehicleKilometersPV(Effect vehicleKilometersPV) {
this.vehicleKilometersPV = vehicleKilometersPV;
}

public void setVehicleKilometersGV(Double vehicleKilometersGV) {
this.vehicleKilometersGV = vehicleKilometersGV;
}

@Override
Expand All @@ -53,24 +63,27 @@ public boolean equals(Object o) {
if (!Objects.equals(emissionsDataContainer, that.emissionsDataContainer)) {
return false;
}
if (!Objects.equals(travelTimes, that.travelTimes)) {
if (!Objects.equals(travelTimesPV, that.travelTimesPV)) {
return false;
}
if (!Objects.equals(vehicleKilometersGV, that.vehicleKilometersGV)) {
return false;
}
return Objects.equals(vehicleKilometers, that.vehicleKilometers);
return Objects.equals(vehicleKilometersPV, that.vehicleKilometersPV);
}

@Override
public int hashCode() {
int result = emissionsDataContainer != null ? emissionsDataContainer.hashCode() : 0;
result = 31 * result + (travelTimes != null ? travelTimes.hashCode() : 0);
result = 31 * result + (vehicleKilometers != null ? vehicleKilometers.hashCode() : 0);
result = 31 * result + (travelTimesPV != null ? travelTimesPV.hashCode() : 0);
result = 31 * result + (vehicleKilometersPV != null ? vehicleKilometersPV.hashCode() : 0);
return result;
}
public void setVehicleHours( Effect vehicleHours ){
this.vehicleHours = vehicleHours;
public void setVehicleHoursPV(Effect vehicleHoursPV){
this.vehicleHoursPV = vehicleHoursPV;
}
public Effect getVehicleHours(){
return vehicleHours;
public Effect getVehicleHoursPV(){
return vehicleHoursPV;
}

public static final record Effect(Double overall, Double induced, Double shifted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ public static StreetPhysicalEffectDataContainer mapDocument(Document document) {
}

JSoupUtils.getFirstRowIndexWithText( table.get(), "Veränderung der Fahrzeugeinsatzzeiten im PV" )
.ifPresent( i -> physicalEffectDataContainer.setVehicleHours( extractEffect( table.get(), i ) ) );
.ifPresent( i -> physicalEffectDataContainer.setVehicleHoursPV( extractEffectPV( table.get(), i ) ) );

JSoupUtils.getFirstRowIndexWithText(table.get(), "Veränderung der Reisezeit im PV")
.ifPresent(i -> physicalEffectDataContainer.setTravelTimes(extractEffect(table.get(), i)));
.ifPresent(i -> physicalEffectDataContainer.setTravelTimesPV(extractEffectPV(table.get(), i)));

JSoupUtils.getFirstRowIndexWithText(table.get(), "Veränderung der Betriebsleistung im Personenverkehr")
.ifPresent(i -> physicalEffectDataContainer.setVehicleKilometers(extractEffect(table.get(), i)));
.ifPresent(i -> physicalEffectDataContainer.setVehicleKilometersPV(extractEffectPV(table.get(), i)));

JSoupUtils.getFirstRowIndexWithText(table.get(), "Veränderung der Betriebsleistung Güterverkehr (GV)")
.ifPresent(i -> physicalEffectDataContainer.setVehicleKilometersGV(extractEffectGV(table.get(), i)));

return physicalEffectDataContainer;
}
Expand All @@ -45,7 +48,13 @@ private static Optional<Integer> getFirstRowIndexWithTextAfter(Element table, St
return Optional.empty();
}

private static StreetPhysicalEffectDataContainer.Effect extractEffect(Element table, int firsRow) {
/**
* Extract the Physical Effects Data for Person transport
* @param table
* @param firsRow
* @return
*/
private static StreetPhysicalEffectDataContainer.Effect extractEffectPV(Element table, int firsRow) {
Double overall = JSoupUtils.parseDoubleOrElseNull(JSoupUtils.getTextFromRowAndCol(table, firsRow, 1));
Double induced = getFirstRowIndexWithTextAfter(table, "induziertem Verkehr", firsRow)
.map(row -> JSoupUtils.getTextFromRowAndCol(table, row, 1))
Expand All @@ -55,4 +64,14 @@ private static StreetPhysicalEffectDataContainer.Effect extractEffect(Element ta
.map(JSoupUtils::parseDoubleOrElseNull).orElse(null);
return new StreetPhysicalEffectDataContainer.Effect(overall, induced, shifted);
}

/**
* Extract the Physical Effects Data for Goods transport
* @param table
* @param firsRow
* @return
*/
private static Double extractEffectGV(Element table, int firsRow) {
return JSoupUtils.parseDoubleOrElseNull(JSoupUtils.getTextFromRowAndCol(table, firsRow, 1));
}
}
6 changes: 4 additions & 2 deletions src/main/java/org/tub/vsp/bvwp/io/StreetCsvWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ private static List<Object> getCsvRecord(StreetAnalysisDataContainer analysisDat
record.add(Headers.DAUER_BAU, baseDataContainer.getCostBenefitAnalysis().getDurations().construction());
record.add(Headers.DAUER_BETRIEB, baseDataContainer.getCostBenefitAnalysis().getDurations().operation());

record.add(Headers.ADDTL_PKWKM_ORIG, baseDataContainer.getPhysicalEffect().getVehicleKilometers().overall());
record.add(Headers.ADDTL_PKWKM_INDUZ_ORIG, Optional.ofNullable(baseDataContainer.getPhysicalEffect().getVehicleKilometers().induced() ).orElse(0. ) );
record.add(Headers.ADDTL_PKWKM_ORIG, baseDataContainer.getPhysicalEffect().getVehicleKilometersPV().overall());
record.add(Headers.ADDTL_PKWKM_INDUZ_ORIG, Optional.ofNullable(baseDataContainer.getPhysicalEffect().getVehicleKilometersPV().induced() ).orElse(0. ) );
record.add(Headers.ADDTL_LKWKM_ORIG, Optional.ofNullable(baseDataContainer.getPhysicalEffect().getVehicleKilometersGV() ).orElse(0. ) );

record.add(Headers.B_PER_KM, baseDataContainer.getCostBenefitAnalysis().getNbOperations().overall());

Expand Down Expand Up @@ -257,6 +258,7 @@ private static List<String> getHeaders(List<StreetAnalysisDataContainer> analysi
headers.addDoubleColumn( Headers.ADDTL_PKWKM_ORIG );
headers.addDoubleColumn(Headers.ADDTL_PKWKM_INDUZ_ORIG );
// headers.addDoubleColumn( Headers.PKWKM_INDUZ_NEU ); // added by automagic
headers.addDoubleColumn( Headers.ADDTL_LKWKM_ORIG );
headers.addDoubleColumn(Headers.B_FZKM);

headers.addDoubleColumn(Headers.CO_2_EQUIVALENTS_EMISSIONS);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static Figure createFigureCostByPriority(int plotWidth, Table table, String xNam

static Figure createFigureNkvByPriority(Axis xAxis, int plotWidth, Table table, String xName) {
Figure figure2;
String yName = Headers.NKV_ORIG;
String yName = Headers.NKV_ORIG_EN;
// String y3Name = Headers.NKV_CO2_680_EN;
String y2Name = Headers.NKV_EL03_CARBON215_INVCOSTTUD;

Expand Down Expand Up @@ -126,7 +126,7 @@ static Figure createFigureNkvByPriority(Axis xAxis, int plotWidth, Table table,

static Figure createFigureNkv(Axis xAxis, int plotWidth, Table table, String xName) {
Figure figure2;
String yName = Headers.NKV_ORIG;
String yName = Headers.NKV_ORIG_EN;
String y3Name = Headers.NKV_CO2_700_EN;
// String y2Name = Headers.NKV_INDUZ_CO2;

Expand Down
Loading

0 comments on commit cd85677

Please sign in to comment.