eqasim-org / ile-de-france

An open synthetic population of Île-de-France for agent-based transport simulation
GNU General Public License v2.0
51 stars 71 forks source link

Error when running matsim's emission contrib #213

Closed syhwawa closed 3 months ago

syhwawa commented 9 months ago

Hi, we are attempting to run the MATSim emissions contribution for the Île-de-France region. We have successfully completed the full simulation and now wish to utilize certain classes from eqasim-java to compute emissions using the MATSim outputs.

However, we encountered an error related to a network consistency check, with the error message as follows

2024-02-07T10:18:10,284  INFO Counter:69 [VehiclesImpl] added vehicle # 8192
2024-02-07T10:18:11,680  INFO Injector:81 === printInjector start ===
2024-02-07T10:18:11,681  INFO Injector:85 org.matsim.api.core.v01.Scenario 
2024-02-07T10:18:11,682  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.scenario.MutableScenario@4d178d55}[Scopes.SINGLETON]
2024-02-07T10:18:11,682  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:65)
2024-02-07T10:18:11,683  INFO Injector:89   --> scope: eager singleton
2024-02-07T10:18:11,683  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.api.core.v01.Scenario, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:65), instance=org.matsim.core.scenario.MutableScenario@4d178d55}
2024-02-07T10:18:11,683  INFO Injector:96 
2024-02-07T10:18:11,683  INFO Injector:85 org.matsim.core.api.experimental.events.EventsManager 
2024-02-07T10:18:11,683  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.events.EventsManagerImpl@38c2c309}[Scopes.SINGLETON]
2024-02-07T10:18:11,683  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:66)
2024-02-07T10:18:11,684  INFO Injector:89   --> scope: eager singleton
2024-02-07T10:18:11,684  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.core.api.experimental.events.EventsManager, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:66), instance=org.matsim.core.events.EventsManagerImpl@38c2c309}
2024-02-07T10:18:11,684  INFO Injector:96 
2024-02-07T10:18:11,684  INFO Injector:85 org.matsim.contrib.emissions.EmissionModule 
2024-02-07T10:18:11,684  INFO Injector:86   --> provider: com.google.inject.internal.ConstructorBindingImpl$Factory@1a480135
2024-02-07T10:18:11,684  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:67)
2024-02-07T10:18:11,685  INFO Injector:89   --> scope: Scopes.NO_SCOPE
2024-02-07T10:18:11,685  INFO Injector:94   ==full==> ConstructorBinding{key=Key[type=org.matsim.contrib.emissions.EmissionModule, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:67), scope=Scopes.NO_SCOPE}
2024-02-07T10:18:11,685  INFO Injector:96 
2024-02-07T10:18:11,685  INFO Injector:99 === printInjector end ===
Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: RuntimeException: The Emission Contrib expects HbefaRoadTypes to be set as link attributes. Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.
  at EmissionModule.<init>(EmissionModule.java:63)
  while locating EmissionModule

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
EmissionModule:   "org.matsim.contrib.emissions.EmissionModule"
========================
End of classname legend:
========================

        at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1103)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1138)
        at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:72)
Caused by: java.lang.RuntimeException: The Emission Contrib expects HbefaRoadTypes to be set as link attributes. Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.
        at org.matsim.contrib.emissions.EmissionModule.checkNetworkConsistency(EmissionModule.java:155)
        at org.matsim.contrib.emissions.EmissionModule.<init>(EmissionModule.java:70)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$382201.GUICE$TRAMPOLINE(<generated>)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$382201.apply(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1100)
        ... 2 more

We believe the issue may be due to recent changes in the OSM network update for the IDF, which resulted in inconsistencies with the mapping function.

When I comment out this line

        if (hbfeaMap.get(type) == null) {
            // return null;
            throw new RuntimeException("'"+ type +"' not in hbefa map");
        }

The error message printed out some new road types are not in the hbefa map:

Exception in thread "main" java.lang.RuntimeException: 'pedestrian' not in hbefa map
        at org.eqasim.ile_de_france.emissions.OsmHbefaMapping.getHEBFAtype(OsmHbefaMapping.java:121)
        at org.eqasim.ile_de_france.emissions.OsmHbefaMapping.determineHebfaType(OsmHbefaMapping.java:92)
        at org.eqasim.ile_de_france.emissions.OsmHbefaMapping.addHbefaMappings(OsmHbefaMapping.java:60)
        at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:59)

We have incorporated these new road types into OsmHbefaMapping.java. However, when we reran the test, the same error occurred.

Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: RuntimeException: The Emission Contrib expects HbefaRoadTypes to be set as link attributes. Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.
  at EmissionModule.<init>(EmissionModule.java:63)
  while locating EmissionModule

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

Below is our HBEFA dataset, but we now think that the problem is not related to the HBEFA data. The header is the same as the one I found in this source (resolved github issue)

Much appreciate if you have any comments or ideas! @Nitnelav

Nitnelav commented 9 months ago

Mmmmm, yeah it looks weird. Can you share your modified OsmHbefaMapping.java ?

gac55 commented 9 months ago

Thanks!

@syhwawa will share :)

I'm wondering about turning off the link type functionality all together (speed and vehicle type being far more dominant factors)

Nitnelav commented 9 months ago

With some effort it is definitely possible. I'm not sure it is negligible though, as it includes the max speed and it is probably important. But it should be easy to verify by analyzing the HBEFA data with some python+pandas magic :)

syhwawa commented 9 months ago

