licit-lab / MnMS

Agent-based Multimodal Urban Moblity Simulator resulting from the ERC MAGnUM project
GNU Lesser General Public License v3.0
10 stars 4 forks source link

Sum of exponential cost equal to zero. Leading to division by zero #60

Closed touf63 closed 2 years ago

touf63 commented 2 years ago

Trace for a running simulation with mobility services WALK, CAR for all demand to 6:30 to 11:00 :

INFO(mnms.flow.MFD): MFD step Time(09:00:00.00) INFO(mnms.simulation): Done [4.3965 s] INFO(mnms.simulation): Updating graph ... INFO(mnms.simulation): Done [0.44772 s] INFO(mnms.simulation): Writing travel time of each link in graph ... INFO(mnms.simulation): Done [0.096553 s] INFO(mnms.simulation): -------------------------------------------------- INFO(mnms.simulation): Current time: Time(09:00:00.00), affectation step: 15 INFO(mnms.simulation): Getting next departures Time(09:00:00.00)->Time(09:10:00.00) .. INFO(mnms.simulation): Done, 17458 new departure INFO(mnms.simulation): Computing paths for new users .. Traceback (most recent call last): File "/Users/c.tettarassar/Documents/LICIT/Code/MnMS-develop/RUN/run.py", line 68, in supervisor.run(Time('06:30:00'), Time('11:00:00'), Dt(minutes=1), 10) File "/Users/c.tettarassar/Documents/LICIT/Code/MnMS-develop/src/mnms/simulation.py", line 78, in run self._decision_model(nu) File "/Users/c.tettarassar/Documents/LICIT/Code/MnMS-develop/src/mnms/travel_decision/model.py", line 104, in call user.path, user.path_cost = self.path_choice(paths, costs) File "/Users/c.tettarassar/Documents/LICIT/Code/MnMS-develop/src/mnms/travel_decision/logit.py", line 29, in path_choice proba_path = [exp(-self._thetac)/sum_cost_exp for c in costs] File "/Users/c.tettarassar/Documents/LICIT/Code/MnMS-develop/src/mnms/travel_decision/logit.py", line 29, in proba_path = [exp(-self._thetac)/sum_cost_exp for c in costs] ZeroDivisionError: float division by zero Process finished with exit code 1

Quick fix : If a cost is equal to zero, returning the first path and first cost.

floriangc commented 2 years ago

Take the first cost and show a warning