MATSIM
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.pt.ReconstructingUmlaufBuilder Class Reference
Inheritance diagram for org.matsim.pt.ReconstructingUmlaufBuilder:
Inheritance graph
[legend]

Public Member Functions

 ReconstructingUmlaufBuilder (Scenario scenario)
 
Collection< Umlaufbuild ()
 

Private Member Functions

void createUmlaeufe ()
 
Id< UmlaufgetUmlaufIdForVehicleId (Id< Vehicle > vehId)
 
Id< UmlaufcreateUmlaufIdFromVehicle (Vehicle vehicle)
 
void createEmptyUmlaeufe ()
 
void createUmlaufStuecke ()
 
void printStatus (int cnt)
 

Private Attributes

final Collection< TransitLinetransitLines
 
final Vehicles vehicles
 
Map< Id< Umlauf >, Umlaufumlaeufe = null
 
ArrayList< UmlaufStueckumlaufStuecke
 
final UmlaufInterpolator umlaufInterpolator
 
final Map< Id< Vehicle >, Id< Umlauf > > umlaufIdsByVehicleId
 

Static Private Attributes

static final Logger log = LogManager.getLogger(ReconstructingUmlaufBuilder.class)
 
static final Comparator< UmlaufStueckdepartureTimeComparator
 

Detailed Description

Generates Umlaeufe (= vehicle runs) from the transit schedule. Will do something interesting only if Departures in the org.matsim.pt.transitSchedule.api.TransitSchedule have vehicle ids, and the same vehicle is used for multiple departures.

Author
(of documentation) kai

Definition at line 47 of file ReconstructingUmlaufBuilder.java.

Constructor & Destructor Documentation

◆ ReconstructingUmlaufBuilder()

org.matsim.pt.ReconstructingUmlaufBuilder.ReconstructingUmlaufBuilder ( Scenario  scenario)

Definition at line 66 of file ReconstructingUmlaufBuilder.java.

References org.matsim.api.core.v01.Scenario.getConfig(), org.matsim.api.core.v01.Scenario.getNetwork(), org.matsim.pt.transitSchedule.api.TransitSchedule.getTransitLines(), org.matsim.api.core.v01.Scenario.getTransitSchedule(), org.matsim.api.core.v01.Scenario.getTransitVehicles(), and org.matsim.core.config.Config.scoring().

66  {
67  // (normal constructor used from TransitQSimEngine for testing :-(. kai, mar'20) yy change
68 
69  this.umlaufInterpolator = new UmlaufInterpolator(scenario.getNetwork(), scenario.getConfig().scoring());
70  this.transitLines = scenario.getTransitSchedule().getTransitLines().values();
71  this.vehicles = scenario.getTransitVehicles();
72  this.umlaufIdsByVehicleId = new HashMap<>();
73  }
final Map< Id< Vehicle >, Id< Umlauf > > umlaufIdsByVehicleId
Here is the call graph for this function:

Member Function Documentation

◆ build()

Collection<Umlauf> org.matsim.pt.ReconstructingUmlaufBuilder.build ( )

◆ createUmlaeufe()

void org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaeufe ( )
private