Hi, thanks for your reply. This is the modified the OsmHbefaMapping.java.


package org.eqasim.ile_de_france.emissions;
// this is a modified copy of a private contribs.emissions class
// TODO: will need to be updated after the matsim 14 release to profit from https://github.com/matsim-org/matsim-libs/pull/1859

import java.util.HashMap;
import java.util.Map;

import org.matsim.api.core.v01.network.Link;

import com.google.inject.Provides;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.emissions.EmissionUtils;

/**
 * Created by molloyj on 01.12.2017.
 *
 *
 * handled OSM road types:
 *    motorway,trunk,primary,secondary, tertiary, unclassified,residential,service
 *    motorway_link, trunk_link,primary_link, secondary_link
 *    tertiary_link, living_street, pedestrian,track,road
 *
 * Hbefa categories and respective speeds
 *    URB/MW-Nat./80 - 130
 *    URB/MW-City/60 - 110
 *    URB/Trunk-Nat./70 - 110
 *    URB/Trunk-City/50 - 90
 *    URB/Distr/50 - 80
 *    URB/Local/50 - 60
 *    URB/Access/30 - 50
 *
 * Conversions from OSM to hbefa types
 *    motorway;MW
 *    primary;Trunk
 *    secondary;Distr
 *    tertiary;Local
 *    residential;Access
 *    living;Access
 */

public class OsmHbefaMapping {
    private static final int MAX_SPEED = 130;
    private static final String OSM_HIGHWAY_TAG = "osm:way:highway";
    Map<String, Hbefa> hbfeaMap = new HashMap<>();

    public static class Hbefa {
        String name;
        int min;
        int max;

        public Hbefa(String name, int min, int max) {
            this.name = name;
            this.min = min;
            this.max = max;
        }
    }

    public void addHbefaMappings(Network network) {
        for (Link link : network.getLinks().values()) {
            String hbefaString = determineHebfaType(link);
            if (hbefaString != null) {
                EmissionUtils.setHbefaRoadType(link, hbefaString);
            }
        }
    }

    @Provides
    public static OsmHbefaMapping build() {
        OsmHbefaMapping mapping = new OsmHbefaMapping();
        mapping.put("motorway-Nat.", new Hbefa("MW-Nat.",80,130));
        mapping.put("motorway", new Hbefa("MW-City",60,90));
        mapping.put("primary-Nat.", new Hbefa("Trunk-Nat.",80,110));
        mapping.put("primary", new Hbefa("Trunk-City",50,80));
        mapping.put("trunk", new Hbefa("Trunk-City",50,80));
        mapping.put("secondary", new Hbefa("Distr",50,80));
        mapping.put("tertiary", new Hbefa("Local",50,60));
        mapping.put("residential", new Hbefa("Access",30,50));
        mapping.put("service", new Hbefa("Access",30,50));
        mapping.put("living", new Hbefa("Access",30,50));
        mapping.put("pedestrian", new Hbefa("Access",30,50));
        mapping.put("footway", new Hbefa("Access",30,50));
        mapping.put("construction", new Hbefa("Access",30,50));
        mapping.put("busway", new Hbefa("Access",30,50));
        mapping.put("cycleway", new Hbefa("Access",30,50));

        return mapping;
    }

    private void put(String s, Hbefa hbefa) {
        hbfeaMap.put(s, hbefa);
    }

    public String determineHebfaType(Link link) {
        String roadType = (String) link.getAttributes().getAttribute(OSM_HIGHWAY_TAG);
        String hbefaType = null;
        if (roadType != null) {
            hbefaType = getHEBFAtype(roadType,link.getFreespeed());
        }
        return hbefaType;

    }

    private String getHEBFAtype(String roadType, double freeVelocity) {

        String[] ss = roadType.split("_"); //want to remove
        String type = ss[0];

        //TODO: could make distinction between national and city, based on shapefile, or regions.
        double freeVelocity_kmh = freeVelocity * 3.6;

        if (type.equals("unclassified") || type.equals("road")) {
            if (freeVelocity_kmh <= 50) type = "living";
            else if (freeVelocity_kmh == 60) type = "tertiary";
            else if (freeVelocity_kmh == 70) type = "secondary";
            else if (freeVelocity_kmh <= 90) type = "primary";
            else type = "motorway";
        }

        //specify that if speed > 90 and primary or motorway, then Nat.
        if (type.equals("motorway") || type.equals("primary") && freeVelocity_kmh >= 90) {
            type += "-Nat.";
        }
        if (hbfeaMap.get(type) == null) {
            // return null;
            throw new RuntimeException("'"+ type +"' not in hbefa map");
        }
        int min_speed = hbfeaMap.get(type).min;
        int max_speed = hbfeaMap.get(type).max;
        int capped_speed = (int) Math.min(Math.max(min_speed, freeVelocity_kmh), max_speed);

        return "URB/" + hbfeaMap.get(type).name + "/" + capped_speed;

    }

}

This is the missing road type in the network we have added:

 mapping.put("pedestrian", new Hbefa("Access",30,50));
        mapping.put("footway", new Hbefa("Access",30,50));
        mapping.put("construction", new Hbefa("Access",30,50));
        mapping.put("busway", new Hbefa("Access",30,50));
        mapping.put("cycleway", new Hbefa("Access",30,50));
Nitnelav commented 9 months ago

