matsim-org / matsim-code-examples

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

How to use TerminationCriterion #672

Open AntonisKoutounidis opened 2 years ago

AntonisKoutounidis commented 2 years ago

I would like to run MATSim without using a predetermined number of iterations. Found out about this https://github.com/matsim-org/matsim-libs/blob/fc97a437f52e4c23d50935e8ea6790e2bfbe10e8/matsim/src/test/java/org/matsim/core/controler/ControlerIT.java.

However, is there any example using this functionality? Can someone guide me on how to use it?

kainagel commented 2 years ago

I added a short example here: https://github.com/matsim-org/matsim-code-examples/blob/14.x/src/main/java/org/matsim/codeexamples/programming/terminationCriterion/RunTerminationCriterionExample.java . Note that this is in the "14.x" branch of the code examples. It should, however, also work with version 13.x of matsim.

This is essentially the same as what is in ControlerIT mentioned above, except that it uses Guice directly rather than the thin interface in between. Guice will allow you more flexibility. On the other hand, if you feel more comfortable with the way it is in ControlerIT, then that will also be fine.

Hope this helps ...

AntonisKoutounidis commented 2 years ago

Thanks for the example. I have a question. What is the meaning of (iteration == 10) in the 37th line of the example. What is the meaning of this 10. Also do I need to set any specific parameter in the config file?

sebhoerl commented 2 years ago

Hi Antonis, you can find a full implementation of the TerminationCriterion here (although without a lot of documentation) as part of our simulation scenarios for Île-de-France. It basically tracks the (trip-based) mode shares of the main modes in the simulation and stops once a convergence criterion is reached:

https://github.com/eqasim-org/eqasim-java/tree/convergence/core/src/main/java/org/eqasim/core/simulation/convergence

Some more information can be found in the following preprint. It describes the basic idea and the convergence criterion we use:

Hörl, S. (2022) Exploring accelerated evolutionary parameter search for iterative large-scale transport simulations in a new calibration testbed

I'm currently cleaning up some code (although the stuff from above) to set up consistent and reusable calibration pipelines for MATSim. I just pushed the basic code and information and I will add the MATSim specific examples in the coming days:

https://github.com/sebhoerl/boptx