matsim-org / matsim-code-examples

A repository containing code examples around MATSim
GNU General Public License v3.0
83 stars 180 forks source link

Visualizing transit vehicles in VIA as car mode #686

Open mashrur93 opened 2 years ago

mashrur93 commented 2 years ago

Hi,

I was trying to visualize the transit vehicles to check if bus/tram was not teleported, as I declared those as main mode in qsim.

<module name="qsim" >

    <param name="startTime" value="00:00:00" />
    <param name="endTime" value="24:00:00" />
    <!-- <param name= "numberOfThreads" value= "3" /> -->
    <param name="flowCapacityFactor" value=".05" />
    <param name="storageCapacityFactor" value=".08" />
    <param name="mainMode" value="car,taxi,motorcycle,bus,tram" />
    <param name="linkDynamics" value="PassingQ" />
    <param name="trafficDynamics" value="kinematicWaves" />     

</module>

However, while visualizing the bus/tram vehicles, I saw bus/tram as car mode in via. I also saw the same issue in the pt-tutorial example file, where train vehicles were simulated as car mode. Is there a way to see the trasnit vehicle as it is (not as car mode in via). However, subway and rail were seen to be simulated as their respective type. it is to be noted that I declared subway and rail to have deterministic service in swissRailRaptor module.

pt_mode_issue pt_mode_issue_1

The following is the scenario of the matsim model:

I will highly appreciate any guidance in this regard. Thanks

Janekdererste commented 2 years ago

The userguide chapter 16 might be helpful for you.

The pt modes don't have to be declared as main modes. They are all handled as pt which has its own config section. This should be described in the userguide as well.

For some historical reason the network mode of pt vessels is changed to car within the mobism. This is why your pt-vehicles will have car as network mode in your visualization. It is possible to filter the pt-vehilces by driver id, which is usually pre-pended with pt_

mashrur93 commented 2 years ago

Thanks, @Janekdererste for the feedback. I have the following questions. I want to get a skim matrix for analyzing the event file. Therefore, with reference to the SwissRailRaptor, I used the following codes. But I am getting errors while loading the shapefiles. I have attached the config, shapefiles, and errors herewith.

queries:

  1. is the code ok?
  2. what does timesCar, earliestTime and earliestTime refer? I am assuming it refers to the time period for which skim matrics will be calculated, but no definitions were found in the swissRailRaptor contrib.
  3. is there any reference example to calculate skim matrics. I got one from matsim-sbb, but it did not run due to the error in the config.

I will highly appreciate any assistance in this regard.

public class skim_trial {

public static void main(String[] args) throws IOException {

    String zonesShapeFilename = "./input/SkimMatrics/zones/zones.shp";
    String zonesIdAttributeName = "gta06";
    String networkFilename = "./input/SkimMatrics/network.xml";
    String transitScheduleFilename = "./input/SkimMatrics/transitScedule.xml";
    String eventsFilename = "./input/SkimMatrics/events.xml.gz";
    String outputDirectory = "./input/SkimMatrics/output";

    Config config = ConfigUtils.loadConfig( "./input/SkimMatrics/config.xml" );

    int numberOfPointsPerZone = 1;
    int numberOfThreads = 2;
    double[] timesCar = {0, 2};
    double earliestTime = 0;
    double latestTime = 86399;

    Random r = new Random(4711);

    CalculateSkimMatrices skims = new CalculateSkimMatrices(outputDirectory, numberOfThreads);

    skims.calculateSamplingPointsPerZoneFromNetwork(networkFilename, numberOfPointsPerZone, zonesShapeFilename, zonesIdAttributeName, r);
           // as facilities file are not available
    skims.calculateNetworkMatrices(networkFilename, eventsFilename, timesCar, config, null, link -> true);
    skims.calculatePTMatrices(networkFilename, transitScheduleFilename, earliestTime, latestTime, config, null, (line, route) -> route.getTransportMode().equals("rail"));
    skims.calculateBeelineMatrix();
    skims.writeSamplingPointsToFile(new File(outputDirectory, CalculateSkimMatrices.ZONE_LOCATIONS_FILENAME));
}

} skimMatrics.zip

Janekdererste commented 2 years ago

So, I have never seen this kind of error before. I found a similar error here

I guess you have to search through your project for conflicting library versions.

Janekdererste commented 2 years ago

Unfortunately, I have never worked with this. And I also don't know, who has. I therefore can't tell, whether this will do what you want.

Janekdererste commented 2 years ago

Recently, this PR was done. Maybe tag some of those people https://github.com/matsim-org/matsim-libs/pull/1890#event-6126171201