Ok looks good to me, with your current code, all links should have a call to EmissionUtils.setHbefaRoadType(link, hbefaString); ... Going back to the error, it come from here : https://github.com/matsim-org/matsim-libs/blob/4c4b8c144080d52258489f26a2a8fe3a693243ca/contribs/emissions/src/main/java/org/matsim/contrib/emissions/EmissionModule.java#L155

so

private void checkNetworkConsistency() {
  var allMatch = scenario.getNetwork().getLinks().values().parallelStream()
                .map(link -> link.getAttributes().getAttribute(EmissionUtils.HBEFA_ROAD_TYPE))
                .allMatch(roadType -> roadType instanceof String);
  if (!allMatch)
    throw new RuntimeException("The Emission Contrib expects HbefaRoadTypes to be set as link attributes. " +
                    "Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. " +
                    "Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.");
}

Can you find the links where the EmissionUtils.HBEFA_ROAD_TYPE attribute (the "hbefa_road_type" attribute) doesn't exist or is not a string ?

That would give us a hint I think.

Nitnelav commented 9 months ago

In the mean time, try to add this to your RunComputeEmissionsEvent.java arround line 58, 59:

        OsmHbefaMapping osmHbefaMapping = OsmHbefaMapping.build();
        Network network = scenario.getNetwork();
        // if the network is from pt2matsim it might not have "type" but "osm:way:highway" attribute instead
        for (Link link: network.getLinks().values()) {
            String roadTypeAttribute = NetworkUtils.getType(link);
            String osmRoadTypeAttribute = (String) link.getAttributes().getAttribute("osm:way:highway");
            if (StringUtils.isBlank(roadTypeAttribute)) {
                if (!StringUtils.isBlank(osmRoadTypeAttribute)) {
                    NetworkUtils.setType(link, osmRoadTypeAttribute);
                }
                else { // not a road (railway for example)
                    NetworkUtils.setType(link, "unclassified");
                }
            }
            // '_link' types are not defined in the OSM mapping, set t undefined
            if (NetworkUtils.getType(link).contains("_link")) {
                NetworkUtils.setType(link, "unclassified");
            }
            if (NetworkUtils.getType(link).equals("living_street")) {
                NetworkUtils.setType(link, "living");
            }
        }
        osmHbefaMapping.addHbefaMappings(network);
syhwawa commented 9 months ago

Thanks for your reply. @Nitnelav

Yes, I believe the error was due to the network side.

When I checked the network file ile_de_france_network.xml.gz which was creared after the IDF simulation pipeline, I couldn't find the hbefa_road_type attribute.

This attribute should be created after running the simulation pipeline? I found the example network file in matsim-lib has this attribute in network(link).

Do you think it could relate the OSM data update for IDF in this PR?

Nitnelav commented 9 months ago

Ah yes the attribute is created in memory but is never written to a file, you need to export the network with a NetworkWriter or something like that, after the osmHbefaMapping.addHbefaMappings(network);

syhwawa commented 9 months ago

In the mean time, try to add this to your RunComputeEmissionsEvent.java arround line 58, 59:

        OsmHbefaMapping osmHbefaMapping = OsmHbefaMapping.build();
        Network network = scenario.getNetwork();
        // if the network is from pt2matsim it might not have "type" but "osm:way:highway" attribute instead
        for (Link link: network.getLinks().values()) {
            String roadTypeAttribute = NetworkUtils.getType(link);
            String osmRoadTypeAttribute = (String) link.getAttributes().getAttribute("osm:way:highway");
            if (StringUtils.isBlank(roadTypeAttribute)) {
                if (!StringUtils.isBlank(osmRoadTypeAttribute)) {
                    NetworkUtils.setType(link, osmRoadTypeAttribute);
                }
                else { // not a road (railway for example)
                    NetworkUtils.setType(link, "unclassified");
                }
            }
            // '_link' types are not defined in the OSM mapping, set t undefined
            if (NetworkUtils.getType(link).contains("_link")) {
                NetworkUtils.setType(link, "unclassified");
            }
            if (NetworkUtils.getType(link).equals("living_street")) {
                NetworkUtils.setType(link, "living");
            }
        }
        osmHbefaMapping.addHbefaMappings(network);

Hi, I gave a try by adding these codes but still encountered the same error:

2024-02-08T15:54:02,549  INFO Counter:69 [VehiclesImpl] added vehicle # 2048
2024-02-08T15:54:02,574  INFO Counter:69 [VehiclesImpl] added vehicle # 4096
2024-02-08T15:54:02,624  INFO Counter:69 [VehiclesImpl] added vehicle # 8192
2024-02-08T15:54:04,485  INFO Injector:81 === printInjector start ===
2024-02-08T15:54:04,486  INFO Injector:85 org.matsim.api.core.v01.Scenario 
2024-02-08T15:54:04,487  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.scenario.MutableScenario@64355120}[Scopes.SINGLETON]
2024-02-08T15:54:04,487  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:88)
2024-02-08T15:54:04,487  INFO Injector:89   --> scope: eager singleton
2024-02-08T15:54:04,487  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.api.core.v01.Scenario, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:88), instance=org.matsim.core.scenario.MutableScenario@64355120}
2024-02-08T15:54:04,487  INFO Injector:96 
2024-02-08T15:54:04,488  INFO Injector:85 org.matsim.core.api.experimental.events.EventsManager 
2024-02-08T15:54:04,488  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.events.EventsManagerImpl@64b7225f}[Scopes.SINGLETON]
2024-02-08T15:54:04,488  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:89)
2024-02-08T15:54:04,488  INFO Injector:89   --> scope: eager singleton
2024-02-08T15:54:04,488  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.core.api.experimental.events.EventsManager, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:89), instance=org.matsim.core.events.EventsManagerImpl@64b7225f}
2024-02-08T15:54:04,488  INFO Injector:96 
2024-02-08T15:54:04,488  INFO Injector:85 org.matsim.contrib.emissions.EmissionModule 
2024-02-08T15:54:04,489  INFO Injector:86   --> provider: com.google.inject.internal.ConstructorBindingImpl$Factory@33db72bd
2024-02-08T15:54:04,489  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:90)
2024-02-08T15:54:04,489  INFO Injector:89   --> scope: Scopes.NO_SCOPE
2024-02-08T15:54:04,489  INFO Injector:94   ==full==> ConstructorBinding{key=Key[type=org.matsim.contrib.emissions.EmissionModule, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:90), scope=Scopes.NO_SCOPE}
2024-02-08T15:54:04,489  INFO Injector:96 
2024-02-08T15:54:04,489  INFO Injector:99 === printInjector end ===
Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: RuntimeException: The Emission Contrib expects HbefaRoadTypes to be set as link attributes. Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.
  at EmissionModule.<init>(EmissionModule.java:63)
  while locating EmissionModule

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
EmissionModule:   "org.matsim.contrib.emissions.EmissionModule"
========================
End of classname legend:
========================

        at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1103)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1138)
        at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:95)
