Skip to content

faq 127336449

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

Car availability ignored

by harisbal on 2017-11-30 15:47:51


Hello,

I have a question regarding car availability. Although I include the carAvail attribute, MATSim seems to ignore it. For instance at the last simulation agent (id=1) switches to car although she does not have access to car. Do you have any idea what I'm missing?

<objectAttributes>
    <object id="1">     
        <attribute name="sex" class="java.lang.String">Female</attribute>
        <attribute name="age" class="java.lang.Integer">34</attribute>
        <attribute name="carAvail" class="java.lang.String">never</attribute>      
    </object>
 </objectAttributes>
In Config.xml
 <module name="changeMode" >
 	<param name="ignoreCarAvailability" value="false"/>
 	<param name="modes" value="car,other"/>
 </module>
<population>
   <person id="1">
     <plan selected="yes">
       <activity type="dummy" x="54.71" y="14.95" end_time="12:18:52"/>
       <leg mode="other"/>
       <activity type="dummy" x="546812.152" y="179276.805"/>
     </plan>
   </person>
 </population>

Comments: 2


Re: Car availability ignored

by harisbal on 2017-11-30 17:15:45

It seems like carAvail must be declared like that to be picked up by MATSim:

  <person id="1">
     <attributes>
       <attribute name="sex" class="java.lang.String">Male</attribute>
       <attribute name="age" class="java.lang.Integer">58</attribute>
       <attribute name="income" class="java.lang.Integer">43000</attribute>
       <attribute name="carAvail" class="java.lang.String">never</attribute>
     </attributes>
     <plan selected="yes">
       <activity type="dummy" x="549425.671" y="180234.925" end_time="12:18:52"/>
       <leg mode="avrs"/>
       <activity type="dummy" x="546812.152" y="179276.805"/>
     </plan>
   </person>
 

Could someone please suggest which is the most appropriate way to define personAttributes?

Thank you in advance!


Re: Car availability ignored

by Kai Nagel on 2017-12-01 02:34:05

Ok. Sorry. Historically, we had:

  1. The Customizable interface, which allows a call getCustomAttributes(...) attached to objects (e.g. persons) that implement the interface. Entries here were, however, neither read from file nor written to file. Code using this facility had to be completely written by the user.

  2. To address the file reading/writing problems, there were then ObjectAttributes, which was a separate data structure, with its own readers and writers, and which could latch on to matsim objects (.e.g persons) via the ID. Code using this facility had to be completely written by the user.

  3. At some point, a specific file of type {{ObjectAttributes}} was used for person attributes. The file name of this was entered in the config, and entries were available via {{population.getPersonAttributes(...)}}. This status probably corresponds to the original question.

  4. Finally, we started the option to include arbitrary free from attributes directly into the matsim files. This corresponds to the answer by harisbal. If you look into the code, the car availability thing is read/set with command {{PersonUtils.get/setCarAvail(...)}}.

So I don't know if this answers the question. If you program your population in code, you have to use {{PersonUtils.setCarAvail(...)}}.

Beyond that, it seems that some things are now in the separate file (version 3), and some are now as additional attributes in the population.xml. I think that our plan is to move most of the material to version 4, but (a) as usual please understand that our resources for community work are limited, and (b) there are actually use cases where leaving the material in a separate file may make sense.

Clone this wiki locally