Skip to content

faq 105381909

Billy Charlton edited this page Sep 5, 2018 · 2 revisions

Calibration with Cadyts

by Tony on 2017-01-09 11:52:19


Dear Sir/Madam,

I am trying to calibrate my MATSim scenario using Cadyts. The Cadyts (version 7) works very well within MATSim version 7. However, when I calibrated my scenario using Cadyts (Version 8) within MATSim 8 (I used the same data and config.xml), it seems that the Cadyts (Version 8) does not work at all. I also run my scenario without Cadyts, the simulated traffic flow is the same as the one using Cadyts (Version 8), which suggests the calibration does not work.

I guess there may be two reasons:

First, I did not set up the calibration correctly within MATSim 8.

Second, there are some major changes in Cadyts (Version 8).

Here is the codes I used in MATSim 8 (The codes are provided by the Cadyts (Version 8) and I just slightly adjusted them by adding the Count Reader).

Thank you very much.

Best Regads,

Tony



String filename="";
 final Config config = ConfigUtils.loadConfig( filename, new CadytsConfigGroup() ) ;
 final Scenario scenario = ScenarioUtils.loadScenario(config) ;
 Counts<Link> calibrationCounts = new Counts<>();
 new CountsReaderMatsimV1(calibrationCounts).readFile("./counts_V3_Calibration.xml");
 // ---
 final Controler controler = new Controler( scenario ) ;


 CadytsCarModule cadytsCarModule=new CadytsCarModule(calibrationCounts);
 controler.addOverridingModule(cadytsCarModule);

 // include cadyts into the plan scoring (this will add the cadyts corrections to the scores):
 controler.setScoringFunctionFactory(new ScoringFunctionFactory() {
    @Inject CadytsContext cadytsContext;
    @Inject CharyparNagelScoringParametersForPerson parameters;
    @Override
    public ScoringFunction createNewScoringFunction(Person person) {
       final CharyparNagelScoringParameters params = parameters.getScoringParameters(person);

       SumScoringFunction scoringFunctionAccumulator = new SumScoringFunction();
       scoringFunctionAccumulator.addScoringFunction(new CharyparNagelLegScoring(params, controler.getScenario().getNetwork()));
       scoringFunctionAccumulator.addScoringFunction(new CharyparNagelActivityScoring(params)) ;
       scoringFunctionAccumulator.addScoringFunction(new CharyparNagelAgentStuckScoring(params));
       final CadytsScoring<Link> scoringFunction = new CadytsScoring<>(person.getSelectedPlan(), config, cadytsContext);
       scoringFunction.setWeightOfCadytsCorrection(30. * config.planCalcScore().getBrainExpBeta()) ;
       scoringFunctionAccumulator.addScoringFunction(scoringFunction );
       return scoringFunctionAccumulator;
    } 
 }) ;

 controler.run() ;

Comments: 1


Re: Calibration with Cadyts

by Kai Nagel on 2017-01-18 12:24:14

I would say that the way it is set up, the counts will not end up in the "central" registry, and thus not be used by cadyts.  I would try something like

final Config config = ConfigUtils.loadConfig( filename, new CadytsConfigGroup() ) ;
 config.counts().setInputFile("...");
 final Scenario scenario = ScenarioUtils.loadScenario(config) ;
 ...

and then not set/read the counts file separately.

Maybe this helps, pls let us know.

Clone this wiki locally