Caused by: java.lang.RuntimeException: The Emission Contrib expects HbefaRoadTypes to be set as link attributes. Use EmissionUtils.setHbefaRoadType(link, type) to set HbefaRoadTypes on each link. Alternatively use an existing mapper such as OsmHbefaMapping, VisumHbefaRoadTypeMapping or VspHbefaRoadTypeMapping to set HbefaRoadTypes on your network.
        at org.matsim.contrib.emissions.EmissionModule.checkNetworkConsistency(EmissionModule.java:155)
        at org.matsim.contrib.emissions.EmissionModule.<init>(EmissionModule.java:70)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$722123.GUICE$TRAMPOLINE(<generated>)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$722123.apply(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1100)
        ... 2 more

Here is my submitting command:

java -Xmx16G -cp /mnt/efs/eqasim-java/ile_de_france/target/ile_de_france-1.3.1.jar:/mnt/efs/ile-de-france/output_vehicles/ile_de_france_run.jar: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents --config-path /mnt/efs/ile-de-france/output_vehicles/ile_de_france_config.xml --hbefa-cold-avg /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/EFA_ColdStart_Vehcat_2015_Cold_Avergae.csv --hbefa-hot-avg /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/EFA_HOT_Vehcat_2015_Hot_Average.csv --hbefa-cold-detailed /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/EFA_ColdStart_Subsegm_2015_Cold_Detailed.csv --hbefa-hot-detailed /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/Combined_EFA_HOT_Subsegm_2015_Hot_Detialed.csv

/mnt/efs/eqasim-java/ile_de_france/target/ile_de_france-1.3.1.jar is the one we made changes to the code. /mnt/efs/ile-de-france/output_vehicles/ile_de_france_run.jar is the original jar file which was created during the eqasim-IDF simulation pipeline

syhwawa commented 9 months ago

Ah yes the attribute is created in memory but is never written to a file, you need to export the network with a NetworkWriter or something like that, after the osmHbefaMapping.addHbefaMappings(network);

Hey @Nitnelav , I gave a try to add NetworkWriter before theosmHbefaMapping.addHbefaMappings(network), the code I added below:


        osmHbefaMapping.addHbefaMappings(network);

        String networkOutputFile = scenario.getConfig().controler().getOutputDirectory() + "output_network_with_emissions_test.xml";
        NetworkWriter networkWriter = new NetworkWriter(network);
        networkWriter.write(networkOutputFile);

It failed with the same error as expected and it does output a network file. The exported the networ has the attribute for the hbefa_road_type.


    <links capperiod="01:00:00" effectivecellsize="7.5" effectivelanewidth="3.75">
        <link id="1" from="1174895929" to="1174895898" length="136.97395144641263" freespeed="8.333333333333334" capacity="600.0" permlanes="1.0" oneway="1" modes="car,car_passenger" >
            <attributes>
                <attribute name="hbefa_road_type" class="java.lang.String">URB/Access/30</attribute>
                <attribute name="osm:way:highway" class="java.lang.String">residential</attribute>
                <attribute name="osm:way:id" class="java.lang.Long">101767911</attribute>
                <attribute name="osm:way:name" class="java.lang.String">Rue Jean de la Chaize</attribute>
                <attribute name="type" class="java.lang.String">residential</attribute>
            </attributes>
        </link>
Nitnelav commented 9 months ago

Ok perfect, can you find the links where the attribute is missing ?

syhwawa commented 9 months ago

Yeah, I can see from the created network, a lot of links miss the hbefa_road_type attributes. @Nitnelav

Is it because the method used to add hbefa_road_type attributes might have been designed or configured to only process certain types of links? I have attached an example below:

