Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DMC config module to MC valid #71

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

syhwawa
Copy link
Contributor

@syhwawa syhwawa commented Nov 1, 2023

Regarding to the issue #70, MC failed due to a validation step when testing DMC module in the simulation.

Here is the DMC module we would like to try in the matsim config:

  <module name="DiscreteModeChoice">
    <param name="modelType" value="Tour" />
    <param name="selector" value="MultinomialLogit" />
	<parameterset type="selector:MultinomialLogit" >
	<!-- Defines whether candidates with a utility lower than the minimum utility should be filtered out. -->
	<param name="considerMinimumUtility" value="false" />
	<!-- Candidates with a utility above that threshold will be cut off to this value. -->
	<param name="maximumUtility" value="700.0" />
	<!-- Candidates with a utility lower than that threshold will not be considered by default. -->
	<param name="minimumUtility" value="-700.0" />
    </parameterset>
   <param name="tourConstraints" value="SubtourMode" />
   <!--		<param name="tourConstraints" value="VehicleContinuity,SubtourMode" />-->
   <param name="tourFinder" value="PlanBased" />
   <param name="tourEstimator" value="Uniform" />
   <parameterset type="modeAvailability:Car">
	<param name="availableModes" value="car,pt,walk,bike" />
  </parameterset>
  </module>

In the base.py file, it seems when building parameters key process, it cannot handel inputs selector:MultinomialLogit and modeAvailability:Car in the DMC module with error below:

  File "/Users/yuhao.sun/Personal_projects/mc/mc/base.py", line 147, in build_from_xml
    _, key, uid = build_paramset_key(sub_object)
  File "/Users/yuhao.sun/Personal_projects/mc/mc/base.py", line 998, in build_paramset_key
    raise ValueError(
ValueError: Cannot build paramset key due to unrecognised parameterset: selector:MultinomialLogit in xml
    self.build_from_xml(xml_object)
  File "/Users/yuhao.sun/Personal_projects/mc/mc/base.py", line 147, in build_from_xml
    _, key, uid = build_paramset_key(sub_object)
  File "/Users/yuhao.sun/Personal_projects/mc/mc/base.py", line 998, in build_paramset_key
    raise ValueError(
ValueError: Cannot build paramset key due to unrecognised parameterset: modeAvailability:Car in xml

I have added new conditions to handle this type of input in the build_paramset_key function to the base.py.

And updated mc work fine with newly added DMC config when I test the matsim config locally using mc debug cli.


Regarding to the issue #72, I have also updated the load_overrides function in autostep.py to check for the existence of the file before attempting to open it.

@syhwawa syhwawa force-pushed the add-DMC-config-module branch from c11983c to c69e9ed Compare November 1, 2023 16:59
@syhwawa syhwawa requested review from mfitz and gac55 November 1, 2023 19:46
Copy link
Contributor

@mfitz mfitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks reasonable, but I don't see any unit tests for the new code, and sure enough, when I run the code coverage report for this branch and for main locally, I see that coverage has dropped from 85.94% to 85.61% with your change. We should be testing any new code we add. We need to add tests for this new logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileNotFoundError when matsim_overrides.json File is Missing MC Failed with newly added DMC module.
2 participants