Skip to content

Commit

Permalink
Merge pull request #26 from matsim-vsp/kaibranch
Browse files Browse the repository at this point in the history
adding rail.  some adaptation for road plots
  • Loading branch information
kainagel authored Jun 7, 2024
2 parents 6388846 + 3463ab8 commit cdb0434
Show file tree
Hide file tree
Showing 7 changed files with 962 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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_Factor2022to2012, 0, 1, 1. ), baseDataContainer ) );
entries.put(Headers.NKV_CO2_2000_EN, NkvCalculatorRail.calculateNkv( new Modifications( 2000 * INFLATION_Factor2022to2012, 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 ) );
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/tub/vsp/bvwp/data/type/Einstufung.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ 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")
WB( "Weiterer Bedarf (WB)"),
KB( "Kein Bedarf (KB)")
// ,@Deprecated /* yyyyyy lieber aufklären!! */ UNDEFINED("undefined")
;

private static final Logger log = LogManager.getLogger( Einstufung.class );
Expand All @@ -29,7 +30,7 @@ public static Einstufung getFromString( String description ) {
}
}
log.warn( "description=" + description );
// throw new RuntimeException( "unknown Einstufung=" + description );
return UNDEFINED;
throw new RuntimeException( "unknown Einstufung=" + description );
// return UNDEFINED;
}
}
131 changes: 29 additions & 102 deletions src/main/java/org/tub/vsp/bvwp/users/kn/Figures1KN.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ class Figures1KN{
final double nkvCappedMax;
final double nkvMin;
private static boolean init = true ;
Figures1KN( Table table ){
Figures1KN( Table table, String xName ){
this.xName = xName;
Axis.AxisBuilder xAxisBuilder = Axis.builder();

if ( xName!=null && xName.contains( "NKV" ) ) {
xAxisBuilder.autoRange( Axis.AutoRange.REVERSED );
}

// ---------------------------------------------------------------
{
// xName = Headers.B_CO2_NEU;
Expand All @@ -48,7 +54,7 @@ class Figures1KN{
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// {
xName = NKV_ORIG_CAPPED5;
// this.xName = NKV_ORIG_CAPPED5;
// xName = Headers.NKV_INDUZ_CO2;
// xName = Headers.NKV_DIFF;
// xName = Headers.ADDITIONAL_LANE_KM;
Expand Down Expand Up @@ -108,7 +114,7 @@ class Figures1KN{
{
DoubleColumn column = DoubleColumn.create( EINSTUFUNG_AS_NUMBER );
final double factor = 8.;
final double offset = 3.;
final double offset = 2.;
for( String prio : table.stringColumn( EINSTUFUNG ) ){
switch( Einstufung.valueOf( prio ) ){
case VBE -> {
Expand All @@ -127,7 +133,7 @@ class Figures1KN{
// column.append( 2. );
// }
default -> {
column.append( 2. );
column.append( offset );
// throw new IllegalStateException( "Unexpected value: " + prio );
}
}
Expand All @@ -147,9 +153,11 @@ class Figures1KN{

}

table = table.sortAscendingOn( xName );
if ( this.xName != null ){
table = table.sortAscendingOn( this.xName );
}

this.xAxis = xAxisBuilder.title( xName )
this.xAxis = xAxisBuilder.title( this.xName )
// .type( Axis.Type.LOG )
.build();

Expand All @@ -160,55 +168,6 @@ class Figures1KN{



}
// ################################################################
// ################################################################
Figure invcost_tud_vs_orig(){
String xName = INVCOST_ORIG;

String yName = INVCOST_TUD;
// String y3Name = Headers.COST_OVERALL;
String y2Name = INVCOST_TUD;

String plotTitle = "";

Axis xAxis = Axis.builder()
.title( xName )
.type( Axis.Type.LOG)
.build();

Axis yAxis = Axis.builder()
.type( Axis.Type.LOG )
// .range( 1.1*table.numberColumn( y2Name ).min(),4. )
.title( yName )
.build();
Layout layout = Layout.builder( plotTitle )
.xAxis( xAxis )
.yAxis( yAxis )
.width( plotWidth )
.build();

List<Trace> traces = new ArrayList<>();

// Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) )
// .text( table.stringColumn( Headers.PROJECT_NAME ).asObjectArray() )
// .name( String.format( legendFormat, yName ) )
// .build();

traces.add( getTraceCyan( table, xName, y2Name ) );
traces.add( getTraceMagenta( table, xName, y2Name ) );
traces.add( getTraceOrange( table, xName, y2Name ) );
traces.add( getTraceRed( table, xName, y2Name ) );

{
double[] xx = new double[]{ table.numberColumn( xName ).min(), table.numberColumn( xName ).max() };
double[] yy = new double[]{ table.numberColumn( xName ).min(), table.numberColumn( xName ).max() };
traces.add( ScatterTrace.builder( xx, yy )
.mode( ScatterTrace.Mode.LINE )
.build() );
}
Figure figure3 = new Figure( layout, traces.toArray( new Trace[0] ) );
return figure3;
}
// ========================================================================================
// ========================================================================================
Expand Down Expand Up @@ -558,20 +517,12 @@ Figure carbon(){

Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build();

Trace trace = ScatterTrace.builder( table.numberColumn( xName ), table.numberColumn( yName ) )
.name( String.format( legendFormat, yName ) )
.text( table.stringColumn( PROJECT_NAME ).asObjectArray() )
.build();

final Trace traceWb = getTraceCyan( table, xName, y2Name );
final Trace traceWbp = getTraceMagenta( table, xName, y2Name );
final Trace traceVb = getTraceOrange( table, xName, y2Name );
final Trace traceVbe = getTraceRed( table, xName, y2Name );


return new Figure( layout
, trace
, traceWb, traceWbp, traceVb, traceVbe );
List<Trace> traces = new ArrayList<>( );
traces.add( getTraceCyan( table, xName, y2Name ) );
traces.add( getTraceMagenta( table, xName, y2Name ) );
traces.add( getTraceOrange( table, xName, y2Name ) );
traces.add( getTraceRed( table, xName, y2Name ) );
return new Figure( layout, traces.toArray(new Trace[]{}) );
}
// ========================================================================================
// ========================================================================================
Expand Down Expand Up @@ -665,41 +616,17 @@ public Figure fzkmDiff(){
return new Figure( layout, traces.toArray(new Trace[]{} ) );

}
public Figure fzkmFromTtime_vs_fzkmOrig(){
String xName = ADDTL_PKWKM_ORIG;

String y2Name = ADDTL_PKWKM_FROM_TTIME;
String yName = ADDTL_PKWKM_FROM_TTIME;

Axis xAxis = Axis.builder().title( xName ).build();

Axis yAxis = Axis.builder().title( y2Name ).build();

Layout layout = Layout.builder().xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build();

List<Trace> traces = new ArrayList<>();

traces.add( getTraceCyan( table, xName, y2Name ) );
traces.add( getTraceMagenta( table, xName, y2Name ) );
traces.add( getTraceOrange( table, xName, y2Name ) );
traces.add( getTraceRed( table, xName, y2Name ) );

return new Figure( layout, traces.toArray(new Trace[]{} ) );
}
public Figure fzkmFromTtimeSum_vs_fzkmOrig(){
String xName = ADDTL_PKWKM_ORIG;

final String ADDTL_PKWKM_FROM_TTIME_PLUS_ORIG = "additional pkwkm from ttime plus orig";

table.addColumns( table.numberColumn( ADDTL_PKWKM_FROM_TTIME ).add( table.numberColumn( ADDTL_PKWKM_ORIG ) ).setName( ADDTL_PKWKM_FROM_TTIME_PLUS_ORIG ) );

String y2Name = ADDTL_PKWKM_FROM_TTIME_PLUS_ORIG;
public Figure invCostTud(){
String y2Name = INVCOST_TUD;

Axis xAxis = Axis.builder().title( xName ).build();
Axis yAxis = Axis.builder().title( y2Name ).type( Axis.Type.LOG ).build();

Axis yAxis = Axis.builder().title( y2Name ).build();
String title = "";
if ( ADDTL_LANE_KM.equals( xName ) ){
title = "addtl_veh-km_diff are SIM addtl_lane-km:";
}

Layout layout = Layout.builder().xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build();
Layout layout = Layout.builder( title ).xAxis( xAxis ).yAxis( yAxis ).width( plotWidth ).build();

List<Trace> traces = new ArrayList<>();

Expand Down Expand Up @@ -728,7 +655,7 @@ static Trace getTraceRed( Table table, String xName, String y2Name ){
final Trace traceVbe = getTrace( xName, y2Name, tableVbe, nameInLegend, color );
return traceVbe;
}
private static Trace getTrace( String xName, String y2Name, Table tableVbe, String nameInLegend, String color ){
static Trace getTrace( String xName, String y2Name, Table tableVbe, String nameInLegend, String color ){
Trace traceVbe = ScatterTrace.builder( tableVbe.numberColumn( xName ), tableVbe.numberColumn( y2Name ) )
.text( tableVbe.stringColumn( PROJECT_NAME ).asObjectArray() )
.name( String.format( legendFormat, nameInLegend ) )
Expand Down
Loading

0 comments on commit cdb0434

Please sign in to comment.