<link id="pt_IDFM:8963" from="pt_IDFM:8963" to="pt_IDFM:8963" length="85.0" freespeed="Infinity" capacity="9999.0" permlanes="1.0" oneway="1" modes="artificial,stopFacilityLink,bus" >
            <attributes>
                <attribute name="type" class="java.lang.String">unclassified</attribute>
            </attributes>
        </link>
        <link id="pt_IDFM:8963_374554" from="pt_IDFM:8963" to="1206327421" length="436.8431952802874" freespeed="Infinity" capacity="9999.0" permlanes="1.0" oneway="1" modes="bus,artificial" >
            <attributes>
                <attribute name="type" class="java.lang.String">unclassified</attribute>
            </attributes>
        </link>
        <link id="pt_IDFM:9312" from="pt_IDFM:9312" to="pt_IDFM:9312" length="20.0" freespeed="20.0" capacity="9999.0" permlanes="1.0" oneway="1" modes="artificial,stopFacilityLink,bus" >
            <attributes>
                <attribute name="type" class="java.lang.String">unclassified</attribute>
            </attributes>
        </link>
Nitnelav commented 9 months ago

mmm still weird, those links are here from the beginning and they never raised any issues...

did you update the dependencies to Matsim 15 at some point ?

You can try using the code from the matsim repo https://github.com/matsim-org/matsim-libs/blob/master/contribs/emissions/src/main/java/org/matsim/contrib/emissions/OsmHbefaMapping.java

syhwawa commented 9 months ago

Hi @Nitnelav, thanks for your advice. I believe we are on the matsim version 14.0.

We have replaced the osm:way:highway to type in the script and now the hbefa_road_type attribute can be successfully applied to the all of the links.

Here is the latest error that we met:

2024-02-14T09:36:14,958  INFO Counter:69 [VehiclesImpl] added vehicle # 1024
2024-02-14T09:36:14,983  INFO Counter:69 [VehiclesImpl] added vehicle # 2048
2024-02-14T09:36:15,031  INFO Counter:69 [VehiclesImpl] added vehicle # 4096
2024-02-14T09:36:15,127  INFO Counter:69 [VehiclesImpl] added vehicle # 8192
2024-02-14T09:36:23,122  INFO Injector:81 === printInjector start ===
2024-02-14T09:36:23,123  INFO Injector:85 org.matsim.api.core.v01.Scenario 
2024-02-14T09:36:23,124  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.scenario.MutableScenario@6601cc93}[Scopes.SINGLETON]
2024-02-14T09:36:23,124  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:93)
2024-02-14T09:36:23,124  INFO Injector:89   --> scope: eager singleton
2024-02-14T09:36:23,125  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.api.core.v01.Scenario, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:93), instance=org.matsim.core.scenario.MutableScenario@6601cc93}
2024-02-14T09:36:23,125  INFO Injector:96 
2024-02-14T09:36:23,125  INFO Injector:85 org.matsim.core.api.experimental.events.EventsManager 
2024-02-14T09:36:23,125  INFO Injector:86   --> provider: ConstantFactory{value=org.matsim.core.events.EventsManagerImpl@54d901aa}[Scopes.SINGLETON]
2024-02-14T09:36:23,125  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:94)
2024-02-14T09:36:23,125  INFO Injector:89   --> scope: eager singleton
2024-02-14T09:36:23,125  INFO Injector:94   ==full==> InstanceBinding{key=Key[type=org.matsim.core.api.experimental.events.EventsManager, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:94), instance=org.matsim.core.events.EventsManagerImpl@54d901aa}
2024-02-14T09:36:23,125  INFO Injector:96 
2024-02-14T09:36:23,126  INFO Injector:85 org.matsim.contrib.emissions.EmissionModule 
2024-02-14T09:36:23,126  INFO Injector:86   --> provider: com.google.inject.internal.ConstructorBindingImpl$Factory@63716833
2024-02-14T09:36:23,126  INFO Injector:87   --> source: org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:95)
2024-02-14T09:36:23,126  INFO Injector:89   --> scope: Scopes.NO_SCOPE
2024-02-14T09:36:23,126  INFO Injector:94   ==full==> ConstructorBinding{key=Key[type=org.matsim.contrib.emissions.EmissionModule, annotation=[none]], source=org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents$1.install(RunComputeEmissionsEvents.java:95), scope=Scopes.NO_SCOPE}
2024-02-14T09:36:23,126  INFO Injector:96 
2024-02-14T09:36:23,126  INFO Injector:99 === printInjector end ===
2024-02-14T09:36:23,231  INFO EmissionModule:161 entering createLookupTables
Exception in thread "main" com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
  at EmissionModule.<init>(EmissionModule.java:63)
  while locating EmissionModule

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
EmissionModule:                 "org.matsim.contrib.emissions.EmissionModule"
========================
End of classname legend:
========================

        at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1103)
        at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1138)
        at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:100)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
        at org.matsim.contrib.emissions.HbefaTables.mapAmbientCondPattern2ParkingTime(HbefaTables.java:140)
        at org.matsim.contrib.emissions.HbefaTables.createColdKey(HbefaTables.java:101)
        at org.matsim.contrib.emissions.HbefaTables.load(HbefaTables.java:78)
        at org.matsim.contrib.emissions.HbefaTables.loadAverageCold(HbefaTables.java:59)
        at org.matsim.contrib.emissions.EmissionModule.createLookupTables(EmissionModule.java:164)
        at org.matsim.contrib.emissions.EmissionModule.<init>(EmissionModule.java:72)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$765239.GUICE$TRAMPOLINE(<generated>)
        at org.matsim.contrib.emissions.EmissionModule$$FastClassByGuice$$765239.apply(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:82)
        at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
        at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
        at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:296)
        at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1100)
        ... 2 more

We are thinking the error is due to the format of our HBEFA dataset. The error was induced by AmbientCondPattern column in the HBEFA dataset from this line of the scipt .

