GithubHelp home page GithubHelp logo

matsim-org / matsim-libs Goto Github PK

View Code? Open in Web Editor NEW
462.0 58.0 436.0 1.43 GB

Multi-Agent Transport Simulation

Home Page: www.matsim.org

Java 99.27% Makefile 0.01% TeX 0.52% HTML 0.01% Shell 0.01% JavaScript 0.15% CSS 0.01% Python 0.05%
matsim transportation-planning simulation agent-based agent-based-simulation agent-based-model

matsim-libs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

matsim-libs's Issues

Have collector for network

So, when doing analysis or preparing scenarios I often filter networks with a shape or something similar. Since these shape operations are expensive it is convenient to use a parallelStream for this.

Now, when writing the result into a network I keep writing the following code snippet:

//filter network
var filteredNetwork = NetworkUtils.createNetwork();
network.getLinks().values().parallelStream()
    .filter(link -> boundingBox.covers(MGC.coord2Point(link.getFromNode().getCoord())))
    .forEach(link -> addLink(filteredNetwork, link));`

 private synchronized void addLink(Network network, Link link) {

    if (!network.getNodes().containsKey(link.getFromNode().getId())){
         network.addNode(link.getFromNode());
    }

    if (!network.getNodes().containsKey(link.getToNode().getId())) {
        network.addNode(link.getToNode());
    }

     network.addLink(link);
}

Solution: Implement a collector for Network in NetworkUtils. It could be used like this:

var filteredNetwork = network.getLinks().parallelStream()
    .filter(link -> // do stuff and return a link)
    .collect(NetworkUtils.getCollector());

DRT (DVRP) passenger's state is not set to abort

In DRT, a PassengerReqeuestRejectedEvent is thrown if no insertion could be found for a request (see DefaultUnplannedRequestInserter for an example).

The class PassengerRequestEventToPassengerEngineForwarder notifies the corresponding PassengerEngine about that event. Currently, the PassengerEngine has two ways to react, depending on whether the request was a prebooking request or not:

1.) if the request was a prebooking request, notify the PreplanningEngine
2.) else throw a PersonStuckEvent

Now here comes the problem (as i see it):

The state of the actual MobsimAgent never is set to ABORT.
In the QSim, the agent only is removed of the agent's state is set to ABORT.

That means: if (for whatever reason) no insertion can be found for a passenger, the qsim runs forever (if no end time was defined).

I know that in general, we want to avoid rejections in the first place. However, this seems to be a bug for me.. (and GL) .. !?

A possible solution would be that the PassengerEngine sets the MobsimAgent's state to ABORT. I will present this in a PR shortly.

Possible bug in InsertionCostCalculator of the DRT extension

Assume that we want to insert a new pickup p followed immediately by the corresponding dropoff d into an existing route between stops i and i+1. Then, the totalTimeLoss should be the travel time from stop i to p plus the time from p to d plus the time from d to stop i+1 minus the time from stop i to stop i+1.

The total time loss is the sum of the pickup detour time loss and the dropoff detour time loss. Therefore, we must subtract the travel time from stop i to stop i+1 from either the first or the latter. However, the current implementation subtracts it neither from the first nor the latter.

  private double calculatePickupDetourTimeLoss(DrtRequest drtRequest, VehicleData.Entry vEntry,
      InsertionWithDetourTimes insertion) {
    // Omitted code...
    double replacedDriveTT = pickupIdx == dropoffIdx // PICKUP->DROPOFF ?
        ? 0 // no drive following the pickup is replaced (only the one following the dropoff)
        : calculateReplacedDriveDuration(vEntry, pickupIdx);
    return toPickupTT + stopDuration + fromPickupTT - replacedDriveTT;
  }

  private double calculateDropoffDetourTimeLoss(DrtRequest drtRequest, VehicleData.Entry vEntry,
      InsertionWithDetourTimes insertion) {
    // Omitted code...
    double replacedDriveTT = dropoffIdx == pickupIdx // PICKUP->DROPOFF ?
        ? 0 // replacedDriveTT already taken into account in pickupDetourTimeLoss
        : calculateReplacedDriveDuration(vEntry, dropoffIdx);
    return toDropoffTT + stopDuration + fromDropoffTT - replacedDriveTT;
  }

The replaced drive time is set to zero in both methods. Although I am not entirely sure (as there are quite a few special cases), this seems like a bug to me. The comment in the second method suggests that the replaced drive time should be incorporated into the pickup detour time loss. The comment in the first method I do not understand.

catch links with costs <= 0 earlier in program flow

As we know, this leads to problems with routing. Unfortunately, this is non-deterministic, since the routers do not always explore all links systematically, and so in some run one may encounter the problem and in some other run not. Also, switching from one type of router (e.g. Dijkstra) to some other (e.g. landmarks) also changes the links that are explored.

There were also problems with multithreaded routing: matsim-org/matsim-code-examples#258 . Removing the above problem as source of errors would allow to concentrate on the multithreading issue.

Change Java version to 11

Chage Matsim's java version to 11.

This includes:

  • Change compilation target
  • Update some maven plugins which are not compatible with java 11
  • Update jenkins configuration, and install a suitable jdk

do not put matsim input files into src/main/resources

See https://matsim.atlassian.net/browse/MATSIM-717 .

After discussing between @mrieser and @kainagel , we came up with the following compromise:

Deprecate old Osm-Readers

I am confident, that the Osm-Reader in the osm-contrib works correctly now.

Deprecate:

  • OsmNetworkReader
  • BicycleOsmNetworkReader

EV custom run

Hi, I want to make a custom RunEvExample because I want to get every vehicle's (agent's) consumption , for example every 10 seconds. More particular, I want to get the battery's info , vehicle's made kilometers and charger's info. Does anyone know where I can get these values?
Thank you in advance

How to use multiMode drt with electric vehicles?

I managed to use the drt module in multiMode with regular vehicles and single mode with electric vehicles (with MATSIM 12.0-2020w21-SNAPSHOT, i.e. a7b313c). However, I have no success so far for multiMode with electric vehicles and it seems to me that this is not yet implemented.

I tried to create a controller with EDrtControlerCreator. However, this method fails because it enforces a single drt mode:

DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(config);

I then adapted the creator as follows:

diff --git a/contribs/drt/src/main/java/org/matsim/contrib/edrt/run/EDrtControlerCreator.java b/contribs/drt/src/main/java/org/matsim/contrib/edrt/run/EDrtControlerCreator.java
index 217472c79f..1291fac03a 100644
--- a/contribs/drt/src/main/java/org/matsim/contrib/edrt/run/EDrtControlerCreator.java
+++ b/contribs/drt/src/main/java/org/matsim/contrib/edrt/run/EDrtControlerCreator.java
@@ -18,10 +18,14 @@

package org.matsim.contrib.edrt.run;                                                                                                                                                                                                                                          
																																																															
+import java.util.List;                                                                                                                                                                                                                                                        
+import java.util.stream.Collectors;                                                                                                                                                                                                                                           
+                                                                                                                                                                                                                                                                              
import org.matsim.api.core.v01.Scenario;                                                                                                                                                                                                                                      
import org.matsim.contrib.drt.run.DrtConfigGroup;                                                                                                                                                                                                                             
import org.matsim.contrib.drt.run.DrtConfigs;                                                                                                                                                                                                                                 
import org.matsim.contrib.drt.run.DrtControlerCreator;                                                                                                                                                                                                                        
+import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;                                                                                                                                                                                                                    
import org.matsim.contrib.dvrp.run.DvrpModule;                                                                                                                                                                                                                                
import org.matsim.contrib.ev.EvModule;                                                                                                                                                                                                                                        
import org.matsim.contrib.ev.discharging.AuxDischargingHandler;                                                                                                                                                                                                               
@@ -40,8 +44,10 @@ import org.matsim.core.scenario.ScenarioUtils;                                                                                                                                                                                                              
public class EDrtControlerCreator {                                                                                                                                                                                                                                           
																																																															
		public static Controler createControler(Config config, boolean otfvis) {                                                                                                                                                                                               
-               DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(config);                                                                                                                                                                                         
-               DrtConfigs.adjustDrtConfig(drtCfg, config.planCalcScore(), config.plansCalcRoute());                                                                                                                                                                           
+//             DrtConfigGroup drtCfg = DrtConfigGroup.getSingleModeDrtConfig(config);                                                                                                                                                                                         
+//             DrtConfigs.adjustDrtConfig(drtCfg, config.planCalcScore(), config.plansCalcRoute());                                                                                                                                                                           
+               DrtConfigs.adjustMultiModeDrtConfig(MultiModeDrtConfigGroup.get(config), config.planCalcScore(), config.plansCalcRoute());                                                                                                                                     
+               List<String> drtModes = MultiModeDrtConfigGroup.get(config).modes().collect(Collectors.toList());                                                                                                                                                              

				Scenario scenario = DrtControlerCreator.createScenarioWithDrtRouteFactory(config);
				ScenarioUtils.loadScenario(scenario);
@@ -51,7 +57,8 @@ public class EDrtControlerCreator {
				controler.addOverridingModule(new DvrpModule());
				controler.addOverridingModule(new EvModule());
				controler.addOverridingModule(new EvDvrpIntegrationModule());
-               controler.addOverridingQSimModule(new EvDvrpFleetQSimModule(drtCfg.getMode()));
+//             controler.addOverridingQSimModule(new EvDvrpFleetQSimModule(drtCfg.getMode()));
+               drtModes.forEach(mode -> controler.addOverridingQSimModule(new EvDvrpFleetQSimModule(mode)));
				controler.addOverridingQSimModule(new AbstractQSimModule() {
						@Override
						protected void configureQSim() {
@@ -59,7 +66,8 @@ public class EDrtControlerCreator {
						}
				});

-               controler.configureQSimComponents(EvDvrpIntegrationModule.activateModes(drtCfg.getMode()));
+//             controler.configureQSimComponents(EvDvrpIntegrationModule.activateModes(drtCfg.getMode()));
+               drtModes.forEach(mode -> controler.configureQSimComponents(EvDvrpIntegrationModule.activateModes(mode)));

				if (otfvis) {
						controler.addOverridingModule(new OTFVisLiveModule());

But this still fails in EDrtVehicleDataEntryFactory, where again only single drt is allowed:

return new EDrtVehicleDataEntryFactory(DrtConfigGroup.getSingleModeDrtConfig(config), minimumRelativeSoc);

Also there is a problem with injecting this factory:

1) Could not find a suitable constructor in org.matsim.contrib.edrt.optimizer.EDrtVehicleDataEntryFactory$EDrtVehicleDataEntryFactoryProvider. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at org.matsim.contrib.edrt.optimizer.EDrtVehicleDataEntryFactory$EDrtVehicleDataEntryFactoryProvider.class(EDrtVehicleDataEntryFactory.java:1)
at org.matsim.contrib.dvrp.run.AbstractDvrpModeQSimModule.bindModal(AbstractDvrpModeQSimModule.java:61) (via modules: org.matsim.core.mobsim.qsim.QSimProvider$1 -> org.matsim.core.mobsim.qsim.AbstractQSimModule$1 -> com.google.inject.util.Modules$OverrideModule -> org.matsim.contrib.edrt.run.EDrtModeQSimModule)
while locating org.matsim.core.mobsim.qsim.QSimProvider
while locating org.matsim.core.mobsim.framework.Mobsim

What is the corrector way forward here?

Calculation of departure times in PlanRouter

I observed a potential problem in the PlanRouter when the departure times for the routing are calculated.

Assume the plan:

     Activity (end time 08:00)
     Leg (duration 00:05)
     Activity (end time 09:00)
     Leg (duration 00:05)
     Activity (end time 10:00, duration 00:10)
     Leg
     Activity

With a value for ActivityDurationInterpretation of tryEndTimeThenDuration the calculation is easy: The first leg starts at 08:00 and the second leg has departure time 09:00 and the third 10:00.

Now with minOfDurationAndEndTime wouldn't we expect the first departure time to be 08:00, the second 09:00, but the third one 09:15? As far I understand, this is how things are interpreted in the QSim and in the TimeMutator. However, PlanRouter uses a departure time of 10:00 here.

The reason is that it calls PlanRouter.calcEndOfActivity which has a "shortcut" in the beginning, which always returns the activity end time if it exists (which always needs to be the case if minOfDurationAndEndTime is used).

Or did I interpret wrongly what should happen here? I added a branch with a unit test that shows the current behaviour (PlanRouterTest):
https://github.com/matsim-org/matsim-libs/tree/plan-router-departure-times

Car Sharing Executable Jar File

Hi,
I am trying to run car sharing module in MATSim. Where can I download the executable jar file (extension package) of car sharing?

Drt interaction activities have arbitrary durations

Drt interaction activities seem to be of arbitrary duration. This only concerns drt interaction activities after getting off the vehicle (i.e. after the dropoff). The BusStop activity duration for the driver is fine, just as the activity duration of customer's the interaction activity before the leg.

I checked the following things:

  1. During routing before the sim, everything looks fine. The generated plans are consistent and do not show strange durations.
  2. The new ScheduleTimingUpdater also does not have anything to do with this

The problem occurs in a newly created equil test scenario as well as when running the examples in matsim-maas.

OTFVis clashes with new mac OS

When using OTFVis (with or without signals) the Java application terminates at the moment just before creating the OTFVis window (after the simulation started) with the following exception:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff3460a8ab __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6a6e2805 objc_exception_throw + 48
2 CoreFoundation 0x00007fff3463330c -[NSException raise] + 9
3 AppKit 0x00007fff31783538 -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 310
4 AppKit 0x00007fff3176aed5 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1416
5 AppKit 0x00007fff3176a947 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 42
6 libnativewindow_macosx.jnilib 0x0000000131da23fe Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 + 398
7 ??? 0x000000011bec0c90 0x0 + 4763421840
)
libc++abi.dylib: terminating with uncaught exception of type NSException

The simulation did not run properly. Error/Exit code: 134

The problem seems to lie in the fact that on new mac OS windows can only be generated out of the main thread. Does anybody know how to start OTFVis from the main thread?
Maybe @michaz or @Janekdererste ?

On Windows or older Mac versions this problem does not occur...

This problem is somehow urgent because it affects teaching...

Change Geotools repository URL

Please change the repository for Geotools in matsim/POM.xml lines 238-243:

<repository>
   <!-- Geotools is not on Maven central -->
   <id>osgeo</id>
   <name>Geotools repository</name>
   <url>http://download.osgeo.org/webdav/geotools</url>
</repository>

to

<repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
 </repository>

Yesterday it has been migrated.
http://geotoolsnews.blogspot.com/2020/04/change-to-maven-repositories.html

Cleanup and document tests in emissions contrib

During PR #960 we were not so happy with the existing tests for ColdEmissionsAnalysisModule and WarmEmissionsAnalysisModule.

This used to be one large test class, which had separate table entries for each test, but put them all into the same table. The result was difficult if not impossible to debug, and the resulting detailed table was inconsistent in the sense that it did not contain all combinations of entries. -- I have now pulled this apart into 6 different test classes, this one here plus "Case1" to "Case5". Things look ok, but given that the single class before was so large that I could not fully comprehend it, there may now be errors in the ripped-apart classes. Hopefully, over time, this will help to sort things out. kai, feb'20

Now it is time to cleanup a bit and document the different test cases.

Possible problem with Exception handling in ParallelEventsManagerImpl

As mentioned in PR #960 it seems to me that there is maybe a problem with the handling of thrown exceptions in ParallelEventsManagerImpl.

Unfortunately I have not the expertise with parallelization, so hopefully someone else can have a look at it and can help.

The problem is that an exception that is thrown sometimes leads to an abort of the simulation. Sometimes the simulation continuous, even if the exception is thrown.

This problem occurs on my laptop and on jenkins, travis as well.

I found this problem while writing an integration test for the online (-> during the simulation) calculation of emissions. The corresponding tests (in PR #960) RunDetailedEmissionToolOnlineExampleIT_vehTypeV1.java and RunDetailedEmissionToolOnlineExampleIT_vehTypeV2.java with expected exceptions are set to ignore for the time being.

Attached you can find the log files. Please note:

  • Failing: Expected exception did not lead to an abort. -> bad
  • Passing: Expected exception triggers an abort. -> good.

I added three screenshots from a comparing view of the - as far as I think - interesting part of both log files (passing . left; failing - right). The expected exception is thrown in both cases in line 3280. -> good!

On the left side it will lead to an BrokenBarrierException (line 3459). -> Sound ok for me, but don't know much about BrokenBarriers.
On the right side, the exception is written down, but iteration 0 will end and iteration 1 starts (line 3620 ff.). -> bad.

grafik
grafik
grafik

EmissionsOnlineIT_locally20200331_vehTypeV2-Failed.txt
EmissionsOnlineIT_locally20200331_vehTypeV2-Passes.txt

have access mode(s) definable for network routing

In pt routing (raptor), we already have that: one can define a set of possible access modes, such as walk and drt. It seems that we should have the same for network routing. To recall, "network routing" is a generalized approach which is used for all individual modes, such as car and bike, but also walk when done on the network.

Use cases for definable access modes are:

  • sbb said that they want to be able to differentiate, say, between (walk-)access-to-rail and (walk-)access-to-car.
  • @dziemke had a case where he wanted to parameterize car access to the primary road network without explicitly having to simulate residential streets.

In general, it seems that we would use the same approach as we are now using in the sbb raptor, which is that the access mode routers are taken from the TripRouter, i.e. they need to be defined explicitly, either as teleportation routers, or as something else.

There are two related questions:

  1. Do we want only one access mode per network mode, or possibly multiple access modes?
  2. Do we implement this in the config as comma-separated list, or using ParameterSet?

Comma-separated list would be easier to implement. However, it would give us only one access mode per network routing mode.

With ParameterSet, the question is what it would look like. Possibly something like this, to avoid a second hierarchy:

<parameterSet name="accessMode">
   <name="networkRoutingMode" value="car" />
   <name="accessEgressMode" value="walk" />
</parameterSet>
<parameterSet name="accessMode">
   <name="networkRoutingMode" value="car" />
   <name="accessEgressMode" value="bike" /> // second access mode for car
</parameterSet>
<parameterSet name="accessMode">
   <name="networkRoutingMode" value="bike" />
   <name="accessEgressMode" value="walk" /> // access mode for bicycle
</parameterSet>

Or rather:

<parameterSet type="networkRoutingConfig">
    <param name="networkRoutingMode" value="car">
    <param name="accessEgressModes" value="car_access_walk,eScooter" />
</parameterSet>
<parameterSet type="networkRoutingConfig">
    <param name="networkRoutingMode" value="bicycle">
    <param name="accessEgressModes" value="bicycle_access_walk" />
</parameterSet>

???

Any opinions?

Bug in the InsertionGenerator of the DRT extension

I think there might be bug in InsertionGenerator::generateDropoffInsertions. Consider a situation where we have an outgoing occupancy of 0 at stop 0 and an outgoing occupancy of "capacity" at stop 1. It is possible to transport a new passenger from stop 0 to stop 1, but the current implementation does not generate this candidate insertion.

deactivated CI builds on AppVeyor

Probably resulted from the change of the repo name to matsim-libs.

Could somebody with access to the repo settings re-enable the builds?

integrate signals reader into osm reader

The osm-network reader which respects signals is the last network reader which depends on the old xml-reader. Changing it to the pbf version would complete the osm-contrib for now.

  • It seems like the singal stuff needs the osm-reader to be inheritable (non final) (janek)
  • Pass Osm-Parser to Osm-Reader from Builder (janek)
  • Make Builder inheritable (janek)
  • create skeleton implementation of signals reader (janek)
  • create unit tests as spec (söhnke)
  • finalize implementation (söhnke)
  • add integration test (söhnke)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.