乔165 2022-06-05 18:01 采纳率: 0%
浏览 15

eclipse运行错误:WARN EmissionsConfigGroup:542 This property is deprecated and will be removed soon.

我运行的是matsin-libs-master里contribs的emission板块的代码,根据输入数据文件生成config文件。完整代码如下:(*开头是注释)

 * project: org.matsim.*
 * copyright       : (C) 2014 by the members listed in the COPYING,        *
 *                   LICENSE and WARRANTY file.                            *
 * email           : info at matsim dot org                                *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *   See also COPYING, LICENSE and WARRANTY file                           *
package org.matsim.contrib.emissions.example;

import org.matsim.contrib.emissions.utils.EmissionsConfigGroup;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigWriter;
import org.matsim.core.config.groups.*;
import org.matsim.core.config.groups.PlanCalcScoreConfigGroup.ActivityParams;
import org.matsim.core.config.groups.StrategyConfigGroup.StrategySettings;
import org.matsim.core.controler.Controler;
import org.matsim.core.controler.MatsimServices;

 * Creates a config file 
 * with necessary emission input files for the {@link EmissionsConfigGroup EmissionsConfigGroup}.
 * 
 * This config file is used by the {@link RunDetailedEmissionToolOfflineExample OfflineExample} and
 * the {@link RunDetailedEmissionToolOnlineExample OnlineExample}
 * 
 * @author benjamin, julia
 *
 * @deprecated -- has not been maintained and should in consequence be phased out.  kai, nov'21
@Deprecated // has not been maintained and should in consequence be phased out.  kai, nov'21
public final class CreateEmissionConfig {

        private static final String inputPath = "E:/Eclipse/workspaceB/matsim-libs-master/contribs/emissions/test/input/org/matsim/contrib/emissions/z_lx/1";
        private static final String networkFile = //inputPath + 
                "sample_network.xml";
        private static final String plansFile = //inputPath + 
                "sample_population.xml";
        private static final String emissionVehicleFile = //inputPath + 
                "sample_emissionVehicles.xml";
        
        private static final String roadTypeMappingFile = //inputPath +
                "sample_roadTypeMapping.txt";
        
        private static final String averageFleetWarmEmissionFactorsFile = //inputPath +
                "sample_EFA_HOT_vehcat_2005average.txt";
        private static final String averageFleetColdEmissionFactorsFile = //inputPath +
                "sample_EFA_ColdStart_vehcat_2005average.txt";
        
        private static final boolean isUsingDetailedEmissionCalculation = true;
        private static final String detailedWarmEmissionFactorsFile = //inputPath +
                "sample_EFA_HOT_SubSegm_2005detailed.txt";
        private static final String detailedColdEmissionFactorsFile = //inputPath +
                 "sample_EFA_ColdStart_SubSegm_2005detailed.txt";
        
        private static final String outputPath = "E:/Eclipse/workspaceB/matsim-libs-master/contribs/emissions/test/output/";
        private static final String configFilePath = inputPath + "config_v2.xml";
        
        private static final int numberOfIterations = 6;
        
        
        public static void main(String[] args) {
            
            Config config = new Config();
            config.addCoreModules();
            MatsimServices controler = new Controler(config);
            
        // controlerConfigGroup
            ControlerConfigGroup ccg = controler.getConfig().controler();
            ccg.setOutputDirectory(outputPath);
            ccg.setFirstIteration(0);
            ccg.setLastIteration(numberOfIterations-1);
            
        // planCalcScoreConfigGroup
            PlanCalcScoreConfigGroup pcs = controler.getConfig().planCalcScore();
            ActivityParams homeP = new ActivityParams("home");
            homeP.setTypicalDuration(12 * 3600);
            pcs.addActivityParams(homeP);
            ActivityParams workP = new ActivityParams("work");
            workP.setTypicalDuration(8 * 3600);
            pcs.addActivityParams(workP);

        // strategy
            StrategyConfigGroup scg = controler.getConfig().strategy();
            StrategySettings strategySettings = new StrategySettings();
            strategySettings.setStrategyName("ChangeExpBeta");
            strategySettings.setWeight(1.0);
            scg.addStrategySettings(strategySettings);
            
        // network
            NetworkConfigGroup ncg = controler.getConfig().network();
            ncg.setInputFile(networkFile);
            
        // plans
            PlansConfigGroup pcg = controler.getConfig().plans();
            pcg.setInputFile(plansFile);
            
        // define emission tool input files    
            EmissionsConfigGroup ecg = new EmissionsConfigGroup() ;
            controler.getConfig().addModule(ecg);

            // one can now directly set the hbefa road types as link attributes
            ecg.setEmissionRoadTypeMappingFile(roadTypeMappingFile);
            ecg.setHbefaRoadTypeSource(EmissionsConfigGroup.HbefaRoadTypeSource.fromFile);

            // emission vehicles are now set in the default vehicle container
            config.vehicles().setVehiclesFile(emissionVehicleFile);

            if ( (Boolean) false ==null ) {
                ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.asEngineInformationAttributes );
            } else if ( false ) {
                ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.usingVehicleTypeId );
            } else {
                ecg.setHbefaVehicleDescriptionSource( EmissionsConfigGroup.HbefaVehicleDescriptionSource.fromVehicleTypeDescription );
            }

            ecg.setAverageWarmEmissionFactorsFile(averageFleetWarmEmissionFactorsFile);
            ecg.setAverageColdEmissionFactorsFile(averageFleetColdEmissionFactorsFile);
//            ecg.setUsingDetailedEmissionCalculation(isUsingDetailedEmissionCalculation);
            ecg.setDetailedWarmEmissionFactorsFile(detailedWarmEmissionFactorsFile);
            ecg.setDetailedColdEmissionFactorsFile(detailedColdEmissionFactorsFile);

            ecg.setWritingEmissionsEvents(false);
            ecg.setEmissionCostMultiplicationFactor(1.0);
            ecg.setConsideringCO2Costs(true);
//            ecg.setEmissionEfficiencyFactor(1.0);
            
       // write config     
            ConfigWriter cw = new ConfigWriter(config);
            cw.write(configFilePath);             

    }

}
以下是报错详细信息:

​​

img


2022-06-05T17:24:43,263 WARN EmissionsConfigGroup:542 This property is deprecated and will be removed soon. The emission contrib expects HbefaRaodTypes to be set as link attributes explicitly
Exception in thread "main" java.lang.RuntimeException: Cost calculations are not part of the emissions contrib. Do not use this config setting.
at org.matsim.contrib.emissions.utils.EmissionsConfigGroup.setEmissionCostMultiplicationFactor(EmissionsConfigGroup.java:490)
at org.matsim.contrib.emissions.example.CreateEmissionConfig.main(CreateEmissionConfig.java:137)

初学者,不是很明白,一个“error”字眼都没看到,我以为能运行的,结果输出路径里啥也没有。是要咋弄呢。

  • 写回答

1条回答 默认 最新

  • BCS-点心 2022-06-06 09:26
    关注

    java.lang.RuntimeException:是运行时异常的意思,就是程序运行的时候出错了
    具体错误是下面这句话:
    Cost calculations are not part of the emissions contrib. Do not use this config setting.
    查了下,没找到什么解释,只能从字面意思上看,是使用的配置有问题

    评论

报告相同问题?

问题事件

  • 创建了问题 6月5日

悬赏问题

  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用
  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题