The values we have in the AmbientCondPattern don't make sense to us with the rest of the code in mapAmbientCondPattern2ParkingTime

Here are the top five rows of one of the HBEFA inputs

Hot_avg['AmbientCondPattern']

0        Ø/France - Avg
1        Ø/France - Avg
2        Ø/France - Avg
3        Ø/France - Avg
4        Ø/France - Avg
              ...      
50365               NaN
50366               NaN
50367               NaN
50368               NaN
50369               NaN

According to our understanding, the value Ø/France - Avg for the AmbientCondPattern , since it there’s no comma to split(code), it will lead to the ArrayIndexOutOfBoundsException error that we met.

I have pasted the HBEFA dataset format what we got:

EFA_ColdStart_Vehcat_2015_Cold_Avergae.csv 
Case;VehCat;Year;TrafficScenario;Component;RoadCat;AmbientCondPattern;EFA_weighted;EFA_km_weighted;EFA_WTT_weighted;EFA_WTT_km_weighted;EFA_WTW_weighted;EFA_WTW_km_weighted
2015_Cold_Avergae[4.2.2];pass. car;2015;REF F HB42;HC;Urban;Ø/France - Avg;0.575411737;;;;;

EFA_HOT_Vehcat_2015_Hot_Average.csv 
Case;VehCat;Year;TrafficScenario;Component;RoadCat;TrafficSit;Gradient;V_weighted;EFA_weighted;AmbientCondPattern;EFA_WTT_weighted;EFA_WTW_weighted
2015_Hot_Average[4.2.2];pass. car;2015;REF F HB42;HC;Rural;RUR/Trunk/110/Freeflow;0%;106.9810333;0.015037361;Ø/France - Avg;;

EFA_ColdStart_Subsegm_2015_Cold_Detailed.csv
Case;VehCat;Year;TrafficScenario;Component;RoadCat;AmbientCondPattern;IDSubsegment;Subsegment;Technology;SizeClasse;EmConcept;KM;%OfSubsegment;EFA;EFA_weighted;EFA_km;EFA_km_weighted;EFA_WTT;EFA_WTT_km;EFA_WTW;EFA_WTW_km
2015_Cold_Detailed[4.2.2];pass. car;2015;REF F HB42;CO2(rep);Urban;"T+0°C,3-4h,0-1km";121930;PC diesel Euro-3;diesel;not specified;PC D Euro-3;206647.8125;0.121785104;14.23684025;17.19615173;;;;;;

EFA_HOT_Subsegm_2015_Hot_Detialed.csv
Case;VehCat;Year;TrafficScenario;Component;RoadCat;TrafficSit;Gradient;IDSubsegment;Subsegment;Technology;SizeClasse;EmConcept;KM;%OfSubsegment;V;V_0%;V_100%;EFA;EFA_0%;EFA_100%;V_weighted;V_weighted_0%;V_weighted_100%;EFA_weighted;EFA_weighted_0%;EFA_weighted_100%;AmbientCondPattern;EFA_WTT;EFA_WTT_0%;EFA_WTT_100%;EFA_WTW;EFA_WTW_0%;EFA_WTW_100%
2015_Hot_Detialed_PC[4.2.2];pass. car;2015;REF F HB42;HC;MW;RUR/MW/80/Freeflow;0%;111903;PC petrol ECE-15'03;petrol (4S);not specified;PC P Euro-0;212826.03125;7.67882811487652e-05;82.8160705566406;;;1.03542721271515;;;82.8160934448242;;;0.0141017716377974;;;Ø/France - Avg;;;;;;

I have also attached the images when we required the HBEFA data: EFA_ColdStart_Subsegm_2015_Cold_Detailed EFA_ColdStart_Vehcat_2015_Cold_Average_Parameter EFA_HOT_Subsegm_2015_Hot_Detailed_Bus_UBus_MC EFA_HOT_Subsegm_2015_Hot_Detailed_PC EFA_HOT_Vehcat_2015_Hot_Average_Parameter

Could you @Nitnelav @neda-git please let us know if our hbefa csv files are like your working dataset or you can see anything weird?

Or maybe if you did some post-processing on the HBEFA data to make them compatible with the code?

Much appreciate your help and time in advance!

Nitnelav commented 9 months ago

Ok I don't know, at this point I would use the debugger and start placing breakpoints everywhere.

I know I did not post process the HBEFA data that's for sure.

For the rest it is too much guesswork here. It is tedious to debug a situation through a gihub issues :)

Nitnelav commented 9 months ago

Also, Why did you separate the Passager car from the rest in the detailed export ?

Nitnelav commented 9 months ago

You can find my file headers here : https://github.com/eqasim-org/ile-de-france/issues/159#issuecomment-1456265962 And my export parameters here : https://github.com/eqasim-org/ile-de-france/issues/159#issuecomment-1456470427

syhwawa commented 9 months ago

Also, Why did you separate the Passager car from the rest in the detailed export ?

Thanks for your reply. @Nitnelav, Yeah. My colleague helped us to prepare the HBEFA dataset since he had the licence, when he prepared the detailed hot emissions factors in the format of all of the combinations, the outputs were too huge to export so he divided it into two separate files. And I combined these two datasets into one later.

I believe it doesn't matter if HBEFA data were extracted as xlsx format and then converted to the csv or directly exported as csv format.

You can find my file headers here : https://github.com/eqasim-org/ile-de-france/issues/159#issuecomment-1456265962 And my export parameters here : https://github.com/eqasim-org/ile-de-france/issues/159#issuecomment-1456470427