(connect multiple umlautStuecke to one umlauf. will do anything interesting only if same vehicle is shared across multiple departures. vehicle id can be set for departures in transit schedule. but usually isn't)

Definition at line 88 of file ReconstructingUmlaufBuilder.java.

References org.matsim.pt.ReconstructingUmlaufBuilder.getUmlaufIdForVehicleId().

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.build().

88  {
89  int cnt = 0;
90  for (UmlaufStueck umlaufStueck : umlaufStuecke) {
91  Id<Umlauf> umlaufId = this.getUmlaufIdForVehicleId(umlaufStueck.getDeparture().getVehicleId());
92  if (umlaufId == null) {
93  throw new RuntimeException("UmlaufId could not be found. veh=" + umlaufStueck.getDeparture().getVehicleId());
94  }
95  Umlauf umlauf = umlaeufe.get(umlaufId);
96  if (umlauf == null) {
97  throw new RuntimeException("Umlauf could not be found: " + umlaufId);
98  }
99  umlaufInterpolator.addUmlaufStueckToUmlauf(umlaufStueck, umlauf);
100  cnt++;
101  printStatus(cnt);
102  }
103  }
void addUmlaufStueckToUmlauf(UmlaufStueckI umlaufStueck, Umlauf umlauf)
Id< Umlauf > getUmlaufIdForVehicleId(Id< Vehicle > vehId)
Here is the call graph for this function:

◆ getUmlaufIdForVehicleId()

Id<Umlauf> org.matsim.pt.ReconstructingUmlaufBuilder.getUmlaufIdForVehicleId ( Id< Vehicle vehId)
private

Definition at line 105 of file ReconstructingUmlaufBuilder.java.

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaeufe().

105  {
106  return this.umlaufIdsByVehicleId.get(vehId);
107  }
final Map< Id< Vehicle >, Id< Umlauf > > umlaufIdsByVehicleId

◆ createUmlaufIdFromVehicle()

Id<Umlauf> org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaufIdFromVehicle ( Vehicle  vehicle)
private

Definition at line 109 of file ReconstructingUmlaufBuilder.java.

References org.matsim.api.core.v01.Id< T >.create(), org.matsim.api.core.v01.Identifiable< T >.getId(), org.matsim.vehicles.VehicleType.getId(), and org.matsim.vehicles.Vehicle.getType().

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.createEmptyUmlaeufe().

109  {
110  Id<Umlauf> id = Id.create(vehicle.getId().toString() + "_" + vehicle.getType().getId().toString(), Umlauf.class);
111  this.umlaufIdsByVehicleId.put(vehicle.getId(), id);
112  return id;
113  }
final Map< Id< Vehicle >, Id< Umlauf > > umlaufIdsByVehicleId
Here is the call graph for this function:

◆ createEmptyUmlaeufe()

void org.matsim.pt.ReconstructingUmlaufBuilder.createEmptyUmlaeufe ( )
private

(create the data structures. each transit vehicles gets an empty umlauf)

Definition at line 118 of file ReconstructingUmlaufBuilder.java.

References org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaufIdFromVehicle(), org.matsim.pt.UmlaufImpl.getId(), org.matsim.vehicles.Vehicles.getVehicles(), and org.matsim.pt.UmlaufImpl.setVehicleId().

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.build().

118  {
119  for (Vehicle vehicle : vehicles.getVehicles().values()) {
120  UmlaufImpl umlauf = new UmlaufImpl(this.createUmlaufIdFromVehicle(vehicle));
121  umlauf.setVehicleId(vehicle.getId());
122  umlaeufe.put(umlauf.getId(), umlauf);
123  }
124  }
Map< Id< Vehicle >, Vehicle > getVehicles()
Here is the call graph for this function:

◆ createUmlaufStuecke()

void org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaufStuecke ( )
private

(one for each "departure" in the transit schedule. also sort them by departure time)

Definition at line 129 of file ReconstructingUmlaufBuilder.java.

References org.matsim.core.gbl.Gbl.assertNotNull(), and org.matsim.pt.ReconstructingUmlaufBuilder.printStatus().

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.build().

129  {
130  this.umlaufStuecke = new ArrayList<>();
131  log.info("Generating UmlaufStuecke ...");
132  int cnt = 0;
133  for (TransitLine line : transitLines) {
134  for (TransitRoute route : line.getRoutes().values()) {
135  Gbl.assertNotNull(route.getRoute()); // will fail much later if this is null. kai, may'17
136  for (Departure departure : route.getDepartures().values()) {
137  UmlaufStueck umlaufStueck = new UmlaufStueck(line, route, departure);
138  umlaufStuecke.add(umlaufStueck);
139  cnt++;
140  printStatus(cnt);
141  }
142  }
143  }
144  log.info("... done generating UmlaufStuecke");
145  Collections.sort(this.umlaufStuecke, departureTimeComparator);
146  }
static final Comparator< UmlaufStueck > departureTimeComparator
Here is the call graph for this function:

◆ printStatus()

void org.matsim.pt.ReconstructingUmlaufBuilder.printStatus ( int  cnt)
private

Definition at line 148 of file ReconstructingUmlaufBuilder.java.

Referenced by org.matsim.pt.ReconstructingUmlaufBuilder.createUmlaufStuecke().

148  {
149  if ( cnt%100==0 ) {
150  System.out.print('.');
151  System.out.flush();
152  }
153  if ( cnt%10000==0 ) {
154  System.out.println();
155  System.out.flush();
156  }
157  }

Member Data Documentation

◆ log

final Logger org.matsim.pt.ReconstructingUmlaufBuilder.log = LogManager.getLogger(ReconstructingUmlaufBuilder.class)
staticprivate

Definition at line 48 of file ReconstructingUmlaufBuilder.java.

◆ departureTimeComparator

final Comparator<UmlaufStueck> org.matsim.pt.ReconstructingUmlaufBuilder.departureTimeComparator
staticprivate
Initial value:
= new Comparator<UmlaufStueck>() {
@Override
public int compare(UmlaufStueck o1, UmlaufStueck o2) {
return Double.compare(o1.getDeparture().getDepartureTime(), o2.getDeparture().getDepartureTime());
}
}

Definition at line 50 of file ReconstructingUmlaufBuilder.java.

◆ transitLines

final Collection<TransitLine> org.matsim.pt.ReconstructingUmlaufBuilder.transitLines
private

Definition at line 59 of file ReconstructingUmlaufBuilder.java.

◆ vehicles

final Vehicles org.matsim.pt.ReconstructingUmlaufBuilder.vehicles
private

Definition at line 60 of file ReconstructingUmlaufBuilder.java.

◆ umlaeufe

Map<Id<Umlauf>,Umlauf> org.matsim.pt.ReconstructingUmlaufBuilder.umlaeufe = null
private

Definition at line 61 of file ReconstructingUmlaufBuilder.java.

◆ umlaufStuecke

ArrayList<UmlaufStueck> org.matsim.pt.ReconstructingUmlaufBuilder.umlaufStuecke
private

Definition at line 62 of file ReconstructingUmlaufBuilder.java.

◆ umlaufInterpolator

final UmlaufInterpolator org.matsim.pt.ReconstructingUmlaufBuilder.umlaufInterpolator
private

Definition at line 63 of file ReconstructingUmlaufBuilder.java.

◆ umlaufIdsByVehicleId

final Map<Id<Vehicle>, Id<Umlauf> > org.matsim.pt.ReconstructingUmlaufBuilder.umlaufIdsByVehicleId
private

Definition at line 64 of file ReconstructingUmlaufBuilder.java.


The documentation for this class was generated from the following file: