gama.old icon indicating copy to clipboard operation
gama.old copied to clipboard

Running advanced driving skill in parallel

Open ThomasHuraux opened this issue 5 years ago • 5 comments

Hi,

Steps to reproduce

  1. Enable "Make species schedule their agents in parallel" option in Preferences/Execution

  2. Run "Road Traffic Complex.gaml" in Driving Skill/models/

Expected behavior

The simulation runs as fast as lightning

Actual behavior

Some agents stop moving and 2 types of errors occur :

EXAMPLE OF ERROR - TYPE 1 ____________________

2 occurrences in 2 agents at cycle 303: Java error: nil value detected
in 
NullPointerException: null
in agents people172, people123

EXAMPLE OF ERROR - TYPE 2 ____________________

1 occurence in people55 at cycle 303: Java error: ConcurrentModificationException
in 
ConcurrentModificationException: null
java.util.ArrayList$Itr.checkForComodification(Unknown Source)
java.util.ArrayList$Itr.next(Unknown Source)
simtools.gaml.extensions.traffic.DrivingSkill.avoidCollision(DrivingSkill.java:1328)
simtools.gaml.extensions.traffic.DrivingSkill.avoidCollision(DrivingSkill.java:1558)
simtools.gaml.extensions.traffic.DrivingSkill.moveToNextLocAlongPathOSM(DrivingSkill.java:1658)
simtools.gaml.extensions.traffic.DrivingSkill.primAdvancedFollow(DrivingSkill.java:491)
simtools.gaml.extensions.traffic.DrivingSkill.primDrive(DrivingSkill.java:982)
in agent people55

System and version

GAMA Platform - V1.8.0 (last version, continuous build) Windows 10 jre1.8.0_221

ThomasHuraux avatar Nov 29 '19 15:11 ThomasHuraux

Dear, thank you for the issue. Nevertheless, I tied with the GAMA 1.8.0 release and with the git (master) version and I cannot reproduce your issue.

More curious, I was not able to get the model you are mentioning: "Road Traffic Complex.gaml" in Driving Skill/models/. Could you perhaps check your GAMA version and try after having created a new workspace?

Cheers

benoitgaudou avatar Dec 04 '19 09:12 benoitgaudou

Hi,

Thank you for your response.

I tried using gama/simtools.gaml.extensions.traffic/models/Driving Skill/models/Driving skill.gaml (experiment_city) with the GAMA 1.8.0 release and a fresh workspace.

Same errors occur again :(

Cheers, Thomas

ThomasHuraux avatar Dec 06 '19 14:12 ThomasHuraux

Hi,

I have the same error as Thomas. To be totally honest, I'm not surprised: this skill wasn't designed to be run in parallel and there are many elements that can cause this kind of error. I don't even know when we could make this skill parallelizable as a lot of calculations depend on other agents.

On the other hand, what is possible is to at least parallelize the calculation of the shortest path (which can take time).

Cheers,

Patrick

Le ven. 6 déc. 2019 à 15:50, Thomas H [email protected] a écrit :

Hi,

Thank you for your response.

I tried using gama/simtools.gaml.extensions.traffic/models/Driving Skill/models/Driving skill.gaml (experiment_city) with the GAMA 1.8.0 release and a fresh workspace.

Same errors occur again :(

Cheers, Thomas

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gama-platform/gama/issues/2912?email_source=notifications&email_token=AALPWHJ4HOZJWQ3AQOEMJWDQXJRE7A5CNFSM4JTBGKYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGEJVWA#issuecomment-562600664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALPWHISHWIZA53NAH7TV2TQXJRE7ANCNFSM4JTBGKYA .

ptaillandier avatar Dec 06 '19 15:12 ptaillandier

Hi,

I think, with respect to this "bug", that this issue should turn into a request for enhancement : make this skill respect the general rules that allow other skills to run in parallel... Cheers Alexis

AlexisDrogoul avatar Dec 09 '19 03:12 AlexisDrogoul

The error comes from the fact that a number of lists (accessible through RoadSkill.AGENTS_ON and RoadSkill.AGENTS mainly, but there might be others) are read and written concurrently from everywhere in the code of the DrivingSkill and RoadSkill, with a lot of side effects. It is very difficult to understand where you can operate on copies and when you need to pass the actual list (to which agents might be added or removed).

I would suggest to replace the AGENTS_ON value with a proper object structure that could keep track of the number of lanes, segments, the lists of agents per segments, the total number of agents, etc. provide the possibility to iterate over the agents (read-only) and to add or remove an agent while taking care of concurrent accesses...

AlexisDrogoul avatar Feb 14 '20 06:02 AlexisDrogoul