Thanks for the sharing links.

I have compared the header of each table that we had are same compared to the outputs you posted https://github.com/eqasim-org/ile-de-france/issues/159#issuecomment-1456265962

In terms of the parameters, I am wondering if these extra pollutants in the components part that we required from HBEFA led to the issue.

syhwawa commented 9 months ago

Hey @Nitnelav, could you please let me know that did you run the emission contribs based on the "actual" matsim outputs instead of test outputs after running the IDF simulation pipelines?

I found the it needs the read the output_events.xml.gz file which is not the default output files after we ran the IDF simulation pipeline.

The IDF documentation describe after running, you should find the MATSim scenario files in the output folder which doesn't include the any output event file.

Nitnelav commented 9 months ago

Yes I did run it on actual Matsim scenarios, one in Nantes and one in Lyon. The output_events.xml.gz should appear in the simulation_output folder after running the MATSim simulation.

You know you need to launch the Matsim simulation after the Eqasim generated the files right ? https://github.com/eqasim-org/ile-de-france/blob/fb1112d2a7d1817746be84413da584c391059ad1/docs/simulation.md?plain=1#L86C1-L94C33

syhwawa commented 9 months ago

@Nitnelav Thanks for your reply.

We have tried to use actual IDF simulation outputs to test the emission contribs.

I believe the tool can actually run some emission analysis now from what I can tell via the latest error message below:


2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:351 will try it with '<technology>; average; average'
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:352  This message given only once.
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:353  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:365 That also did not work.
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:366 Now trying with setting to vehicle attributes to "average; average; average" and try it with the average table
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:367  This message given only once.
2024-02-16T14:29:07,492  WARN ColdEmissionAnalysisModule:368  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:317 try reading detailed values
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:318  This message given only once.
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:319  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:328 try to rewrite from HBEFA3 to HBEFA4 and lookup in detailed table again
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:329  This message given only once.
2024-02-16T14:29:07,493  INFO ColdEmissionAnalysisModule:330  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,493  WARN ColdEmissionAnalysisModule:349 did not find emission factor for efkey=PASSENGER_CAR; CO; 13; 1; petrol (4S); >=2L; PC petrol (4S) Euro-4
2024-02-16T14:29:07,493  WARN ColdEmissionAnalysisModule:350  re-written to PASSENGER_CAR; CO; 13; 1; petrol (4S); average; average
2024-02-16T14:29:07,493  WARN ColdEmissionAnalysisModule:351 will try it with '<technology>; average; average'
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:352  This message given only once.
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:353  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:365 That also did not work.
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:366 Now trying with setting to vehicle attributes to "average; average; average" and try it with the average table
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:367  This message given only once.
2024-02-16T14:29:07,494  WARN ColdEmissionAnalysisModule:368  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,495  INFO WarmEmissionHandler:157 Vehicle 2680945 is ending its first activity of the day and leaving link 86272 without having entered.
2024-02-16T14:29:07,495  INFO WarmEmissionHandler:158 This is because of the MATSim logic that there is no link enter event for the link of the first activity
2024-02-16T14:29:07,496  INFO WarmEmissionHandler:159 Thus, no emissions are calculated for this link leave event.
2024-02-16T14:29:07,496  INFO VehicleUtils:340 vehicleId=2680945 not in allVehicles; trying standard vehicles container ...
2024-02-16T14:29:07,496  INFO VehicleUtils:340 vehicleId=2680945 not in allVehicles; trying standard vehicles container ...
2024-02-16T14:29:07,496  INFO WarmEmissionAnalysisModule:461 try reading detailed values
2024-02-16T14:29:07,496  INFO WarmEmissionAnalysisModule:462  This message given only once.
2024-02-16T14:29:07,496  INFO WarmEmissionAnalysisModule:463  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,497  INFO WarmEmissionAnalysisModule:472 try to rewrite from HBEFA3 to HBEFA4 and lookup in detailed table again
2024-02-16T14:29:07,497  INFO WarmEmissionAnalysisModule:473  This message given only once.
2024-02-16T14:29:07,497  INFO WarmEmissionAnalysisModule:474  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,501  WARN WarmEmissionAnalysisModule:493 did not find emission factor for efkey=PASSENGER_CAR; NOx; URB/Access/30; SATURATED; petrol (4S); >=2L; PC petrol (4S) Euro-4
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:494  re-written to PASSENGER_CAR; NOx; URB/Access/30; SATURATED; petrol (4S); average; average
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:495 will try it with '<technology>; average; average'
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:496  This message given only once.
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:497  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:509 That also did not work.
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:510 Now trying with setting to vehicle attributes to "average; average; average" and try it with the average table
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:511  This message given only once.
2024-02-16T14:29:07,502  WARN WarmEmissionAnalysisModule:512  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,503  INFO WarmEmissionAnalysisModule:461 try reading detailed values
2024-02-16T14:29:07,503  INFO WarmEmissionAnalysisModule:462  This message given only once.
2024-02-16T14:29:07,503  INFO WarmEmissionAnalysisModule:463  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,503  INFO WarmEmissionAnalysisModule:472 try to rewrite from HBEFA3 to HBEFA4 and lookup in detailed table again
2024-02-16T14:29:07,503  INFO WarmEmissionAnalysisModule:473  This message given only once.
2024-02-16T14:29:07,504  INFO WarmEmissionAnalysisModule:474  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:493 did not find emission factor for efkey=PASSENGER_CAR; CO; URB/Access/30; SATURATED; petrol (4S); >=2L; PC petrol (4S) Euro-4
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:494  re-written to PASSENGER_CAR; CO; URB/Access/30; SATURATED; petrol (4S); average; average
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:495 will try it with '<technology>; average; average'
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:496  This message given only once.
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:497  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:509 That also did not work.
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:510 Now trying with setting to vehicle attributes to "average; average; average" and try it with the average table
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:511  This message given only once.
2024-02-16T14:29:07,504  WARN WarmEmissionAnalysisModule:512  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,505  INFO VehicleUtils:340 vehicleId=2680945 not in allVehicles; trying standard vehicles container ...
2024-02-16T14:29:07,505  INFO VehicleUtils:340 vehicleId=2680945 not in allVehicles; trying standard vehicles container ...
2024-02-16T14:29:07,505  INFO VehicleUtils:342  Future occurences of this logging statement are suppressed.
2024-02-16T14:29:07,506  INFO EventsManagerImpl:137  event # 16
Exception in thread "main" java.lang.RuntimeException: Was not able to lookup emissions factor. Maybe you wanted to look up detailed values and did not specify this in the config OR you should use another fallback setting when using detailed calculation OR values ar missing in your emissions table(s) either average or detailed OR... ? efkey: PASSENGER_CAR; NOx; 13; 2; petrol (4S); >=2L; PC petrol (4S) Euro-4
        at org.matsim.contrib.emissions.ColdEmissionAnalysisModule.getEmissionsFactor(ColdEmissionAnalysisModule.java:408)
        at org.matsim.contrib.emissions.ColdEmissionAnalysisModule.calculateColdEmissions(ColdEmissionAnalysisModule.java:190)
        at org.matsim.contrib.emissions.ColdEmissionAnalysisModule.checkVehicleInfoAndCalculateWColdEmissions(ColdEmissionAnalysisModule.java:117)
        at org.matsim.contrib.emissions.ColdEmissionHandler.handleEvent(ColdEmissionHandler.java:115)
        at org.matsim.core.events.EventsManagerImpl.callHandlerFast(EventsManagerImpl.java:268)
        at org.matsim.core.events.EventsManagerImpl.processEvent(EventsManagerImpl.java:141)
        at org.matsim.core.events.EventsReaderXMLv1.startEvent(EventsReaderXMLv1.java:104)
        at org.matsim.core.events.EventsReaderXMLv1.startTag(EventsReaderXMLv1.java:80)
        at org.matsim.core.events.MatsimEventsReader$XmlEventsReader.startTag(MatsimEventsReader.java:140)
        at org.matsim.core.utils.io.MatsimXmlParser.startElement(MatsimXmlParser.java:347)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:183)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2710)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
        at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:324)
        at org.matsim.core.utils.io.MatsimXmlParser.parse(MatsimXmlParser.java:197)
        at org.matsim.core.utils.io.MatsimXmlParser.readFile(MatsimXmlParser.java:149)
        at org.matsim.core.events.MatsimEventsReader.readFile(MatsimEventsReader.java:79)
        at org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents.main(RunComputeEmissionsEvents.java:108)

