Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaibranch #18

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 16 additions & 14 deletions src/main/java/org/tub/vsp/bvwp/data/Headers.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.tub.vsp.bvwp.data;

import org.tub.vsp.bvwp.data.type.Einstufung;

public final class Headers{
/**
* Additional lane-km of the project. Estimated from length of the construction project and project type (e.g. "Neubau" vs. "Erweiterung").
*/
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 @@ -17,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 @@ -67,7 +69,7 @@ public final class Headers{
/**
* So etwas wie "VB-E", "VB", ...
*
* @see org.tub.vsp.bvwp.data.type.Priority
* @see Einstufung
*/
public static final String EINSTUFUNG = "Einstufung";
/**
Expand All @@ -81,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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.tub.vsp.bvwp.data.container.base.rail;

import org.tub.vsp.bvwp.data.type.Priority;
import org.tub.vsp.bvwp.data.type.Einstufung;

import java.util.Objects;

public class RailProjectInformationDataContainer {
private String projectNumber;
private String title;
private Priority priority;
private Einstufung priority;
private String bautyp;
private Double length;

Expand All @@ -29,11 +29,11 @@ public RailProjectInformationDataContainer setTitle(String title) {
return this;
}

public Priority getPriority() {
public Einstufung getPriority() {
return priority;
}

public RailProjectInformationDataContainer setPriority(Priority priority) {
public RailProjectInformationDataContainer setPriority( Einstufung priority ) {
this.priority = priority;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.tub.vsp.bvwp.data.container.base.street;

import org.tub.vsp.bvwp.data.type.Bautyp;
import org.tub.vsp.bvwp.data.type.Priority;
import org.tub.vsp.bvwp.data.type.Einstufung;

import java.util.Objects;

public class StreetProjectInformationDataContainer {
private String projectNumber;
private String street;
private Priority priority;
private Einstufung priority;
private Bautyp bautyp;
private Double length;
private Double verkehrsbelastung2030;
Expand All @@ -31,11 +31,11 @@ public StreetProjectInformationDataContainer setStreet(String street) {
return this;
}

public Priority getPriority() {
public Einstufung getPriority() {
return priority;
}

public StreetProjectInformationDataContainer setPriority(Priority priority) {
public StreetProjectInformationDataContainer setPriority( Einstufung priority ) {
this.priority = priority;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.jsoup.nodes.Document;
import org.tub.vsp.bvwp.JSoupUtils;
import org.tub.vsp.bvwp.data.container.base.rail.RailProjectInformationDataContainer;
import org.tub.vsp.bvwp.data.type.Priority;
import org.tub.vsp.bvwp.data.type.Einstufung;

import java.text.ParseException;

Expand All @@ -26,7 +26,7 @@ public static RailProjectInformationDataContainer mapDocument(Document document)
return projectInformation.setProjectNumber(projectNumber)
.setTitle(titel)
.setLength(JSoupUtils.parseDouble(length))
.setPriority(Priority.getFromString(priority));
.setPriority( Einstufung.getFromString(priority ) );
} catch (ParseException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import org.apache.logging.log4j.Logger;
import org.jsoup.nodes.Document;
import org.tub.vsp.bvwp.JSoupUtils;
import org.tub.vsp.bvwp.computation.ConsoleColors;
import org.tub.vsp.bvwp.data.container.base.street.StreetProjectInformationDataContainer;
import org.tub.vsp.bvwp.data.type.Bautyp;
import org.tub.vsp.bvwp.data.type.Priority;
import org.tub.vsp.bvwp.data.type.Einstufung;

import java.text.ParseException;

Expand Down Expand Up @@ -50,7 +49,7 @@ public static StreetProjectInformationDataContainer mapDocument(Document documen
.setStreet(street)
.setLength(JSoupUtils.parseDouble(length))
.setBautyp(Bautyp.getFromString(bautyp))
.setPriority(Priority.getFromString(priority))
.setPriority( Einstufung.getFromString(priority ) )
.setVerkehrsbelastungPlanfall( JSoupUtils.parseDouble( verkehrsbelastungPlanfall ) );
} catch (ParseException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public enum Priority{
public enum Einstufung{
VBE("Vordringlicher Bedarf - Engpassbeseitigung (VB-E)"),
VB("Vordringlicher Bedarf (VB)"),
WBP("Weiterer Bedarf mit Planungsrecht (WB*)"),
WB( "Weiterer Bedarf (WB)"),
@Deprecated // yyyyyy lieber aufklären!!
UNDEFINED("undefined");

private static final Logger log = LogManager.getLogger( Priority.class );
private static final Logger log = LogManager.getLogger( Einstufung.class );

public final String description;

Priority( String description ) {
Einstufung( String description ) {
this.description = description;
}

public static Priority getFromString( String description ) {
for ( Priority v : values()){
public static Einstufung getFromString( String description ) {
for ( Einstufung v : values()){
if( v.description.equalsIgnoreCase( description ) ){
return v;
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/tub/vsp/bvwp/users/kmt/FiguresKMT.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.tub.vsp.bvwp.BvwpUtils;
import org.tub.vsp.bvwp.data.Headers;
import org.tub.vsp.bvwp.data.type.Priority;
import org.tub.vsp.bvwp.data.type.Einstufung;
import tech.tablesaw.api.Table;
import tech.tablesaw.plotly.components.Axis;
import tech.tablesaw.plotly.components.Axis.Type;
Expand All @@ -20,8 +20,8 @@ class FiguresKMT {
//Do not instanciate
FiguresKMT(){}

private static Trace getPriorityTrace( Table table, Priority priority, String xName, String yName,
String color){
private static Trace getPriorityTrace( Table table, Einstufung priority, String xName, String yName,
String color){
Table tableVbe = BvwpUtils.extractPriorityTable(table, priority.name());
return ScatterTrace.builder( tableVbe.numberColumn( xName ), tableVbe.numberColumn( yName ) )
.text( tableVbe.stringColumn( Headers.PROJECT_NAME ).asObjectArray() )
Expand Down Expand Up @@ -61,10 +61,10 @@ static Figure createFigureCostByPriority(int plotWidth, Table table, String xNam
.name( String.format( legendFormat, yName ) )
.build();

final Trace traceWb = getPriorityTrace(table, Priority.WB, xName, y2Name, "cyan");
final Trace traceWbp = getPriorityTrace(table, Priority.WBP, xName, y2Name, "yellow");
final Trace traceVb = getPriorityTrace(table, Priority.VB, xName, y2Name, "orange");
final Trace traceVbe = getPriorityTrace( table, Priority.VBE , xName, y2Name, "red" );
final Trace traceWb = getPriorityTrace(table, Einstufung.WB, xName, y2Name, "cyan" );
final Trace traceWbp = getPriorityTrace(table, Einstufung.WBP, xName, y2Name, "yellow" );
final Trace traceVb = getPriorityTrace(table, Einstufung.VB, xName, y2Name, "orange" );
final Trace traceVbe = getPriorityTrace( table, Einstufung.VBE , xName, y2Name, "red" );

Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) )
.text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() )
Expand All @@ -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 All @@ -101,10 +101,10 @@ static Figure createFigureNkvByPriority( Axis xAxis, int plotWidth, Table table,
.name( String.format( legendFormat, String.format( "%30s" , yName ) ) )
.build();

final Trace traceWb = getPriorityTrace(table, Priority.WB, xName, y2Name, "cyan");
final Trace traceWbp = getPriorityTrace(table, Priority.WBP, xName, y2Name, "yellow");
final Trace traceVb = getPriorityTrace(table, Priority.VB, xName, y2Name, "orange");
final Trace traceVbe = getPriorityTrace( table, Priority.VBE , xName, y2Name, "red" );
final Trace traceWb = getPriorityTrace(table, Einstufung.WB, xName, y2Name, "cyan" );
final Trace traceWbp = getPriorityTrace(table, Einstufung.WBP, xName, y2Name, "yellow" );
final Trace traceVb = getPriorityTrace(table, Einstufung.VB, xName, y2Name, "orange" );
final Trace traceVbe = getPriorityTrace( table, Einstufung.VBE , xName, y2Name, "red" );


Trace trace3 = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( y3Name ) )
Expand Down
Loading
Loading