It seems to me the error was induced by some missing values from the provided HBEFA dataset.

Our running command is below:

java -Xmx16G -cp /mnt/efs/eqasim-java/ile_de_france/target/ile_de_france-1.3.1.jar:/mnt/efs/ile-de-france/output_vehicles/ile_de_france_run.jar: \
org.eqasim.ile_de_france.emissions.RunComputeEmissionsEvents \
--config-path /mnt/efs/ile-de-france/output_vehicles/ile_de_france_config.xml \
--hbefa-cold-avg /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/fix_comma/EFA_ColdStart_Vehcat_2015_Cold_Avergae.csv \
--hbefa-hot-avg /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/fix_comma/EFA_HOT_Vehcat_2015_Hot_Average.csv \
--hbefa-cold-detailed /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/fix_comma/EFA_ColdStart_Subsegm_2015_Cold_Detailed.csv \
--hbefa-hot-detailed /mnt/efs/ile-de-france/data/HBEFA/CML_HBEFA_Factors/fix_comma/Combined_EFA_HOT_Subsegm_2015_Hot_Detialed.csv

Currently, we are using two jar files

  1. /mnt/efs/eqasim-java/ile_de_france/target/ile_de_france-1.3.1.jar . This is the one we made changes to the code

  2. /mnt/efs/ile-de-france/output_vehicles/ile_de_france_run.jar  is the original jar file which was created during the eqasim-IDF simulation pipeline

When we tried to use the first jar only after complying with the code in eqasim-java repo, it gave us some missing dependencies error.

As you suggested, we're trying to use the IDF debugger for the error. Could you please tell us how would you create the jar file after modifying the compute emission script? Thanks.

Nitnelav commented 9 months ago

Well, I don't know, I confused, may be it's because it's Friday and I'm tiered but there is too much unclear informations in your previous message.

If you could formulate a clear question or issue we can focus on instead of sending all your console errors here until it works I would appreciate it :)

Also, don't hesitate to close issues once you find a solution and open a new one as the next issue arrises. It is going to be easier to read for anyone who is trying to follow these discussions.

Finally, it seems like you could benefit from a few tutorials on using Java (using the IntelliJ IDE to debug, create jars etc.). I would suggest you spend a bit of time on that before going further.

sebhoerl commented 3 months ago

Closing this, please reopen if there are open questions.